Skip to content
Open
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
258 changes: 258 additions & 0 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[package]
name = "mollycache"
version = "0.1.0"
edition = "2024"
edition = "2024"

[dev-dependencies]
rusqlite = { version = "0.38.0", features = ["bundled"] }
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ MollyCache is a high-performance, in-memory SQL database with row-based caching
- [Rust](https://rust-lang.org/tools/install/) v1.88.0 or higher
- Optionally, for testing, the [`tarpaulin`](https://crates.io/crates/cargo-tarpaulin) crate (install with `cargo install tarpaulin`)

## Development Setup

To set up your environment (Git hooks, `molly` CLI shortcut):

**Windows (PowerShell):**
```powershell
.\scripts\setup.ps1
```

**Linux / macOS:**
```bash
./scripts/setup.sh
```

This will:
1. Enable `cargo fmt` checks before commits.
2. Add the `molly` command to your shell:
- `molly`: Jump to project root.
- `molly -t feature-name`: Create or switch to a worktree in `worktrees/feature-name`.

## Running

To run the MollyCache interactive CLI:
Expand Down Expand Up @@ -75,4 +95,4 @@ The entire database is built to be atomic and thread-safe, allowing for concurre

Contributions and ideas are welcome! Current progress is tracked using the [issues tab on GitHub](https://github.com/MollyCache/mollycache/issues).

Code contributions must be properly formatted before being merged. Run the formatter with `cargo fmt --all`.
Code contributions must be properly formatted before being merged. Run the formatter with `cargo fmt --all`.
87 changes: 87 additions & 0 deletions scripts/setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# PowerShell Setup Script for MollyCache
$ErrorActionPreference = "Stop"

$repoRoot = Resolve-Path "$PSScriptRoot\.."
$repoRoot = $repoRoot.Path
$profilePath = $PROFILE

Write-Host "🔮 Setting up MollyCache environment..."

# 1. Configure Git Hooks
Write-Host "1️⃣ Configuring Git Hooks..."
git config core.hooksPath .githooks
if ($LASTEXITCODE -eq 0) {
Write-Host " ✅ Git hooks enabled."
} else {
Write-Host " ❌ Failed to configure git hooks." -ForegroundColor Red
}

# 2. Install 'molly' alias/function
Write-Host "2️⃣ Installing 'molly' shell function..."

$mollyFunc = @"

# --- MollyCache Dev Tools ---
function molly {
param(
[Alias("t")]
[string]`$target
)

`$projectRoot = "$repoRoot"

if (-not `$target) {
Set-Location `$projectRoot
return
}

# Handle Worktrees
`$wtDir = Join-Path `$projectRoot "worktrees" `$target

if (Test-Path `$wtDir) {
Write-Host "📂 Switching to worktree: `$target" -ForegroundColor Cyan
Set-Location `$wtDir
} else {
Write-Host "🌿 Creating new worktree: `$target" -ForegroundColor Green

# Capture current location to return if git fails
`$oldLoc = Get-Location
Set-Location `$projectRoot

# Create worktree (detached or new branch)
# Try to verify if branch exists or create new one
try {
git worktree add "worktrees/`$target" -b "ai/`$target"
} catch {
Write-Warning "Branch might already exist or name is invalid. Trying checkout without -b..."
git worktree add "worktrees/`$target" `$target
}

if ($?) {
Set-Location `$wtDir
# Copy config if needed (optional)
} else {
Set-Location `$oldLoc
Write-Error "Failed to create worktree."
}
}
}
# ----------------------------
"@

# Check if already installed
if (Test-Path $profilePath) {
$currentProfile = Get-Content $profilePath -Raw
if ($currentProfile -match "# --- MollyCache Dev Tools ---") {
Write-Host " ⚠️ 'molly' function already exists in profile. Skipping." -ForegroundColor Yellow
} else {
Add-Content -Path $profilePath -Value $mollyFunc
Write-Host " ✅ 'molly' function added to $profilePath"
}
} else {
New-Item -Path $profilePath -ItemType File -Force | Out-Null
Add-Content -Path $profilePath -Value $mollyFunc
Write-Host " ✅ Created profile and added 'molly' function."
}

Write-Host "`n🎉 Setup complete! Restart your terminal or run '. `$profilePath' to use the 'molly' command."
Loading
Loading