Skip to content

Instantly share code, notes, and snippets.

View schickling's full-sized avatar
Making the web better

Johannes Schickling schickling

Making the web better
View GitHub Profile
@schickling
schickling / ai-agent.ts
Created July 25, 2025 10:09
AI Agent Client-DO Example for LiveStore on Cloudflare
/**
* AI Agent Client-DO Example
*
* This example demonstrates how a client-do can be used to create a lightweight AI agent
* that maintains conversation state, handles user interactions, and manages AI responses.
* The DO acts as a stateful agent instance that persists conversation history and context.
*
* Architecture Overview:
* ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
* │ Web Client │ │ Mobile App │ │ API Client │
@schickling
schickling / update-deps.ts
Created July 25, 2025 09:29
TypeScript script for intelligent dependency management in monorepos with Expo constraints
#!/usr/bin/env bun
import { Effect, Logger, LogLevel } from '@livestore/utils/effect'
import { Cli, PlatformNode } from '@livestore/utils/node'
import { cmd, cmdText } from '@livestore/utils-dev/node'
import { Schema } from '@livestore/utils/effect'
// Types for our dependency update workflow
const PackageUpdate = Schema.Struct({
name: Schema.String,
@schickling
schickling / dependency-management.md
Created July 25, 2025 08:16
LiveStore Dependency Management Guide - Comprehensive guide for updating NPM dependencies in the LiveStore monorepo using pnpm with Expo constraints and syncpack validation

Dependency Management Guide

This document outlines the process for updating NPM dependencies in the LiveStore project. We use pnpm update as our primary tool with syncpack for validation. Update all dependencies across the entire monorepo.

Quick Start

# 0. Update PNPM itself first
pnpm --version  # Check current version
pnpm view pnpm version  # Check latest version
@schickling
schickling / otel-investigation.md
Last active July 23, 2025 07:00
Investigation: OpenTelemetry Node.js HostDetector import issue in Cloudflare Workers

OpenTelemetry Node.js HostDetector Import Issue in Cloudflare Context

Problem

The Node.js-specific HostDetector from @opentelemetry/resources is being imported in a Cloudflare Workers test environment, causing compatibility issues.

Error Location: /Users/schickling/Code/livestore/cloudflare-adapter/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/HostDetector.js

Test File: /Users/schickling/Code/livestore/cloudflare-adapter/tests/integration-cloudflare/src/hibernation.test.ts

Root Cause Analysis

@schickling
schickling / .envrc
Created July 7, 2025 09:33
Expo/React Native CI Testing: Nix + Maestro Best Practices - Complete setup for automated iOS testing with intelligent detection, performance optimization, and reproducible environments. Saves 8+ seconds per test run with 28% performance improvement.
use flake
# Fix SDK conflicts between Nix and Xcode
unset SDKROOT NIX_APPLE_SDK_VERSION NIX_LDFLAGS NIX_CFLAGS_COMPILE 2>/dev/null || true
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
tags level
best-practices
typescript
boolean
warn

Enforce Explicit Value Comparisons

Detects shorthand value usage patterns (implicit truthiness/falsiness checking) in JavaScript/TypeScript code. This rule helps identify places where explicit comparisons might be preferred for clarity and type safety. Common cases include checking for undefined/null, empty strings, zero values, and boolean states.

import { spawn } from 'node:child_process'
import process from 'node:process'
const run = (cmd: string, args: string[], forwardStdin = true) =>
spawn(cmd, args, {
shell: true,
stdio: [forwardStdin ? 'inherit' : 'ignore', 'inherit', 'inherit'],
})
const processes = [
@schickling
schickling / ChildProcessRunner.ts
Created December 18, 2024 14:45
Effect Node Child Process Worker
/* eslint-disable prefer-arrow/prefer-arrow-functions */
import process from 'node:process'
import { WorkerError } from '@effect/platform/WorkerError'
import * as Runner from '@effect/platform/WorkerRunner'
import * as Context from 'effect/Context'
import * as Deferred from 'effect/Deferred'
import * as Effect from 'effect/Effect'
import * as Exit from 'effect/Exit'
import * as FiberId from 'effect/FiberId'
@schickling
schickling / fix-lock-file.yml
Created November 9, 2024 16:34
GitHub action fix pnpm lock file
name: Fix Lock File and Create PR
on:
push:
branches:
- '**' # Run on every branch push
permissions:
contents: write
pull-requests: write
{ lib, stdenv, fetchurl, unzip }:
let
# https://docs.dagger.io/install
version = "0.12.5"; # Replace with the actual version you want to install
system = stdenv.hostPlatform.system;
# Map Nix system to Dagger's OS and architecture naming
systemMap = {
"x86_64-linux" = { os = "linux_amd64"; sha256 = ""; };