packages feed

synapse-cc-0.1.0.0: README.md

# synapse-cc

**Unified compiler toolchain for Plexus backends**

`synapse-cc` (synapse compiler collection) orchestrates the complete pipeline from backend schema discovery to compiled, ready-to-use client libraries.

## Features

- πŸ”§ **Unified Interface**: Single command to generate clients from any backend
- πŸ” **Smart Tool Discovery**: Finds local development builds or installed versions
- ⚑ **Fast**: Smart caching avoids regeneration when schemas haven't changed (coming in Phase 3)
- 🎯 **Multi-Language**: TypeScript, Python, Rust support (TypeScript in MVP)
- πŸ› οΈ **Complete Pipeline**: From schema β†’ IR β†’ generated code β†’ compiled artifacts

## Installation

### From Source

```bash
cd synapse-cc
cabal build
cabal install
```

### Dependencies

`synapse-cc` requires these tools to be available:
- **synapse** - Schema discovery and IR generation
- **hub-codegen** - Code generation from IR

The tool will automatically find them if they're:
- In your `$PATH`
- In local development directories (`../synapse`, `../hub-codegen`)
- In `~/.plexus/bin/`

## Usage

### Basic TypeScript Client

```bash
synapse-cc typescript substrate ws://localhost:4444
```

This will:
1. Connect to substrate at `ws://localhost:4444`
2. Discover the schema
3. Generate IR
4. Generate TypeScript client
5. Output to `./generated/`

### Options

```bash
synapse-cc <target> <backend> <url> [OPTIONS]

Arguments:
  target    Target language (typescript, python, rust)
  backend   Backend identifier (substrate, plexus, synapse, etc.)
  url       Backend WebSocket URL (e.g., ws://localhost:4444)

Options:
  -o, --output DIR           Output directory (default: ./generated)
  --bundle-transport BOOL    Bundle transport code (default: true)
  --no-install              Skip dependency installation
  --no-build                Skip compilation step
  --cache-dir DIR           Cache directory (default: ~/.plexus/cache)
  --force                   Force regeneration (ignore cache)
  --watch                   Watch backend and regenerate on changes
  --debug                   Enable debug logging
  -h, --help                Show help message
```

### Examples

**External transport mode** (uses `@plexus/rpc-client` package):
```bash
synapse-cc typescript substrate ws://localhost:4444 \
  --bundle-transport=false \
  --output ./packages/substrate-client
```

**Skip build steps** (just generate code):
```bash
synapse-cc typescript substrate ws://localhost:4444 \
  --no-install \
  --no-build
```

**Debug mode**:
```bash
synapse-cc typescript substrate ws://localhost:4444 --debug
```

## Architecture

```
synapse-cc (Haskell)
    ↓
    β”œβ”€β†’ synapse (Haskell) β†’ IR (JSON)
    ↓
    β”œβ”€β†’ hub-codegen (Rust) β†’ Generated Code
    ↓
    └─→ Language Tools (npm, tsc, etc.) β†’ Compiled Artifact
```

## Development

### Project Structure

```
synapse-cc/
β”œβ”€β”€ synapse-cc.cabal         # Cabal project file
β”œβ”€β”€ PLAN.md                  # Detailed implementation plan
β”œβ”€β”€ app/
β”‚   └── Main.hs              # Entry point
└── src/
    └── SynapseCC/
        β”œβ”€β”€ Types.hs         # Core types
        β”œβ”€β”€ CLI.hs           # Command-line parsing
        β”œβ”€β”€ Discover.hs      # Tool discovery
        β”œβ”€β”€ Pipeline.hs      # Pipeline orchestration
        β”œβ”€β”€ Process.hs       # Subprocess helpers
        β”œβ”€β”€ Cache.hs         # Caching (Phase 3)
        β”œβ”€β”€ Language.hs      # Language integration (Phase 2)
        └── Logging.hs       # Pretty output
```

### Building

```bash
cabal build
```

### Running from source

```bash
cabal run synapse-cc -- typescript substrate ws://localhost:4444
```

### Testing

```bash
# Ensure substrate is running
cd ../plexus-substrate
cargo run -- --port 4444

# In another terminal, test synapse-cc
cd ../synapse-cc
cabal run synapse-cc -- typescript substrate ws://localhost:4444 --debug
```

## Roadmap

### Phase 1: MVP (Current)
- βœ… Project scaffolding
- βœ… Tool discovery
- βœ… Pipeline orchestration
- βœ… Basic error handling
- [ ] End-to-end testing

### Phase 2: Language Integration
- [ ] Dependency installation (npm, pip, cargo)
- [ ] Build automation
- [ ] Multi-package manager support

### Phase 3: Smart Caching
- [ ] Hash-based caching
- [ ] Cache management
- [ ] Fast iteration

### Phase 4: Production Features
- [ ] Watch mode
- [ ] Progress indicators
- [ ] Auto-install tools
- [ ] Configuration files

## Contributing

See [PLAN.md](./PLAN.md) for detailed implementation plan and design decisions.

## License

MIT