Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ releases/*.tar.gz
# Conversation history (contains potential secrets)
*.txt
*.py
!scripts/fast_build.py
!scripts/resolve_merge_conflicts.py
!scripts/upstream_sync.py
C:\Users\downl\Desktop\codex-main\.specstory\history\2026-01-16_05-43Z-未来のai開発と統合エコシステム.md
codex-rs/build_error.txt
codex-rs/build_error.txt
Expand Down
12 changes: 6 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### ✅ Added

- **Fast Incremental Build System (`scripts/fast_build.py`)**
- **Fast Incremental Build System (`scripts/fast_build.py` + `scripts/upstream_sync.py`)**
- MD5 hash-based change detection for intelligent rebuilds
- Cargo incremental compilation optimization
- Parallel build processing with CPU core utilization
- tqdm-powered progress visualization
- Build cache persistence (`.build_cache.pkl`)
- Build cache persistence (`.codex-fast-build-cache.json`)

- **Hot Reload Installation System (`scripts/build_and_install.py`)**
- **Hot Reload Installation System (`scripts/fast_build.py fast-build-install`)**
- Cross-platform process detection and termination (psutil)
- Atomic binary replacement with safety checks
- Platform-specific installation (Windows/macOS/Linux)
- Installation verification with version checking
- PowerShell integration for Windows deployment
- PowerShell wrapper (`codex-rs/fast_build.ps1`) plus `just fast-build*` entry points

- **Integrated Release Packaging**
- GitHub Actions workflow for cross-platform tgz packages
Expand All @@ -129,8 +129,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- **Development Tools Enhancement**
- `just fast-build` - Quick incremental builds
- `just build-install` - Full pipeline execution
- `just install-kill` - Direct binary replacement
- `just fast-build-install` - Full pipeline execution
- `just upstream-sync` - Upstream merge + resolver orchestration
- Process-safe deployment with zero-downtime updates

### 🎯 Performance Improvements
Expand Down
10 changes: 7 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ just clippy # Lint all crates
just fix -p <crate> # Auto-fix clippy issues for a specific crate
just test # Run all tests with cargo-nextest
just install # Fetch dependencies, show active toolchain
just fast-build [targets] # Differential build via scripts/fast_build.py
just fast-build-install # Differential build + install via scripts/fast_build.py
just upstream-sync # Fetch/merge upstream and run resolver
just codex # Run codex from source (cargo run --bin codex)
just exec "prompt" # Run codex exec mode

Expand All @@ -40,11 +43,12 @@ cargo shear # Find unused dependencies
cargo deny check # License/security audit
```

### Windows fast-build scripts (from codex-rs/)
### Cross-platform fast-build tasks

```powershell
.\ultra-fast-build-install.ps1 # Fastest incremental build
.\clean-build-install.ps1 # Clean rebuild
just fast-build codex-cli codex-tui # Differential build
just fast-build-install codex-cli codex-tui # Differential build + install
.\fast_build.ps1 -Task fast-build-install # Windows wrapper around scripts/fast_build.py
```

### Bazel (alternative build system)
Expand Down
12 changes: 7 additions & 5 deletions codex-rs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ Codex-RSは、依存関係の重い環境から脱却し、**単一のネイテ
**Built for speed.**

- **sccache Support**: Optimized for 6-core parallel builds, drastically reducing compilation time.
- **Atomic Updates**: Smart installation scripts (`fast_build.ps1`) ensuring zero-downtime updates during development.
- **Atomic Updates**: `just fast-build-install` and `fast_build.ps1` wrap a shared Python pipeline for zero-downtime updates during development.

**スピードを追求**

- **sccacheサポート**: 6コア並列ビルドに最適化されており、コンパイル時間を大幅に短縮。
- **アトミック更新**: スマートなインストールスクリプト(`fast_build.ps1`)により、開発中のゼロダウンタイム更新を実現。
- **アトミック更新**: `just fast-build-install` と `fast_build.ps1` が共通Pythonパイプラインを呼び出し、開発中のゼロダウンタイム更新を実現。

---

Expand Down Expand Up @@ -100,9 +100,11 @@ For developers who value speed, utilize our optimized PowerShell workflow:
スピードを重視する開発者向けに、最適化されたPowerShellワークフローを提供しています:

```powershell
# Optimized for 6-core parallel processing
# 6コア並列処理に最適化
.\fast_build.ps1
# Default: 6 parallel jobs (override with CODEX_FAST_BUILD_JOBS or --jobs)
# 既定: 6並列(`CODEX_FAST_BUILD_JOBS` または `--jobs` で上書き)
just fast-build-install codex-cli codex-tui
# Windows wrapper
.\fast_build.ps1 -Task fast-build-install -Targets codex-cli,codex-tui
```

### Standard Usage / 基本的な使い方
Expand Down
100 changes: 42 additions & 58 deletions codex-rs/fast_build.ps1
Original file line number Diff line number Diff line change
@@ -1,62 +1,46 @@
# Fast Build & Install Script (Simplified)
# Requirements: 6-core, sccache, kill processes, overwrite install

$ErrorActionPreference = "Stop"

function Write-Status($msg) { Write-Host "[$(Get-Date -Format 'HH:mm:ss')] $msg" -ForegroundColor Cyan }
function Write-Success($msg) { Write-Host "[$(Get-Date -Format 'HH:mm:ss')] $msg" -ForegroundColor Green }

# 1. Setup Environment
if ($env:USE_SCCACHE -eq "1" -and (Get-Command sccache -ErrorAction SilentlyContinue)) {
$env:RUSTC_WRAPPER = "sccache"
$cacheMode = "sccache"
} else {
Remove-Item Env:RUSTC_WRAPPER -ErrorAction SilentlyContinue
$env:SCCACHE_DISABLE = "1"
$cacheMode = "rustc"
[CmdletBinding()]
param(
[ValidateSet('fast-build', 'fast-build-install')]
[string]$Task = 'fast-build-install',
[ValidateSet('md5', 'mtime', 'cargo-metadata')]
[string]$Method = $(if ($env:CODEX_FAST_BUILD_METHOD) { $env:CODEX_FAST_BUILD_METHOD } else { 'md5' }),
[int]$Jobs = $(if ($env:CODEX_FAST_BUILD_JOBS) { [int]$env:CODEX_FAST_BUILD_JOBS } else { 6 }),
[string[]]$Targets = @('codex-cli', 'codex-tui', 'codex-gui'),
[string]$LogFile,
[switch]$Force,
[switch]$NoDenyWarnings
)

$ErrorActionPreference = 'Stop'
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
$scriptPath = Join-Path $repoRoot 'scripts\fast_build.py'
$python = if (Get-Command py -ErrorAction SilentlyContinue) { 'py' } elseif (Get-Command python -ErrorAction SilentlyContinue) { 'python' } else { throw 'Python launcher not found (expected py or python).' }

$argsList = @()
if ($python -eq 'py') {
$argsList += '-3'
}
$env:RUSTFLAGS = "-D warnings"
Write-Status "Environment configured: compiler=$cacheMode, Jobs=6"

# 2. Kill Processes
Write-Status "Killing existing processes..."
Stop-Process -Name "codex" -Force -ErrorAction SilentlyContinue
Stop-Process -Name "codex-tui" -Force -ErrorAction SilentlyContinue
Stop-Process -Name "codex-gui" -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 1

# 3. Build (Direct execution for visibility)
Write-Status "Starting Cargo Build (CLI + TUI)..."
# We build both. If CLI is already built, sccache/cargo will skip it quickly.
cargo build --release -p codex-cli -p codex-tui -j 6

if ($LASTEXITCODE -ne 0) {
Write-Error "Build failed with code $LASTEXITCODE"
exit $LASTEXITCODE
$argsList += $scriptPath
$argsList += $Task
$argsList += '--changed-only'
$argsList += '--jobs'
$argsList += $Jobs
$argsList += '--method'
$argsList += $Method
if ($LogFile) {
$argsList += '--log-file'
$argsList += $LogFile
}

Write-Success "Build Complete."

# 4. Install (Overwrite)
Write-Status "Installing binaries..."
$installDir = "$env:USERPROFILE\.cargo\bin"
if (-not (Test-Path $installDir)) { New-Item -ItemType Directory -Path $installDir -Force }

$binaries = @("codex.exe", "codex-tui.exe")
foreach ($bin in $binaries) {
$src = "target\release\$bin"
$dest = "$installDir\$bin"

if (Test-Path $src) {
Write-Host "Copying $bin to $dest..."
Copy-Item -Path $src -Destination $dest -Force
Write-Success "Installed $bin"
}
else {
Write-Warning "$bin not found in target/release!"
}
if ($Force) {
$argsList += '--force'
}
if ($NoDenyWarnings) {
$argsList += '--no-deny-warnings'
}
if ($Targets.Count -gt 0) {
$argsList += $Targets
}

# 5. Verify
Write-Status "Verifying installation..."
& "$installDir\codex.exe" --version
Write-Host "[fast_build.ps1] $python $($argsList -join ' ')" -ForegroundColor Cyan
& $python @argsList
exit $LASTEXITCODE
13 changes: 12 additions & 1 deletion codex-rs/justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
set positional-arguments

python_cmd := if os_family() == "windows" { "py -3" } else { "python3" }
build_script := "../scripts/fast_build.py"
# Display help
help:
just -l
Expand Down Expand Up @@ -58,4 +60,13 @@ install-tui:
build-install-all:
cargo build --release -p codex-cli -p codex-tui
cargo install --path cli --force
cargo install --path tui --force
cargo install --path tui --force

fast-build *args:
{{python_cmd}} {{build_script}} fast-build --changed-only "$@"

fast-build-install *args:
{{python_cmd}} {{build_script}} fast-build-install --changed-only "$@"

upstream-sync *args:
{{python_cmd}} {{build_script}} upstream-sync "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- Cargo.lockの再生成

### 2. 高速差分ビルドの実行
- `scripts/fast_build.py debug codex-cli` を実行
- `python3 scripts/fast_build.py fast-build --changed-only codex-cli --profile debug` を実行
- ファイル変更検出(1363ファイル)完了
- フルビルドが必要と判定

Expand All @@ -26,7 +26,7 @@
- タイトル: "Codex Extended - Skills + MCP + Agents SDK Architecture"
- アーキテクチャ図: Mermaidで生成したv2.10.0アーキテクチャ図
- 機能説明: Skills System, MCP Integration, Agents SDK Patterns
- 使用例: `codex $ build-manager fast-build` などの新コマンド
- 使用例: `just fast-build`, `just fast-build-install`, `just upstream-sync` などの正式タスク
- 機能ステータスマトリックス更新
- ドキュメントリンク更新

Expand Down
25 changes: 13 additions & 12 deletions docs/plan/MERGE_STRATEGY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ This document describes the strategy for merging upstream OpenAI Codex changes w

- `zapabob/scripts/load-env.sh` - Environment loading script
- `zapabob/scripts/setup-env-vars.ps1` - PowerShell environment setup
- `merge_with_custom_features.py` - Custom merge tool
- `advanced_merge_resolver.py` - Advanced merge conflict resolver
- `scripts/upstream_sync.py` - Upstream merge orchestration entry point
- `scripts/resolve_merge_conflicts.py` - Upstream-first merge conflict resolver

## Merge Strategy

Expand All @@ -28,7 +28,7 @@ This document describes the strategy for merging upstream OpenAI Codex changes w
1. **Identify Custom Features**

```bash
python3 advanced_merge_resolver.py --identify
python3 scripts/resolve_merge_conflicts.py codex-rs/tui/src/slash_command.rs --rule "codex-rs/tui/src/slash_command.rs=upstream-reinject"
```

2. **Backup Current State**
Expand Down Expand Up @@ -58,7 +58,7 @@ git diff --name-only --diff-filter=U
#### Automatic Merge

```bash
python3 advanced_merge_resolver.py
python3 scripts/upstream_sync.py
```

#### Manual Merge (if needed)
Expand All @@ -77,7 +77,8 @@ python3 advanced_merge_resolver.py

```bash
# Check custom features preserved
python3 advanced_merge_resolver.py --verify
git diff --check
python3 scripts/fast_build.py fast-build --changed-only codex-cli codex-tui

# Run tests
cd codex-rs && cargo test -p codex-tui
Expand Down Expand Up @@ -115,7 +116,7 @@ Custom cmd Modified → Merge, preserve custom
**Solution**: Run the merge resolver

```bash
python3 advanced_merge_resolver.py --file codex-rs/tui/src/slash_command.rs
python3 scripts/resolve_merge_conflicts.py codex-rs/tui/src/slash_command.rs --rule "codex-rs/tui/src/slash_command.rs=upstream-reinject"
```

#### 2. Custom Features Not Detected
Expand All @@ -124,10 +125,9 @@ python3 advanced_merge_resolver.py --file codex-rs/tui/src/slash_command.rs

```bash
python3 -c "
from advanced_merge_resolver import MergeConflictResolver
resolver = MergeConflictResolver()
features = resolver.identify_custom_features()
print(features)
from scripts.resolve_merge_conflicts import choose_strategy, load_rules
rules = load_rules([])
print(choose_strategy("codex-rs/tui/src/slash_command.rs", rules))
"
```

Expand Down Expand Up @@ -163,12 +163,13 @@ if git merge upstream/main --no-edit; then
echo "Merge successful!"
else
echo "Conflicts detected, running resolver..."
python3 advanced_merge_resolver.py
python3 scripts/upstream_sync.py
fi

# Step 4: Verify
echo "[4/4] Verifying custom features..."
python3 advanced_merge_resolver.py --verify
git diff --check
python3 scripts/fast_build.py fast-build --changed-only codex-cli codex-tui

echo "=== Merge Complete ==="
```
Expand Down
11 changes: 11 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
set working-directory := "codex-rs"
set positional-arguments
python_cmd := if os_family() == "windows" { "py -3" } else { "python3" }
build_script := "../scripts/fast_build.py"

# Display help
help:
Expand Down Expand Up @@ -85,3 +87,12 @@ write-app-server-schema *args:
# Tail logs from the state SQLite database
log *args:
if [ "${1:-}" = "--" ]; then shift; fi; cargo run -p codex-state --bin logs_client -- "$@"

fast-build *args:
{{python_cmd}} {{build_script}} fast-build --changed-only "$@"

fast-build-install *args:
{{python_cmd}} {{build_script}} fast-build-install --changed-only "$@"

upstream-sync *args:
{{python_cmd}} {{build_script}} upstream-sync "$@"
Loading
Loading