Skip to content
Merged
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
Binary file added .DS_Store
Binary file not shown.
21 changes: 19 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master

- name: Install Rust toolchain
uses: dtolnay/[email protected]
with:
toolchain: 1.90.0
components: rustfmt, clippy

- name: Cache cargo
uses: actions/cache@v4
with:
Expand All @@ -37,3 +39,18 @@ jobs:

- name: Run check
run: just check

- name: Install ISO tooling
run: |
sudo apt-get update
sudo apt-get install -y xorriso

- name: Build installer ISO
run: ./scripts/make_iso.sh

- name: Upload installer ISO artifact
uses: actions/upload-artifact@v4
with:
name: tiles-installer-iso
path: dist/*.iso
if-no-files-found: error
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
.tiles_dev
dist/
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Modelfile-based SDK that lets developers to lets developers customize local mode
- Go to root and run `just serve` in another terminal to run the server
- Run the rust cli using cargo as usual

### Packaging installers

- `just bundle` creates a tarball that includes the CLI binary and Python server.
- `just iso` wraps the bundle and installer script into an ISO that can be flashed with tools like Balena Etcher.

## License

This project is dual-licensed under MIT and Apache 2.0 terms:
Expand Down
55 changes: 55 additions & 0 deletions ascii-art.txt

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ bundle:

install:
./scripts/install.sh

iso:
./scripts/make_iso.sh
1 change: 0 additions & 1 deletion memgpt.modelfile

This file was deleted.

1 change: 1 addition & 0 deletions registry/memgpt/Modelfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM driaforall/mem-agent-mlx-4bit
6 changes: 3 additions & 3 deletions scripts/bundler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
OUT_NAME="${BINARY_NAME}-v${VERSION}-${ARCH}-${OS}"

echo "🚀 Building ${BINARY_NAME} (${TARGET} mode)..."
echo "Building ${BINARY_NAME} (${TARGET} mode)..."
cargo build --${TARGET}

mkdir -p "${DIST_DIR}/tmp"
Expand All @@ -21,9 +21,9 @@ cp -r "${SERVER_DIR}" "${DIST_DIR}/tmp/"
rm -rf "${DIST_DIR}/tmp/server/__pycache__"
rm -rf "${DIST_DIR}/tmp/server/.venv"

echo "📦 Creating ${OUT_NAME}.tar.gz..."
echo "Creating ${OUT_NAME}.tar.gz..."
tar -czf "${DIST_DIR}/${OUT_NAME}.tar.gz" -C "${DIST_DIR}/tmp" .

rm -rf "${DIST_DIR}/tmp"

echo "Bundle created: ${DIST_DIR}/${OUT_NAME}.tar.gz"
echo "Bundle created: ${DIST_DIR}/${OUT_NAME}.tar.gz"
244 changes: 213 additions & 31 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,70 +1,252 @@
#!/usr/bin/env bash
set -euo pipefail

ENV="prod" # prod is another env, try taking it from github env
REPO="tilesprivacy/tilekit"
# VERSION="${TILES_VERSION:-latest}"
VERSION="0.1.0"
INSTALL_DIR="$HOME/.local/bin" # CLI install location
SERVER_DIR="$HOME/.local/share/tiles/server" # Python server folder
# ============================================================================
# Tiles Installer
# ============================================================================

# Terminal setup
TERM_WIDTH=${COLUMNS:-80}
if command -v tput >/dev/null 2>&1; then
TERM_WIDTH=$(tput cols 2>/dev/null || echo 80)
fi
[[ $TERM_WIDTH -lt 60 ]] && TERM_WIDTH=80

# Display ASCII art if available
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ASCII_ART_FILE="${SCRIPT_DIR}/../ascii-art.txt"
if [[ ! -f "${ASCII_ART_FILE}" ]]; then
VOLUME_ROOT="$(dirname "${SCRIPT_DIR}")"
ASCII_ART_FILE="${VOLUME_ROOT}/ascii-art.txt"
fi
if [[ -f "${ASCII_ART_FILE}" ]]; then
cat "${ASCII_ART_FILE}"
echo ""
fi

# Configuration
ENV="${TILES_INSTALL_ENV:-prod}"
REPO="tilesprivacy/tilekit"
VERSION="0.1.0"
INSTALL_DIR="$HOME/.local/bin"
SERVER_DIR="$HOME/.local/share/tiles/server"
TMPDIR="$(mktemp -d)"
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)

# ============================================================================
# UI Functions
# ============================================================================

# Print functions with color support
print_header() {
echo ""
echo -e "\033[1;36m================================================================================\033[0m"
echo -e "\033[1;37m$*\033[0m"
echo -e "\033[1;36m================================================================================\033[0m"
echo ""
}

print_step() {
echo -e "\033[1;36m>\033[0m $*"
}

print_success() {
echo -e "\033[1;32m[OK]\033[0m $*"
}

print_warning() {
echo -e "\033[1;33m[!]\033[0m $*"
}

print_error() {
echo -e "\033[1;31m[ERROR]\033[0m $*" >&2
}

print_info() {
echo -e "\033[0;90m $*\033[0m"
}

log() { echo -e "\033[1;36m$*\033[0m"; }
err() { echo -e "\033[1;31m$*\033[0m" >&2; exit 1; }
wrap_text() {
local text="$1"
local prefix="${2:- }"
local width=$((TERM_WIDTH - ${#prefix}))
echo "$text" | fold -s -w "$width" | sed "s/^/$prefix/"
}

echo "🔍 Checking Python..."
if ! command -v python3 >/dev/null 2>&1; then
log "⚠️ Python 3.10+ not found."
print_section() {
echo ""
echo -e "\033[1;37m[ $* ]\033[0m"
}

print_section_end() {
echo -e "\033[1;37m------------------------------------------------------------\033[0m"
echo ""
}

log() {
echo -e "\033[1;36m$*\033[0m"
}

err() {
print_error "$*"
echo ""
exit 1
}

# ============================================================================
# Main Installation
# ============================================================================

print_header "Tiles Installer v${VERSION}"

wrap_text "This installer will set up Tiles on your system, including the CLI tool and Python server environment." " "
echo ""

# ----------------------------------------------------------------------------
# Check Dependencies
# ----------------------------------------------------------------------------

print_section "Checking Dependencies"

print_step "Checking Python installation..."
if command -v python3 >/dev/null 2>&1; then
PY_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
print_success "Python ${PY_VERSION} found"
else
print_warning "Python 3.10+ not found"

if [[ "$OS" == "darwin" ]]; then
log "Installing via Homebrew..."
brew install python || err "Could not install Python automatically. Please install manually."
print_info "Installing Python via Homebrew..."
brew install python || err "Could not install Python. Please install manually from https://www.python.org"
elif [[ -f /etc/debian_version ]]; then
log "Installing via apt..."
print_info "Installing Python via apt..."
sudo apt-get update -y && sudo apt-get install -y python3 python3-venv
else
err "Please install Python manually: https://www.python.org/downloads/"
fi

print_success "Python installed"
fi

echo "🔍 Checking uv..."
if ! command -v uv >/dev/null 2>&1; then
log "⬇️ Installing uv..."
print_step "Checking uv package manager..."
if command -v uv >/dev/null 2>&1; then
UV_VERSION=$(uv --version 2>&1 | awk '{print $2}')
print_success "uv ${UV_VERSION} found"
else
print_info "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
print_success "uv installed"
fi

log "⬇️ Downloading Tiles (${VERSION}) for ${ARCH}-${OS}..."
print_section_end

# ----------------------------------------------------------------------------
# Download/Locate Tiles
# ----------------------------------------------------------------------------

if [[ "$ENV" == "prod" ]]; then
print_section "Gathering Tiles Bundle"

print_step "Looking for Tiles v${VERSION} (${ARCH}-${OS})..."

LOCAL_BUNDLE="${SCRIPT_DIR}/tiles-v${VERSION}-${ARCH}-${OS}.tar.gz"
ROOT_BUNDLE="${SCRIPT_DIR}/../dist/tiles-v${VERSION}-${ARCH}-${OS}.tar.gz"

if [[ -f "${LOCAL_BUNDLE}" ]]; then
print_info "Found local bundle"
cp "${LOCAL_BUNDLE}" "${TMPDIR}/tiles.tar.gz"
print_success "Bundle located"
elif [[ -f "${ROOT_BUNDLE}" ]]; then
print_info "Found bundle in repository"
cp "${ROOT_BUNDLE}" "${TMPDIR}/tiles.tar.gz"
print_success "Bundle located"
elif [[ "${ENV}" == "prod" ]]; then
print_info "Downloading from GitHub releases..."
TAR_URL="https://github.com/${REPO}/releases/download/${VERSION}/tiles-v${VERSION}-${ARCH}-${OS}.tar.gz"
curl -fsSL -o "${TMPDIR}/tiles.tar.gz" "$TAR_URL"

if curl -fsSL -o "${TMPDIR}/tiles.tar.gz" "$TAR_URL"; then
print_success "Bundle downloaded"
else
err "Failed to download bundle from ${TAR_URL}"
fi
else
# Installer suppose to ran from tilekit root folder after running the bundler
mv "dist/tiles-v${VERSION}-${ARCH}-${OS}.tar.gz" "${TMPDIR}/tiles.tar.gz"
err "Could not locate bundle tiles-v${VERSION}-${ARCH}-${OS}.tar.gz"
fi

echo "⬇️ Installing tiles..."
# Lets point to tile repo
print_step "Extracting bundle..."
tar -xzf "${TMPDIR}/tiles.tar.gz" -C "${TMPDIR}"
print_success "Bundle extracted"

print_section_end

log "📦 Installing tiles binary to ${INSTALL_DIR}..."
# ----------------------------------------------------------------------------
# Install Tiles
# ----------------------------------------------------------------------------

print_section "Installing Components"

print_step "Installing CLI binary..."
print_info "Location: ${INSTALL_DIR}/tiles"
mkdir -p "${INSTALL_DIR}"
install -m 755 "${TMPDIR}/tiles" "${INSTALL_DIR}/tiles"
print_success "CLI binary installed"

log "📦 Installing Python server to ${SERVER_DIR}..."
print_step "Installing Python server..."
print_info "Location: ${SERVER_DIR}"
mkdir -p "${SERVER_DIR}"
cp -r "${TMPDIR}/server"/* "${SERVER_DIR}/"
print_success "Server files installed"

log "🔧 Setting up Python environment..."
print_step "Setting up Python environment..."
print_info "Installing dependencies with uv..."
cd "${SERVER_DIR}"
uv sync --frozen || err "Dependency setup failed."
if uv sync --frozen; then
print_success "Python environment ready"
else
err "Failed to set up Python environment"
fi

print_section_end

# Cleanup
rm -rf "${TMPDIR}"

log "✅ Tiles installed successfully!"
log ""
log "👉 Make sure ${INSTALL_DIR} is in your PATH."
# ============================================================================
# Installation Complete
# ============================================================================

print_header "Installation Complete"

print_success "Tiles v${VERSION} installed successfully!"
echo ""

wrap_text "The Tiles CLI has been installed to ${INSTALL_DIR}. Make sure this directory is in your PATH to use the 'tiles' command." " "
echo ""

# Display PATH setup instructions if needed
if [[ ":$PATH:" != *":${INSTALL_DIR}:"* ]]; then
print_warning "Setup Required"
echo ""
wrap_text "Add the following line to your shell configuration file (~/.bashrc, ~/.zshrc, or ~/.profile):" " "
echo ""
echo -e "\033[1;37m export PATH=\"\$HOME/.local/bin:\$PATH\"\033[0m"
echo ""
wrap_text "Then reload your shell or run: source ~/.zshrc" " "
echo ""
fi

# Display help
print_section "Getting Started"

export PATH="${INSTALL_DIR}:${PATH}"
if command -v tiles >/dev/null 2>&1; then
tiles --help 2>/dev/null || "${INSTALL_DIR}/tiles" --help 2>/dev/null || true
else
"${INSTALL_DIR}/tiles" --help 2>/dev/null || true
fi

print_section_end

wrap_text "For more information, visit the documentation or run 'tiles --help' at any time." " "
echo ""
Loading