From d89875d59ffb57c6c508f26c7774edf69d5a4a93 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:21:11 +0000 Subject: [PATCH 1/6] Initial plan From 4f075bec7ffc4a1f1ca39ff367bcd1afdfa46d0a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:26:53 +0000 Subject: [PATCH 2/6] Add first-install detection and dependency installation to install script Co-authored-by: streed <805140+streed@users.noreply.github.com> --- install.sh | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 188 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 1fb62ea..c9f9407 100755 --- a/install.sh +++ b/install.sh @@ -16,6 +16,7 @@ NC='\033[0m' # No Color REPO="streed/ml-notes" INSTALL_DIR="/usr/local/bin" BINARY_NAME="ml-notes" +LILRAG_REPO="streed/lil-rag" # Functions print_error() { @@ -72,7 +73,7 @@ detect_platform() { check_requirements() { local missing_tools=() - for tool in curl tar; do + for tool in curl tar git; do if ! command -v "$tool" &> /dev/null; then missing_tools+=("$tool") fi @@ -168,8 +169,194 @@ verify_installation() { fi } +# Check if this is a first install (no config file exists) +is_first_install() { + # Get the config path using the same logic as the Go code + local config_dir + if command -v "$BINARY_NAME" &> /dev/null; then + # If ml-notes is installed, we can ask it for the config path + local config_path + config_path=$("$BINARY_NAME" config path 2>/dev/null || echo "") + if [ -n "$config_path" ] && [ -f "$config_path" ]; then + return 1 # Config exists, not first install + fi + fi + + # Fallback: check standard XDG config location + local xdg_config_home="${XDG_CONFIG_HOME:-$HOME/.config}" + local config_file="$xdg_config_home/ml-notes/config.json" + + if [ -f "$config_file" ]; then + return 1 # Config exists, not first install + fi + + return 0 # No config found, first install +} + +# Install first-time dependencies +install_first_time_dependencies() { + print_info "Installing first-time dependencies..." + + # Install pdftotext + install_pdftotext + + # Install lil-rag service + install_lilrag_service + + print_success "First-time dependencies installed successfully!" +} + +# Install pdftotext command based on OS +install_pdftotext() { + print_info "Installing pdftotext..." + + # Check if pdftotext is already installed + if command -v pdftotext &> /dev/null; then + print_success "pdftotext is already installed" + return 0 + fi + + local OS=$(uname -s | tr '[:upper:]' '[:lower:]') + + case "$OS" in + linux) + install_pdftotext_linux + ;; + darwin) + install_pdftotext_macos + ;; + *) + print_warning "Unsupported OS for automatic pdftotext installation: $OS" + print_info "Please install pdftotext manually:" + print_info " Linux: sudo apt-get install poppler-utils (or equivalent)" + print_info " macOS: brew install poppler" + ;; + esac +} + +# Install pdftotext on Linux +install_pdftotext_linux() { + print_info "Installing pdftotext on Linux..." + + # Try different package managers + if command -v apt-get &> /dev/null; then + print_info "Using apt-get to install poppler-utils..." + if sudo apt-get update && sudo apt-get install -y poppler-utils; then + print_success "pdftotext installed via apt-get" + return 0 + fi + elif command -v yum &> /dev/null; then + print_info "Using yum to install poppler-utils..." + if sudo yum install -y poppler-utils; then + print_success "pdftotext installed via yum" + return 0 + fi + elif command -v dnf &> /dev/null; then + print_info "Using dnf to install poppler-utils..." + if sudo dnf install -y poppler-utils; then + print_success "pdftotext installed via dnf" + return 0 + fi + elif command -v pacman &> /dev/null; then + print_info "Using pacman to install poppler..." + if sudo pacman -S --noconfirm poppler; then + print_success "pdftotext installed via pacman" + return 0 + fi + else + print_warning "No supported package manager found" + print_info "Please install pdftotext manually: sudo apt-get install poppler-utils" + return 1 + fi + + print_warning "Failed to install pdftotext automatically" + print_info "Please install manually: sudo apt-get install poppler-utils" + return 1 +} + +# Install pdftotext on macOS +install_pdftotext_macos() { + print_info "Installing pdftotext on macOS..." + + if command -v brew &> /dev/null; then + print_info "Using Homebrew to install poppler..." + if brew install poppler; then + print_success "pdftotext installed via Homebrew" + return 0 + else + print_warning "Failed to install pdftotext via Homebrew" + return 1 + fi + else + print_warning "Homebrew not found" + print_info "Please install Homebrew first: https://brew.sh" + print_info "Then run: brew install poppler" + return 1 + fi +} + +# Install lil-rag service +install_lilrag_service() { + print_info "Installing lil-rag service..." + + # Check if Go is available for building + if ! command -v go &> /dev/null; then + print_warning "Go not found - cannot build lil-rag service" + print_info "Please install Go and then manually install lil-rag:" + print_info " git clone https://github.com/${LILRAG_REPO}.git" + print_info " cd lil-rag && go build -o lil-rag . && sudo install lil-rag ${INSTALL_DIR}/" + return 1 + fi + + # Create temp directory for cloning + local temp_dir=$(mktemp -d) + cleanup_temp() { + rm -rf "$temp_dir" + } + trap cleanup_temp EXIT + + print_info "Cloning lil-rag repository..." + if ! git clone "https://github.com/${LILRAG_REPO}.git" "$temp_dir/lil-rag"; then + print_error "Failed to clone lil-rag repository" + return 1 + fi + + print_info "Building lil-rag..." + cd "$temp_dir/lil-rag" + if ! go build -o lil-rag .; then + print_error "Failed to build lil-rag" + return 1 + fi + + # Install the binary + print_info "Installing lil-rag to $INSTALL_DIR..." + + # Check if we need sudo + if [ -w "$INSTALL_DIR" ]; then + SUDO="" + else + SUDO="sudo" + print_info "Root access required to install to $INSTALL_DIR" + fi + + if $SUDO install -m 755 lil-rag "$INSTALL_DIR/"; then + print_success "lil-rag service installed successfully!" + print_info "You can start it with: lil-rag" + return 0 + else + print_error "Failed to install lil-rag" + return 1 + fi +} + # Post-installation setup post_install() { + # Check if this is a first install (config doesn't exist) + if is_first_install; then + print_info "First install detected - setting up additional dependencies..." + install_first_time_dependencies + fi + echo "" print_info "Next steps:" echo " 1. Initialize configuration: ml-notes init" From 88b911cf80cff729c003e0e558458171e265503e Mon Sep 17 00:00:00 2001 From: Reed Date: Fri, 12 Sep 2025 11:29:15 -0700 Subject: [PATCH 3/6] Update install.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index c9f9407..aa89873 100755 --- a/install.sh +++ b/install.sh @@ -339,7 +339,7 @@ install_lilrag_service() { print_info "Root access required to install to $INSTALL_DIR" fi - if $SUDO install -m 755 lil-rag "$INSTALL_DIR/"; then + if ${SUDO:+$SUDO }install -m 755 lil-rag "$INSTALL_DIR/"; then print_success "lil-rag service installed successfully!" print_info "You can start it with: lil-rag" return 0 From 9d60a84249810186116d86429a66afadb0b2f2db Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:29:32 +0000 Subject: [PATCH 4/6] Improve error handling for first-install dependencies to be non-fatal Co-authored-by: streed <805140+streed@users.noreply.github.com> --- install.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index aa89873..f53ebff 100755 --- a/install.sh +++ b/install.sh @@ -197,13 +197,26 @@ is_first_install() { install_first_time_dependencies() { print_info "Installing first-time dependencies..." + local failed_installs=() + # Install pdftotext - install_pdftotext + if ! install_pdftotext; then + failed_installs+=("pdftotext") + fi # Install lil-rag service - install_lilrag_service + if ! install_lilrag_service; then + failed_installs+=("lil-rag") + fi - print_success "First-time dependencies installed successfully!" + if [ ${#failed_installs[@]} -eq 0 ]; then + print_success "First-time dependencies installed successfully!" + else + print_warning "Some dependencies could not be installed automatically: ${failed_installs[*]}" + print_info "You can install them manually later. ML Notes will still work without them." + print_info "For pdftotext: Install poppler-utils (Linux) or poppler (macOS)" + print_info "For lil-rag: git clone https://github.com/${LILRAG_REPO}.git && cd lil-rag && go build" + fi } # Install pdftotext command based on OS From 4848e91825ba2ea14a97ad698b23a1b65b5c8735 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:30:50 +0000 Subject: [PATCH 5/6] Fix install command syntax for lil-rag installation Co-authored-by: streed <805140+streed@users.noreply.github.com> --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index f53ebff..cd3d2d4 100755 --- a/install.sh +++ b/install.sh @@ -352,7 +352,7 @@ install_lilrag_service() { print_info "Root access required to install to $INSTALL_DIR" fi - if ${SUDO:+$SUDO }install -m 755 lil-rag "$INSTALL_DIR/"; then + if $SUDO install -m 755 lil-rag "$INSTALL_DIR/"; then print_success "lil-rag service installed successfully!" print_info "You can start it with: lil-rag" return 0 From 0c6eb909ce10dc00c0e244f63532421eac56f038 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:34:02 +0000 Subject: [PATCH 6/6] Use lil-rag repository's install.sh script for installation Co-authored-by: streed <805140+streed@users.noreply.github.com> --- install.sh | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/install.sh b/install.sh index cd3d2d4..87d62b4 100755 --- a/install.sh +++ b/install.sh @@ -215,7 +215,7 @@ install_first_time_dependencies() { print_warning "Some dependencies could not be installed automatically: ${failed_installs[*]}" print_info "You can install them manually later. ML Notes will still work without them." print_info "For pdftotext: Install poppler-utils (Linux) or poppler (macOS)" - print_info "For lil-rag: git clone https://github.com/${LILRAG_REPO}.git && cd lil-rag && go build" + print_info "For lil-rag: git clone https://github.com/${LILRAG_REPO}.git && cd lil-rag && ./install.sh" fi } @@ -312,15 +312,6 @@ install_pdftotext_macos() { install_lilrag_service() { print_info "Installing lil-rag service..." - # Check if Go is available for building - if ! command -v go &> /dev/null; then - print_warning "Go not found - cannot build lil-rag service" - print_info "Please install Go and then manually install lil-rag:" - print_info " git clone https://github.com/${LILRAG_REPO}.git" - print_info " cd lil-rag && go build -o lil-rag . && sudo install lil-rag ${INSTALL_DIR}/" - return 1 - fi - # Create temp directory for cloning local temp_dir=$(mktemp -d) cleanup_temp() { @@ -331,33 +322,35 @@ install_lilrag_service() { print_info "Cloning lil-rag repository..." if ! git clone "https://github.com/${LILRAG_REPO}.git" "$temp_dir/lil-rag"; then print_error "Failed to clone lil-rag repository" + print_info "Please install lil-rag manually:" + print_info " git clone https://github.com/${LILRAG_REPO}.git" + print_info " cd lil-rag && ./install.sh" return 1 fi - print_info "Building lil-rag..." + print_info "Running lil-rag installation script..." cd "$temp_dir/lil-rag" - if ! go build -o lil-rag .; then - print_error "Failed to build lil-rag" - return 1 - fi - - # Install the binary - print_info "Installing lil-rag to $INSTALL_DIR..." - # Check if we need sudo - if [ -w "$INSTALL_DIR" ]; then - SUDO="" - else - SUDO="sudo" - print_info "Root access required to install to $INSTALL_DIR" + # Check if install.sh exists + if [ ! -f "install.sh" ]; then + print_error "install.sh not found in lil-rag repository" + print_info "Please install lil-rag manually:" + print_info " git clone https://github.com/${LILRAG_REPO}.git" + print_info " cd lil-rag && go build -o lil-rag . && sudo install lil-rag ${INSTALL_DIR}/" + return 1 fi - if $SUDO install -m 755 lil-rag "$INSTALL_DIR/"; then + # Make install.sh executable and run it + chmod +x install.sh + if ./install.sh --install-dir "$INSTALL_DIR"; then print_success "lil-rag service installed successfully!" print_info "You can start it with: lil-rag" return 0 else - print_error "Failed to install lil-rag" + print_error "Failed to install lil-rag using its install script" + print_info "Please install lil-rag manually:" + print_info " git clone https://github.com/${LILRAG_REPO}.git" + print_info " cd lil-rag && ./install.sh" return 1 fi }