feat(docker): add dev.sh with auto-funding and ATM app setup

- Add dev.sh script for managing regtest development environment
- Implement cmd_fund to fund ATM app owner via Lightning.Pub API
- Add --fund flag to cmd_up for automatic funding on startup
- Update setup_atm_app to write VITE_APP_ID to machine .env
- Fix Electron IPC to pass appId and extensionApiUrl to renderer
- Restructure repo from nested lamassu-next/ to root

The dev.sh script now supports:
- ./dev.sh up --fund  # Start regtest and auto-fund ATM
- ./dev.sh fund       # Fund existing ATM app
- ./dev.sh status     # Show environment status
- ./dev.sh reset      # Clean restart

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-02-15 14:19:16 -05:00
commit c98f126ba7
180 changed files with 2695 additions and 9587 deletions

218
.claude/skills/docs.md Normal file
View file

@ -0,0 +1,218 @@
# /docs - Documentation Agent
## Purpose
Keep documentation synchronized with code, generate API docs, and maintain architecture diagrams.
## Invocation
```
/docs [command] [target]
```
Commands:
- `sync` - Sync docs with code changes
- `api` - Generate API documentation
- `diagram` - Update architecture diagrams
- `readme` - Update package README
- `changelog` - Generate changelog entry
## Documentation Structure
```
docs/
├── architecture/
│ ├── overview.md # High-level architecture
│ ├── nostr-protocol.md # Nostr integration details
│ ├── lightning-flow.md # Payment flows
│ └── hardware-hal.md # HAL documentation
├── api/
│ ├── nostr-client.md # @lamassu/nostr-client API
│ ├── clink.md # @lamassu/clink API
│ ├── state-machine.md # @lamassu/state-machine API
│ └── hal.md # @lamassu/hal API
├── guides/
│ ├── development.md # Dev setup guide
│ ├── hardware-testing.md # Testing with real hardware
│ └── deployment.md # NixOS deployment guide
└── adrs/ # Architecture Decision Records
├── 001-nostr-backbone.md
├── 002-clink-over-bolt12.md
└── ...
```
## Sync Tasks
### Code → Docs Sync
When code changes:
1. Detect modified files
2. Check if related docs exist
3. Flag outdated documentation
4. Suggest updates
### Doc → Code Validation
Ensure docs reference actual code:
- [ ] Function names match
- [ ] Parameter types correct
- [ ] Return types accurate
- [ ] Examples compile/run
## API Documentation
### TypeScript Packages
Generate from TSDoc comments:
```typescript
/**
* Create a CLINK offer for receiving payments
*
* @param identity - Machine identity (nsec/npub)
* @param relays - Relay URLs to include in offer
* @param priceType - 'fixed' | 'variable' | 'spontaneous'
* @param amount - Amount in sats (required for fixed)
* @returns Encoded noffer string
*
* @example
* ```typescript
* const offer = createOffer(identity, ['wss://relay.example'], 'fixed', 10000)
* // Returns: noffer1...
* ```
*/
export function createOffer(...): string
```
### Rust Crate (HAL)
Generate from rustdoc comments:
```rust
/// Connect to a bill validator
///
/// # Arguments
/// * `port` - Serial port path (e.g., "/dev/ttyUSB0")
///
/// # Errors
/// Returns `ValidatorError::ConnectionFailed` if port unavailable
///
/// # Example
/// ```
/// let mut validator = Id003Validator::new("/dev/ttyUSB0", "USD");
/// validator.connect().await?;
/// ```
pub async fn connect(&mut self) -> Result<(), ValidatorError>
```
## Diagram Updates
### Mermaid Diagrams
Keep architecture diagrams current:
```mermaid
sequenceDiagram
participant U as User
participant A as ATM
participant R as Relay
participant L as Lightning.Pub
U->>A: Insert $20 bill
A->>A: Validate bill
A->>R: Publish CLINK offer
U->>R: Send payment request
R->>A: Forward request
A->>L: Generate invoice
L->>A: Return invoice
A->>R: Send invoice to user
U->>L: Pay invoice
L->>A: Payment confirmed
A->>U: Display success
```
### Auto-update triggers
- New event kinds added → Update protocol diagram
- State machine changes → Update flow diagram
- New hardware driver → Update HAL diagram
## Changelog Generation
### Format (Keep a Changelog)
```markdown
## [Unreleased]
### Added
- CLINK offer support for cash-in flow
- Puloon dispenser driver
### Changed
- Upgraded to XState v5 actor model
### Fixed
- Race condition in bill acceptance
### Security
- Added NIP-44 encryption for receipts
```
### Auto-detection
From git commits since last release:
- `feat:` → Added
- `fix:` → Fixed
- `refactor:` → Changed
- `security:` → Security
- `BREAKING:` → Breaking Changes
## Output Format
### Sync Report
```markdown
## Documentation Sync: [target]
### Outdated Docs
| Doc | Code Change | Status |
|-----|-------------|--------|
| api/clink.md | createOffer params | ⚠️ Outdated |
| guides/development.md | New env var | ⚠️ Missing |
### Suggested Updates
1. `api/clink.md:45` - Add `timeout` parameter to createOffer
2. `guides/development.md` - Add LIGHTNING_PUB_URL env var
### Missing Documentation
- `packages/cashu/src/wallet.ts` - No API docs
```
### Generated Docs
```markdown
## Generated: [file]
### API Reference
#### `createOffer(identity, relays, priceType, amount?)`
Creates a CLINK offer for receiving Lightning payments.
**Parameters:**
| Name | Type | Description |
|------|------|-------------|
| identity | MachineIdentity | Machine nsec/npub |
| relays | string[] | Relay URLs |
| priceType | 'fixed' \| 'variable' | Pricing model |
| amount | number? | Amount in sats |
**Returns:** `string` - Encoded noffer
**Example:**
```typescript
const offer = createOffer(identity, ['wss://relay'], 'fixed', 10000)
```
```
## Example Usage
```
/docs sync packages/clink/
```
```
/docs api packages/nostr-client/src/
```
```
/docs changelog --since v0.1.0
```