Skip to content

Latest commit

 

History

History
409 lines (315 loc) · 13.2 KB

CONTRIBUTING.md

File metadata and controls

409 lines (315 loc) · 13.2 KB

contributing to screen pipe

first off, thank you for considering contributing to screen pipe! it's people like you that make screen pipe such a great tool. we're looking for developers who want to create paid pipes, with the potential to easily make $1000/m. let's schedule a call to get you onboarded.

getting started

before you begin:

  • try to run the pre-built app to get familiar with the project
  • familiarize yourself with the project structure and architecture.

installation and build guide

macos

  1. install dependencies:

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    brew install pkg-config ffmpeg jq cmake wget
  2. install bun cli:

    curl -fsSL https://bun.sh/install | bash
  3. clone the repository:

    git clone https://github.com/mediar-ai/screenpipe
    cd screenpipe
  4. build the project:

    cargo build --release --features metal
  5. run screenpipe:

    ./target/release/screenpipe
  6. build the desktop app:

    cd screenpipe-app-tauri
    bun install
    bun scripts/pre_build.js
    bun tauri build

windows

  1. install required tools:

    winget install -e --id Microsoft.VisualStudio.2022.BuildTools
    winget install -e --id Rustlang.Rustup
    winget install -e --id LLVM.LLVM
    winget install -e --id Kitware.CMake
    winget install -e --id GnuWin32.UnZip
    winget install -e --id Git.Git
    irm https://bun.sh/install.ps1 | iex
  2. clone and setup vcpkg:

    cd C:\dev
    $env:DEV_DIR = $(pwd)
    git clone https://github.com/microsoft/vcpkg.git
    cd vcpkg
    ./bootstrap-vcpkg.bat -disableMetrics
    ./vcpkg.exe integrate install --disable-metrics
    ./vcpkg.exe install ffmpeg:x64-windows
  3. set environment variables:

    [System.Environment]::SetEnvironmentVariable('PKG_CONFIG_PATH', "$env:DEV_DIR\vcpkg\packages\ffmpeg_x64-windows\lib\pkgconfig", 'User')
    [System.Environment]::SetEnvironmentVariable('VCPKG_ROOT', "$env:DEV_DIR\vcpkg", 'User')
    [System.Environment]::SetEnvironmentVariable('LIBCLANG_PATH', 'C:\Program Files\LLVM\bin', 'User')
    [System.Environment]::SetEnvironmentVariable('PATH', "$([System.Environment]::GetEnvironmentVariable('PATH', 'User'));C:\Program Files (x86)\GnuWin32\bin", 'User')
  4. clone and build:

    git clone https://github.com/mediar-ai/screenpipe
    cd screenpipe
    cargo build --release
    cd screenpipe-app-tauri
    bun install
    bun scripts/pre_build.js
    bun tauri build

linux

  1. install dependencies:

    sudo apt-get install -y g++ ffmpeg tesseract-ocr cmake libavformat-dev libavfilter-dev libavdevice-dev libssl-dev libtesseract-dev libxdo-dev libsdl2-dev libclang-dev libxtst-dev
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  2. install bun cli:

    curl -fsSL https://bun.sh/install | bash
  3. clone and build:

    git clone https://github.com/mediar-ai/screenpipe
    cd screenpipe
    cargo build --release
  4. run the application:

    ./target/release/screenpipe
  5. build the desktop app:

    cd screenpipe-app-tauri
    bun install
    bun scripts/pre_build.js
    bun tauri build

how can i contribute?

reporting bugs

this section guides you through submitting a bug report for screen pipe. following these guidelines helps maintainers and the community understand your report, reproduce the behavior, and find related reports.

  • use a clear and descriptive title for the issue to identify the problem.
  • describe the exact steps which reproduce the problem in as many details as possible.
  • provide specific examples to demonstrate the steps.

suggesting enhancements

this section guides you through submitting an enhancement suggestion for screen pipe, including completely new features and minor improvements to existing functionality.

  • use a clear and descriptive title for the issue to identify the suggestion.
  • provide a step-by-step description of the suggested enhancement in as many details as possible.
  • explain why this enhancement would be useful to most screen pipe users.

pull requests

  • fill in the required template
  • do not include issue numbers in the pr title
  • include screenshots and animated gifs in your pull request whenever possible.
  • follow the rust styleguides.
  • end all files with a newline.

styleguides

