Skip to content
Draft
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ _test*
.DS_Store
__pycache__
node_modules
.claude

# Build outputs
src/clients/go/build/

.vscode/*
!.vscode/*.shared.json
Expand Down
96 changes: 96 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

This is @justbe/webview, a cross-platform library for building web-based desktop apps. The architecture consists of:

- **Rust backend**: Core webview functionality using `tao` and `wry`
- **Multi-language clients**: Deno/TypeScript, Python, and Go clients that interface with the Rust binary via stdio

## Essential Commands

### Build Commands
```bash
# Build everything
mise build

# Build specific targets
mise build:rust # Build the webview binary
mise build:deno # Build Deno client
mise build:python # Build Python client
mise build:go # Build Go client
```

### Code Generation
```bash
# Generate all schemas and clients
mise gen

# Generate specific parts
mise gen:rust # Generate JSON schemas from Rust
mise gen:deno # Generate TypeScript client
mise gen:python # Generate Python client
mise gen:go # Generate Go client
```

### Linting and Type Checking
```bash
# Run all lints
mise lint

# Specific lints
mise lint:rust # cargo fmt --check && cargo clippy
mise lint:deno # deno lint && deno check
mise lint:go # golangci-lint run
mise lint:ast-grep # AST-based linting
```

### Running Examples
```bash
# Run Deno example
mise run example:deno basic

# Run Python example
mise run example:python basic

# Run Go example (binaries built in src/clients/go/build/)
mise run example:go simple
```

### Version Management
```bash
# Sync version numbers across all packages
mise sync-versions
```

## Architecture

### IPC Communication
- Client libraries communicate with the Rust binary via stdio (standard input/output)
- Messages are JSON-encoded and follow schemas defined in `schemas/`
- Schema-driven development ensures type safety across language boundaries

### Directory Structure
- `src/` - Rust source code
- `src/clients/deno/` - Deno/TypeScript client
- `src/clients/python/` - Python client
- `src/clients/go/` - Go client
- `schemas/` - JSON schemas for IPC messages
- `scripts/` - Build and generation scripts
- `sg/` - AST-grep linting rules

### Key Files
- `mise.toml` - Task runner configuration and tool versions
- `Cargo.toml` - Rust dependencies and build settings
- `src/clients/deno/deno.json` - Deno project configuration
- `src/clients/python/pyproject.toml` - Python project configuration
- `src/clients/go/go.mod` - Go module configuration

### Development Workflow
1. Rust structs define the message protocol
2. `mise gen:rust` generates JSON schemas from Rust code
3. `mise gen:deno`, `mise gen:python`, and `mise gen:go` generate typed clients from schemas
4. Clients automatically download platform binaries if needed
5. Communication happens via JSON messages over stdio
29 changes: 27 additions & 2 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ deno = "2.3.7"
rust = { version = "1.78.0", postinstall = "rustup component add rustfmt clippy rust-analyzer" }
ruff = "0.12.0"
uv = "0.6.2"
go = "1.23.4"
golangci-lint = "2.1.6"

[settings]
experimental = true
Expand Down Expand Up @@ -36,16 +38,23 @@ outputs = ["schemas/*.json"]
description = "Generate the deno client"
run = "deno run -A scripts/generate-schema/index.ts --language typescript"
depends = ["gen:rust"]
sources = ["schemas/*", "scripts/generate-schema.ts"]
sources = ["schemas/*", "scripts/generate-schema/**/*.ts"]
outputs = ["src/clients/deno/schemas/*.ts"]

[tasks."gen:python"]
description = "Generate the python client"
run = "deno run -A scripts/generate-schema/index.ts --language python"
depends = ["gen:rust"]
sources = ["schemas/*", "scripts/generate-schema.ts"]
sources = ["schemas/*", "scripts/generate-schema/**/*.ts"]
outputs = ["src/clients/python/src/justbe_webview/schemas/*.py"]

[tasks."gen:go"]
description = "Generate the go client"
run = "deno run -A scripts/generate-schema/index.ts --language go"
depends = ["gen:rust"]
sources = ["schemas/*", "scripts/generate-schema/**/*.ts"]
outputs = ["src/clients/go/webview/schemas.go"]

## Debug

[tasks."print-schema"]
Expand Down Expand Up @@ -93,6 +102,10 @@ depends = ["gen:deno", "build:rust"]
description = "Run code gen for python and ensure the binary is built"
depends = ["gen:python", "build:rust"]

[tasks."build:go"]
description = "Run code gen for go and ensure the binary is built"
depends = ["gen:go", "build:rust"]

[tasks.build]
description = "Build all targets"
depends = ["build:*"]
Expand All @@ -109,6 +122,11 @@ description = "Run deno lint"
dir = "src/clients/deno"
run = ["deno lint", "deno check ."]

[tasks."lint:go"]
description = "Run golangci-lint against go code"
dir = "src/clients/go"
run = "golangci-lint run ./webview/..."

[tasks."lint:ast-grep"]
description = "Run ast-grep lint"
run = """
Expand Down Expand Up @@ -138,3 +156,10 @@ depends = ["build:deno"]
env = { LOG_LEVEL = "debug", WEBVIEW_BIN = "../../../target/debug/webview" }
run = "deno run -E -R -N --allow-run examples/{{arg(name=\"example\")}}.ts"
dir = "src/clients/deno"

[tasks."example:go"]
description = "Run a go example"
depends = ["build:go"]
dir = "src/clients/go"
run = "mkdir -p build && go build -o build/{{arg(name=\"example\")}} examples/{{arg(name=\"example\")}}.go && ./build/{{arg(name=\"example\")}}"
env = { LOG_LEVEL = "debug", WEBVIEW_BIN = "../../../target/debug/webview" }
Loading