git commit messages

  • use the present tense ("add feature" not "added feature")
  • use the imperative mood ("move cursor to..." not "moves cursor to...")
  • limit the first line to 72 characters or less
  • reference issues and pull requests liberally after the first line

rust styleguide

all rust code must adhere to rust style guide.

we follow this folder structure.

additional notes

try to keep files small (under 600 lines of code)

AI is quite bad when files are big, we should try to keep small so we move faster (also it's nice for humans too 🤓)

ai system prompt

i use cursor with this prompt to help me with the code:

Rules:
- Coding: louis is working on screenpipe most of the time, it's an open source app, lib, and CLI, that record screens & mics 24/7, extract OCR & STT, save to local db, connect to AI, do magic, it's written in Rust + Tauri and we write plugins (pipes) in TS + Bun. the Rust CLI is embedded as a sidecar in Tauri. it works on macos, windows, linux
- Coding: always keep my style black and white, with some nerdy style and fonts pixelated / scientific style
- Coding: do not remove @ts-ignore except if i explicitly ask you
- Coding: always use lower case for logging stuff or UI
- Coding: Rust: always use anyhow error, tokio instead of std stuff, avoid mutex if you can, prefer channels, write code easy to read for humans, fast for machines
- Coding: when i ask to give me the full code it means FULL, no fucking // rest of the code comments GIVE ME THE FULL CODE
- Coding: if it seems like you lack some context about a niche lib just ask me to provide the source code and i will (instead of providing a bad answer)
- Coding: NextJS: make sure to use tailwind, typescript, shadcn, lucide, magicui, and framer-motion to make UIs amazing
- Coding: Make sure to escape html thing like quotes etc properly. Only when necessary
- Coding: When writing react or html code make sure to use thing like ' instead of ". Only when necessary (e.g inside quote themselves)

principles

  • user fanatic: focus on building what people want and bring maximum value.
  • concurrency: channels > mutexes/locks
  • simplicity: avoid premature optimization. write code that is easy for humans to read, fast for machines to execute. less is more. optimise for less code, less files, less dependencies, less complexity.
  • production: we're building real products, not python toy that grow to 150k stars and die prematurely and never leave localhost, thank you.
  • focus: avoid feature creep. focus on the core functionality and build upon it. focus on the user and their needs.
  • use numbers: if you can't measure it, you can't improve it.
  • avoid oop: prefer functional programming.
  • positive-sum: we're all going to win, it is a multiplayer, positive sum game. (that escalated quickly)

issue and pull request labels

this section lists the labels we use to help us track and manage issues and pull requests.

  • bug - issues that are bugs.
  • enhancement - issues that are feature requests.
  • documentation - issues or pull requests related to documentation.
  • good first issue - good for newcomers.

building

cargo build --release --features metal # or cuda, depending on your computer's NPU

running tests

before submitting a pull request, run all the tests to ensure nothing has broken:

cargo test
# on macos you need to set DYLD_LIBRARY_PATH for apple native OCR tests to run
DYLD_LIBRARY_PATH=$(pwd)/screenpipe-vision/lib cargo test

you can add env var to .vscode/settings.json:

{
    "terminal.integrated.env.osx": {
        "DYLD_LIBRARY_PATH": "$(pwd)/screenpipe-vision/lib"
    }
}

this is @louis030195 whole .vscode/settings.json file:

{
    "rust-analyzer.server.extraEnv": {
        "PKG_CONFIG_ALLOW_SYSTEM_LIBS": "1",
        "PKG_CONFIG_ALLOW_SYSTEM_CFLAGS": "1",
        "PKG_CONFIG_PATH": "/opt/homebrew/lib/pkgconfig:/opt/homebrew/share/pkgconfig",
        "PATH": "/usr/bin:/opt/homebrew/bin:${env:PATH}",
        "DYLD_LIBRARY_PATH": "${workspaceFolder}/screenpipe-vision/lib:${env:DYLD_LIBRARY_PATH}"
    },
    "rust-analyzer.cargo.extraEnv": {
        "PKG_CONFIG_ALLOW_SYSTEM_LIBS": "1",
        "PKG_CONFIG_ALLOW_SYSTEM_CFLAGS": "1",
        "PKG_CONFIG_PATH": "/opt/homebrew/lib/pkgconfig:/opt/homebrew/share/pkgconfig",
        "PATH": "/usr/bin:/opt/homebrew/bin:${env:PATH}",
        "DYLD_LIBRARY_PATH": "${workspaceFolder}/screenpipe-vision/lib:${env:DYLD_LIBRARY_PATH}"
    },
    // add env to integrated terminal
    "terminal.integrated.env.osx": {
        "DYLD_LIBRARY_PATH": "${workspaceFolder}/screenpipe-vision/lib:${env:DYLD_LIBRARY_PATH}",
        "SCREENPIPE_APP_DEV": "true",
    },
    "rust-analyzer.cargo.features": [
        "pipes"
    ],
    "rust-analyzer.cargo.runBuildScripts": true,
    "rust-analyzer.checkOnSave.command": "clippy",
    "rust-analyzer.checkOnSave.extraArgs": [
        "--features",
        "pipes"
    ],
    "rust-analyzer.cargo.allFeatures": false,
    "rust-analyzer.cargo.noDefaultFeatures": false
}

other hacks

running dev + prod in the same time

one command i keep using to avoid having to kill my main "production" process is:

./target/release/screenpipe --port 3035 --data-dir /tmp/sp

it will avoid conflicts with the port and avoid conflicts with the data dir

especially useful if you've done new database migrations and want to avoid breaking your previous months of data :)

on macos the /tmp dir keeps being cleaned up by the system fyi

debugging github action

ssh into the runner:

- name: Setup tmate session # HACK
  if: matrix.platform == 'windows-latest'
  uses: mxschmitt/action-tmate@v3

run locally: https://github.com/nektos/act

debugging memory errors

RUSTFLAGS="-Z sanitizer=address" cargo run --bin screenpipe
# or
RUSTFLAGS="-Z sanitizer=leak" cargo run --bin screenpipe

for performance monitoring, you can use the following command:

cargo install cargo-instruments
# tracking leaks over 60 minutes time limit
cargo instruments -t Leaks --bin screenpipe --features metal --time-limit 600000 --open

then open the file in target/release/instruments using xcode -> open developer tool -> instruments.

benchmarks

cargo bench

check benchmark visuals

creating new migrations

cargo install sqlx-cli
sqlx migrate add <migration_name>

set up azure ubuntu vm with display & audio

# Set variables
RG_NAME="my-avd-rgg"
LOCATION="westus2" 
VM_NAME="ubuntu-avd"
IMAGE="Canonical:0001-com-ubuntu-server-jammy:22_04-lts-gen2:latest"
VM_SIZE="Standard_D2s_v3"  

# Create resource group
az group create --name $RG_NAME --location $LOCATION

# Create VM
az vm create \
  --resource-group $RG_NAME \
  --name $VM_NAME \
  --image $IMAGE \
  --admin-username azureuser \
  --generate-ssh-keys \
  --size $VM_SIZE

# Enable RDP
az vm open-port --port 3389 --resource-group $RG_NAME --name $VM_NAME

# Install xrdp, audio, and desktop environment
az vm run-command invoke \
  --resource-group $RG_NAME \
  --name $VM_NAME \
  --command-id RunShellScript \
  --scripts "
    sudo apt update && sudo apt install -y xrdp ubuntu-desktop pulseaudio
    sudo systemctl enable xrdp
    sudo adduser xrdp ssl-cert
    echo 'startxfce4' | sudo tee /etc/xrdp/startwm.sh
    sudo systemctl restart xrdp
    sudo ufw allow 3389/tcp
  "

# Enable audio redirection
az vm run-command invoke \
  --resource-group $RG_NAME \
  --name $VM_NAME \
  --command-id RunShellScript \
  --scripts "
    echo 'load-module module-native-protocol-tcp auth-anonymous=1' | sudo tee -a /etc/pulse/default.pa
    sudo systemctl restart pulseaudio
  "

# Get IP address
IP=$(az vm list-ip-addresses --resource-group $RG_NAME --name $VM_NAME --output table | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | head -1)

# Now you can open Microsoft Remote Desktop and use the IP in new PC to connect to it

# RDP into the VM
ssh azureuser@$IP

# Forwarding port to local 
ssh -L 13389:localhost:3389 azureuser@$IP

# Changing password
az vm user update \
  --resource-group $RG_NAME \
  --name $VM_NAME \
  --username azureuser \
  --password <new-password>

now you can either dev screenpipe on linux or run screenpipe in the cloud that record your local macos. make sure to configure microsoft remote desktop to forward audio

join the community

say 👋 in our public discord channel. we discuss how to bring this lib to production, help each other with contributions, personal projects or just hang out ☕.

thank you for contributing to screen pipe! 🎉