Compare commits
No commits in common. "main" and "feature/shared-task-scheduler" have entirely different histories.
main
...
feature/sh
17 changed files with 27 additions and 1006 deletions
36
.env.example
36
.env.example
|
|
@ -46,39 +46,3 @@ SNIPE_DB=data/snipe.db
|
||||||
# Heimdall license server — for tier resolution and free-key auto-provisioning.
|
# Heimdall license server — for tier resolution and free-key auto-provisioning.
|
||||||
# HEIMDALL_URL=https://license.circuitforge.tech
|
# HEIMDALL_URL=https://license.circuitforge.tech
|
||||||
# HEIMDALL_ADMIN_TOKEN=
|
# HEIMDALL_ADMIN_TOKEN=
|
||||||
|
|
||||||
# ── eBay Affiliate (optional) ─────────────────────────────────────────────────
|
|
||||||
# Set to your eBay Partner Network (EPN) campaign ID to earn commissions on
|
|
||||||
# listing click-throughs. Leave blank for clean /itm/ URLs (no tracking).
|
|
||||||
# Register at https://partnernetwork.ebay.com — self-hosted users can use their
|
|
||||||
# own ID; the CF cloud instance uses CF's campaign ID (disclosed in the UI).
|
|
||||||
# EBAY_AFFILIATE_CAMPAIGN_ID=
|
|
||||||
|
|
||||||
# ── LLM inference (vision / photo analysis) ──────────────────────────────────
|
|
||||||
# circuitforge-core LLMRouter auto-detects backends from these env vars
|
|
||||||
# (no llm.yaml required). Backends are tried in this priority order:
|
|
||||||
# 1. ANTHROPIC_API_KEY → Claude API (cloud; requires Paid tier key)
|
|
||||||
# 2. OPENAI_API_KEY → OpenAI-compatible endpoint
|
|
||||||
# 3. OLLAMA_HOST → local Ollama (default: http://localhost:11434)
|
|
||||||
# Leave all unset to disable LLM features (photo analysis won't run).
|
|
||||||
|
|
||||||
# ANTHROPIC_API_KEY=
|
|
||||||
# ANTHROPIC_MODEL=claude-haiku-4-5-20251001
|
|
||||||
|
|
||||||
# OPENAI_API_KEY=
|
|
||||||
# OPENAI_BASE_URL=https://api.openai.com/v1
|
|
||||||
# OPENAI_MODEL=gpt-4o-mini
|
|
||||||
|
|
||||||
# OLLAMA_HOST=http://localhost:11434
|
|
||||||
# OLLAMA_MODEL=llava:7b
|
|
||||||
|
|
||||||
# CF Orchestrator — managed inference for Paid+ cloud users (internal use only).
|
|
||||||
# Self-hosted users leave this unset; it has no effect without a valid allocation token.
|
|
||||||
# CF_ORCH_URL=https://orch.circuitforge.tech
|
|
||||||
|
|
||||||
# ── In-app feedback (beta) ────────────────────────────────────────────────────
|
|
||||||
# When set, a feedback FAB appears in the UI and routes submissions to Forgejo.
|
|
||||||
# Leave unset to silently hide the button (demo/offline deployments).
|
|
||||||
# FORGEJO_API_TOKEN=
|
|
||||||
# FORGEJO_REPO=Circuit-Forge/snipe
|
|
||||||
# FORGEJO_API_URL=https://git.opensourcesolarpunk.com/api/v1
|
|
||||||
|
|
|
||||||
60
README.md
60
README.md
|
|
@ -2,51 +2,7 @@
|
||||||
|
|
||||||
> *Part of the Circuit Forge LLC "AI for the tasks you hate most" suite.*
|
> *Part of the Circuit Forge LLC "AI for the tasks you hate most" suite.*
|
||||||
|
|
||||||
**Status:** Active — eBay listing intelligence MVP complete (search, trust scoring, affiliate links, feedback FAB, vision task scheduling). Auction sniping engine and multi-platform support are next.
|
**Status:** Active — eBay listing search + seller trust scoring MVP complete. Auction sniping engine and multi-platform support are next.
|
||||||
|
|
||||||
## Quick install (self-hosted)
|
|
||||||
|
|
||||||
**Requirements:** Docker with Compose plugin, Git. No API keys needed to get started.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# One-line install — clones to ~/snipe by default
|
|
||||||
bash <(curl -fsSL https://git.opensourcesolarpunk.com/Circuit-Forge/snipe/raw/branch/main/install.sh)
|
|
||||||
|
|
||||||
# Or clone manually and run the script:
|
|
||||||
git clone https://git.opensourcesolarpunk.com/Circuit-Forge/snipe.git
|
|
||||||
bash snipe/install.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
Then open **http://localhost:8509**.
|
|
||||||
|
|
||||||
### Manual setup (if you prefer)
|
|
||||||
|
|
||||||
Snipe's API image is built from a parent context that includes `circuitforge-core`. Both repos must sit as siblings in the same directory:
|
|
||||||
|
|
||||||
```
|
|
||||||
workspace/
|
|
||||||
├── snipe/ ← this repo
|
|
||||||
└── circuitforge-core/ ← required sibling
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash
|
|
||||||
mkdir snipe-workspace && cd snipe-workspace
|
|
||||||
git clone https://git.opensourcesolarpunk.com/Circuit-Forge/snipe.git
|
|
||||||
git clone https://git.opensourcesolarpunk.com/Circuit-Forge/circuitforge-core.git
|
|
||||||
cd snipe
|
|
||||||
cp .env.example .env # edit if you have eBay API credentials (optional)
|
|
||||||
./manage.sh start
|
|
||||||
```
|
|
||||||
|
|
||||||
### Optional: eBay API credentials
|
|
||||||
|
|
||||||
Snipe works without any credentials using its Playwright scraper fallback. Adding eBay API credentials unlocks faster searches and inline seller account age (no extra scrape needed):
|
|
||||||
|
|
||||||
1. Register at [developer.ebay.com](https://developer.ebay.com/my/keys)
|
|
||||||
2. Copy your Production **App ID** and **Cert ID** into `.env`
|
|
||||||
3. Restart: `./manage.sh restart`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## What it does
|
## What it does
|
||||||
|
|
||||||
|
|
@ -112,20 +68,6 @@ Scans listing titles for signals the item may have undisclosed damage or problem
|
||||||
- **On-demand**: ↻ button on any listing card triggers `POST /api/enrich` — runs enrichment and re-scores without waiting for a second search
|
- **On-demand**: ↻ button on any listing card triggers `POST /api/enrich` — runs enrichment and re-scores without waiting for a second search
|
||||||
- **Category history**: derived from the seller's accumulated listing data (Browse API `categories` field); improves with every search, no extra API calls
|
- **Category history**: derived from the seller's accumulated listing data (Browse API `categories` field); improves with every search, no extra API calls
|
||||||
|
|
||||||
### Affiliate link builder
|
|
||||||
|
|
||||||
Listing cards surface eBay affiliate-wrapped URLs. Uses `circuitforge_core.affiliates.wrap_url` — resolution order: user opted out → plain URL; user has BYOK affiliate ID → their ID; CF env var set (`EBAY_AFFILIATE_ID`) → CF's ID; otherwise plain URL. Users can configure their own eBay Partner Network ID or opt out entirely in Settings.
|
|
||||||
|
|
||||||
Disclosure tooltip appears on first encounter per-session and on each wrapped link (per-retailer copy from `get_disclosure_text`).
|
|
||||||
|
|
||||||
### Feedback FAB
|
|
||||||
|
|
||||||
In-app feedback button (bottom-right FAB) opens a modal: title, description, optional screenshot. Posts to the CF feedback endpoint. Status probed on load; FAB hidden if endpoint unreachable.
|
|
||||||
|
|
||||||
### Vision task scheduling
|
|
||||||
|
|
||||||
Photo condition assessment tasks queued through `circuitforge_core.tasks.TaskScheduler` — VRAM-aware slot management shared with any other LLM workloads on the same host. Runs moondream2 locally (free tier) or Claude vision (paid/cloud). Results stored per-listing and update the trust score card.
|
|
||||||
|
|
||||||
### Market price comparison
|
### Market price comparison
|
||||||
Completed sales fetched via eBay Marketplace Insights API (with Browse API fallback for app tiers that don't have Insights access). Median stored per query hash, used to score `price_vs_market` across all listings in a search.
|
Completed sales fetched via eBay Marketplace Insights API (with Browse API fallback for app tiers that don't have Insights access). Median stored per query hash, used to score `price_vs_market` across all listings in a search.
|
||||||
|
|
||||||
|
|
|
||||||
20
api/main.py
20
api/main.py
|
|
@ -11,15 +11,12 @@ from pathlib import Path
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
import io
|
import io
|
||||||
|
|
||||||
from fastapi import Depends, FastAPI, HTTPException, UploadFile, File
|
from fastapi import Depends, FastAPI, HTTPException, UploadFile, File
|
||||||
from fastapi.responses import StreamingResponse
|
from fastapi.responses import StreamingResponse
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
from circuitforge_core.config import load_env
|
from circuitforge_core.config import load_env
|
||||||
from circuitforge_core.affiliates import wrap_url as _wrap_affiliate_url
|
|
||||||
from circuitforge_core.api import make_feedback_router as _make_feedback_router
|
|
||||||
from app.db.store import Store
|
from app.db.store import Store
|
||||||
from app.db.models import SavedSearch as SavedSearchModel, ScammerEntry
|
from app.db.models import SavedSearch as SavedSearchModel, ScammerEntry
|
||||||
from app.platforms import SearchFilters
|
from app.platforms import SearchFilters
|
||||||
|
|
@ -66,7 +63,6 @@ def _ebay_creds() -> tuple[str, str, str]:
|
||||||
client_secret = (os.environ.get("EBAY_CERT_ID") or os.environ.get("EBAY_CLIENT_SECRET", "")).strip()
|
client_secret = (os.environ.get("EBAY_CERT_ID") or os.environ.get("EBAY_CLIENT_SECRET", "")).strip()
|
||||||
return client_id, client_secret, env
|
return client_id, client_secret, env
|
||||||
|
|
||||||
|
|
||||||
app = FastAPI(title="Snipe API", version="0.1.0", lifespan=_lifespan)
|
app = FastAPI(title="Snipe API", version="0.1.0", lifespan=_lifespan)
|
||||||
app.include_router(ebay_webhook_router)
|
app.include_router(ebay_webhook_router)
|
||||||
|
|
||||||
|
|
@ -77,12 +73,6 @@ app.add_middleware(
|
||||||
allow_headers=["*"],
|
allow_headers=["*"],
|
||||||
)
|
)
|
||||||
|
|
||||||
_feedback_router = _make_feedback_router(
|
|
||||||
repo="Circuit-Forge/snipe",
|
|
||||||
product="snipe",
|
|
||||||
)
|
|
||||||
app.include_router(_feedback_router, prefix="/api/feedback")
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/api/health")
|
@app.get("/api/health")
|
||||||
def health():
|
def health():
|
||||||
|
|
@ -399,18 +389,12 @@ def search(
|
||||||
and shared_store.get_seller("ebay", listing.seller_platform_id)
|
and shared_store.get_seller("ebay", listing.seller_platform_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
def _serialize_listing(l: object) -> dict:
|
|
||||||
d = dataclasses.asdict(l)
|
|
||||||
d["url"] = _wrap_affiliate_url(d["url"], retailer="ebay")
|
|
||||||
return d
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"listings": [_serialize_listing(l) for l in listings],
|
"listings": [dataclasses.asdict(l) for l in listings],
|
||||||
"trust_scores": trust_map,
|
"trust_scores": trust_map,
|
||||||
"sellers": seller_map,
|
"sellers": seller_map,
|
||||||
"market_price": market_price,
|
"market_price": market_price,
|
||||||
"adapter_used": adapter_used,
|
"adapter_used": adapter_used,
|
||||||
"affiliate_active": bool(os.environ.get("EBAY_AFFILIATE_CAMPAIGN_ID", "").strip()),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -645,5 +629,3 @@ async def import_blocklist(
|
||||||
|
|
||||||
log.info("Blocklist import: %d added, %d errors", imported, len(errors))
|
log.info("Blocklist import: %d added, %d errors", imported, len(errors))
|
||||||
return {"imported": imported, "errors": errors}
|
return {"imported": imported, "errors": errors}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,6 @@ class TrustScorer:
|
||||||
signal_scores, is_dup, seller,
|
signal_scores, is_dup, seller,
|
||||||
listing_id=listing.id or 0,
|
listing_id=listing.id or 0,
|
||||||
listing_title=listing.title,
|
listing_title=listing.title,
|
||||||
listing_condition=listing.condition,
|
|
||||||
times_seen=listing.times_seen,
|
times_seen=listing.times_seen,
|
||||||
first_seen_at=listing.first_seen_at,
|
first_seen_at=listing.first_seen_at,
|
||||||
price=listing.price,
|
price=listing.price,
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,8 @@ _SCRATCH_DENT_KEYWORDS = frozenset([
|
||||||
"crack", "cracked", "chip", "chipped",
|
"crack", "cracked", "chip", "chipped",
|
||||||
"damage", "damaged", "cosmetic damage",
|
"damage", "damaged", "cosmetic damage",
|
||||||
"blemish", "wear", "worn", "worn in",
|
"blemish", "wear", "worn", "worn in",
|
||||||
# Parts / condition catch-alls (also matches eBay condition field strings verbatim)
|
# Parts / condition catch-alls
|
||||||
"as is", "for parts", "parts only", "spares or repair", "parts or repair",
|
"as is", "for parts", "parts only", "spares or repair", "parts or repair",
|
||||||
"parts/repair", "parts or not working", "not working",
|
|
||||||
# Evasive redirects — seller hiding damage detail in listing body
|
# Evasive redirects — seller hiding damage detail in listing body
|
||||||
"see description", "read description", "read listing", "see listing",
|
"see description", "read description", "read listing", "see listing",
|
||||||
"see photos for", "see pics for", "see images for",
|
"see photos for", "see pics for", "see images for",
|
||||||
|
|
@ -73,7 +72,6 @@ class Aggregator:
|
||||||
seller: Optional[Seller],
|
seller: Optional[Seller],
|
||||||
listing_id: int = 0,
|
listing_id: int = 0,
|
||||||
listing_title: str = "",
|
listing_title: str = "",
|
||||||
listing_condition: str = "",
|
|
||||||
times_seen: int = 1,
|
times_seen: int = 1,
|
||||||
first_seen_at: Optional[str] = None,
|
first_seen_at: Optional[str] = None,
|
||||||
price: float = 0.0,
|
price: float = 0.0,
|
||||||
|
|
@ -139,9 +137,7 @@ class Aggregator:
|
||||||
)
|
)
|
||||||
if photo_hash_duplicate and not is_established_retailer:
|
if photo_hash_duplicate and not is_established_retailer:
|
||||||
red_flags.append("duplicate_photo")
|
red_flags.append("duplicate_photo")
|
||||||
if (listing_title and _has_damage_keywords(listing_title)) or (
|
if listing_title and _has_damage_keywords(listing_title):
|
||||||
listing_condition and _has_damage_keywords(listing_condition)
|
|
||||||
):
|
|
||||||
red_flags.append("scratch_dent_mentioned")
|
red_flags.append("scratch_dent_mentioned")
|
||||||
|
|
||||||
# Staging DB signals
|
# Staging DB signals
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,21 @@
|
||||||
# compose.override.yml — dev-only additions (auto-applied by Docker Compose in dev).
|
|
||||||
# Safe to delete on a self-hosted machine — compose.yml is self-contained.
|
|
||||||
#
|
|
||||||
# What this adds over compose.yml:
|
|
||||||
# - Live source mounts so code changes take effect without rebuilding images
|
|
||||||
# - RELOAD=true to enable uvicorn --reload for the API
|
|
||||||
# - NOTE: circuitforge-core is NOT mounted here — use `./manage.sh build` to
|
|
||||||
# pick up cf-core changes. Mounting it as a bind volume would break self-hosted
|
|
||||||
# installs that don't have the sibling directory.
|
|
||||||
services:
|
services:
|
||||||
api:
|
api:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: snipe/Dockerfile
|
||||||
|
network_mode: host
|
||||||
volumes:
|
volumes:
|
||||||
|
- ../circuitforge-core:/app/circuitforge-core
|
||||||
- ./api:/app/snipe/api
|
- ./api:/app/snipe/api
|
||||||
- ./app:/app/snipe/app
|
- ./app:/app/snipe/app
|
||||||
|
- ./data:/app/snipe/data
|
||||||
- ./tests:/app/snipe/tests
|
- ./tests:/app/snipe/tests
|
||||||
environment:
|
environment:
|
||||||
- RELOAD=true
|
- RELOAD=true
|
||||||
|
|
||||||
|
web:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/web/Dockerfile
|
||||||
|
volumes:
|
||||||
|
- ./web/src:/app/src # not used at runtime but keeps override valid
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,11 @@ services:
|
||||||
build:
|
build:
|
||||||
context: ..
|
context: ..
|
||||||
dockerfile: snipe/Dockerfile
|
dockerfile: snipe/Dockerfile
|
||||||
# Host networking lets nginx (in the web container) reach the API at
|
ports:
|
||||||
# 172.17.0.1:8510 (the Docker bridge gateway). Required — nginx.conf
|
- "8510:8510"
|
||||||
# is baked into the image and hard-codes that address.
|
|
||||||
network_mode: host
|
|
||||||
env_file: .env
|
env_file: .env
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/snipe/data
|
- ./data:/app/snipe/data
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
web:
|
web:
|
||||||
build:
|
build:
|
||||||
|
|
|
||||||
226
install.sh
226
install.sh
|
|
@ -1,226 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
# Snipe — self-hosted install script
|
|
||||||
#
|
|
||||||
# Supports two install paths:
|
|
||||||
# Docker (recommended) — everything in containers, no system Python deps required
|
|
||||||
# No-Docker — conda or venv + direct uvicorn, for machines without Docker
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# bash install.sh # installs to ~/snipe
|
|
||||||
# bash install.sh /opt/snipe # custom install directory
|
|
||||||
# bash install.sh ~/snipe --no-docker # force no-Docker path even if Docker present
|
|
||||||
#
|
|
||||||
# Requirements (Docker path): Docker with Compose plugin, Git
|
|
||||||
# Requirements (no-Docker path): Python 3.11+, Node.js 20+, Git, xvfb (system)
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
INSTALL_DIR="${1:-$HOME/snipe}"
|
|
||||||
FORCE_NO_DOCKER="${2:-}"
|
|
||||||
FORGEJO="https://git.opensourcesolarpunk.com/Circuit-Forge"
|
|
||||||
CONDA_ENV="cf"
|
|
||||||
|
|
||||||
info() { echo " [snipe] $*"; }
|
|
||||||
ok() { echo "✓ $*"; }
|
|
||||||
warn() { echo "! $*"; }
|
|
||||||
fail() { echo "✗ $*" >&2; exit 1; }
|
|
||||||
hr() { echo "────────────────────────────────────────────────────────"; }
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo " Snipe — self-hosted installer"
|
|
||||||
echo " Install directory: $INSTALL_DIR"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# ── Detect capabilities ──────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
HAS_DOCKER=false
|
|
||||||
HAS_CONDA=false
|
|
||||||
HAS_PYTHON=false
|
|
||||||
HAS_NODE=false
|
|
||||||
|
|
||||||
docker compose version >/dev/null 2>&1 && HAS_DOCKER=true
|
|
||||||
conda --version >/dev/null 2>&1 && HAS_CONDA=true
|
|
||||||
python3 --version >/dev/null 2>&1 && HAS_PYTHON=true
|
|
||||||
node --version >/dev/null 2>&1 && HAS_NODE=true
|
|
||||||
command -v git >/dev/null 2>&1 || fail "Git is required. Install with: sudo apt-get install git"
|
|
||||||
|
|
||||||
# Honour --no-docker flag
|
|
||||||
[[ "$FORCE_NO_DOCKER" == "--no-docker" ]] && HAS_DOCKER=false
|
|
||||||
|
|
||||||
if $HAS_DOCKER; then
|
|
||||||
INSTALL_PATH="docker"
|
|
||||||
ok "Docker found — using Docker install path (recommended)"
|
|
||||||
elif $HAS_PYTHON; then
|
|
||||||
INSTALL_PATH="python"
|
|
||||||
warn "Docker not found — using no-Docker path (conda or venv)"
|
|
||||||
else
|
|
||||||
fail "Docker or Python 3.11+ is required. Install Docker: https://docs.docker.com/get-docker/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ── Clone repos ──────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
# compose.yml and the Dockerfile both use context: .. (parent directory), so
|
|
||||||
# snipe/ and circuitforge-core/ must be siblings inside INSTALL_DIR.
|
|
||||||
SNIPE_DIR="$INSTALL_DIR/snipe"
|
|
||||||
CORE_DIR="$INSTALL_DIR/circuitforge-core"
|
|
||||||
|
|
||||||
if [[ -d "$SNIPE_DIR" ]]; then
|
|
||||||
info "Snipe already cloned — pulling latest..."
|
|
||||||
git -C "$SNIPE_DIR" pull --ff-only
|
|
||||||
else
|
|
||||||
info "Cloning Snipe..."
|
|
||||||
mkdir -p "$INSTALL_DIR"
|
|
||||||
git clone "$FORGEJO/snipe.git" "$SNIPE_DIR"
|
|
||||||
fi
|
|
||||||
ok "Snipe → $SNIPE_DIR"
|
|
||||||
|
|
||||||
if [[ -d "$CORE_DIR" ]]; then
|
|
||||||
info "circuitforge-core already cloned — pulling latest..."
|
|
||||||
git -C "$CORE_DIR" pull --ff-only
|
|
||||||
else
|
|
||||||
info "Cloning circuitforge-core (shared library)..."
|
|
||||||
git clone "$FORGEJO/circuitforge-core.git" "$CORE_DIR"
|
|
||||||
fi
|
|
||||||
ok "circuitforge-core → $CORE_DIR"
|
|
||||||
|
|
||||||
# ── Configure environment ────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
ENV_FILE="$SNIPE_DIR/.env"
|
|
||||||
if [[ ! -f "$ENV_FILE" ]]; then
|
|
||||||
cp "$SNIPE_DIR/.env.example" "$ENV_FILE"
|
|
||||||
# Safe defaults for local installs — no eBay registration, no Heimdall
|
|
||||||
sed -i 's/^EBAY_WEBHOOK_VERIFY_SIGNATURES=true/EBAY_WEBHOOK_VERIFY_SIGNATURES=false/' "$ENV_FILE"
|
|
||||||
ok ".env created from .env.example"
|
|
||||||
echo ""
|
|
||||||
info "Snipe works out of the box with no API keys."
|
|
||||||
info "Add EBAY_APP_ID / EBAY_CERT_ID later for faster searches (optional)."
|
|
||||||
echo ""
|
|
||||||
else
|
|
||||||
info ".env already exists — skipping (delete it to reset)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "$SNIPE_DIR"
|
|
||||||
|
|
||||||
# ── Docker install path ───────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
if [[ "$INSTALL_PATH" == "docker" ]]; then
|
|
||||||
info "Building Docker images (~1 GB download on first run)..."
|
|
||||||
docker compose build
|
|
||||||
|
|
||||||
info "Starting Snipe..."
|
|
||||||
docker compose up -d
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
ok "Snipe is running!"
|
|
||||||
hr
|
|
||||||
echo " Web UI: http://localhost:8509"
|
|
||||||
echo " API: http://localhost:8510/docs"
|
|
||||||
echo ""
|
|
||||||
echo " Manage: cd $SNIPE_DIR && ./manage.sh {start|stop|restart|logs|test}"
|
|
||||||
hr
|
|
||||||
echo ""
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ── No-Docker install path ───────────────────────────────────────────────────
|
|
||||||
|
|
||||||
# System deps: Xvfb is required for Playwright (Kasada bypass via headed Chromium)
|
|
||||||
if ! command -v Xvfb >/dev/null 2>&1; then
|
|
||||||
info "Installing Xvfb (required for eBay scraper)..."
|
|
||||||
if command -v apt-get >/dev/null 2>&1; then
|
|
||||||
sudo apt-get install -y --no-install-recommends xvfb
|
|
||||||
elif command -v dnf >/dev/null 2>&1; then
|
|
||||||
sudo dnf install -y xorg-x11-server-Xvfb
|
|
||||||
elif command -v brew >/dev/null 2>&1; then
|
|
||||||
warn "macOS: Xvfb not available. The scraper fallback may fail."
|
|
||||||
warn "Add eBay API credentials to .env to use the API adapter instead."
|
|
||||||
else
|
|
||||||
warn "Could not install Xvfb automatically. Install it with your package manager."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ── Python environment setup ─────────────────────────────────────────────────
|
|
||||||
|
|
||||||
if $HAS_CONDA; then
|
|
||||||
info "Setting up conda environment '$CONDA_ENV'..."
|
|
||||||
if conda env list | grep -q "^$CONDA_ENV "; then
|
|
||||||
info "Conda env '$CONDA_ENV' already exists — updating..."
|
|
||||||
conda run -n "$CONDA_ENV" pip install --quiet -e "$CORE_DIR"
|
|
||||||
conda run -n "$CONDA_ENV" pip install --quiet -e "$SNIPE_DIR"
|
|
||||||
else
|
|
||||||
conda create -n "$CONDA_ENV" python=3.11 -y
|
|
||||||
conda run -n "$CONDA_ENV" pip install --quiet -e "$CORE_DIR"
|
|
||||||
conda run -n "$CONDA_ENV" pip install --quiet -e "$SNIPE_DIR"
|
|
||||||
fi
|
|
||||||
conda run -n "$CONDA_ENV" playwright install chromium
|
|
||||||
conda run -n "$CONDA_ENV" playwright install-deps chromium
|
|
||||||
PYTHON_RUN="conda run -n $CONDA_ENV"
|
|
||||||
ok "Conda environment '$CONDA_ENV' ready"
|
|
||||||
else
|
|
||||||
info "Setting up Python venv at $SNIPE_DIR/.venv ..."
|
|
||||||
python3 -m venv "$SNIPE_DIR/.venv"
|
|
||||||
"$SNIPE_DIR/.venv/bin/pip" install --quiet -e "$CORE_DIR"
|
|
||||||
"$SNIPE_DIR/.venv/bin/pip" install --quiet -e "$SNIPE_DIR"
|
|
||||||
"$SNIPE_DIR/.venv/bin/playwright" install chromium
|
|
||||||
"$SNIPE_DIR/.venv/bin/playwright" install-deps chromium
|
|
||||||
PYTHON_RUN="$SNIPE_DIR/.venv/bin"
|
|
||||||
ok "Python venv ready at $SNIPE_DIR/.venv"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ── Frontend ─────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
if $HAS_NODE; then
|
|
||||||
info "Building Vue frontend..."
|
|
||||||
cd "$SNIPE_DIR/web"
|
|
||||||
npm ci --prefer-offline --silent
|
|
||||||
npm run build
|
|
||||||
cd "$SNIPE_DIR"
|
|
||||||
ok "Frontend built → web/dist/"
|
|
||||||
else
|
|
||||||
warn "Node.js not found — skipping frontend build."
|
|
||||||
warn "Install Node.js 20+ from https://nodejs.org and re-run install.sh to build the UI."
|
|
||||||
warn "Until then, you can access the API directly at http://localhost:8510/docs"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ── Write start/stop scripts ─────────────────────────────────────────────────
|
|
||||||
|
|
||||||
cat > "$SNIPE_DIR/start-local.sh" << 'STARTSCRIPT'
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
# Start Snipe without Docker (API only — run from the snipe/ directory)
|
|
||||||
set -euo pipefail
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
|
|
||||||
if [[ -f .venv/bin/uvicorn ]]; then
|
|
||||||
UVICORN=".venv/bin/uvicorn"
|
|
||||||
elif command -v conda >/dev/null 2>&1 && conda env list | grep -q "^cf "; then
|
|
||||||
UVICORN="conda run -n cf uvicorn"
|
|
||||||
else
|
|
||||||
echo "No Python env found. Run install.sh first." >&2; exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p data
|
|
||||||
echo "Starting Snipe API on http://localhost:8510 ..."
|
|
||||||
$UVICORN api.main:app --host 0.0.0.0 --port 8510 "${@}"
|
|
||||||
STARTSCRIPT
|
|
||||||
chmod +x "$SNIPE_DIR/start-local.sh"
|
|
||||||
|
|
||||||
# Frontend serving (if built)
|
|
||||||
cat > "$SNIPE_DIR/serve-ui.sh" << 'UISCRIPT'
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
# Serve the pre-built Vue frontend on port 8509 (dev only — use nginx for production)
|
|
||||||
cd "$(dirname "$0")/web/dist"
|
|
||||||
python3 -m http.server 8509
|
|
||||||
UISCRIPT
|
|
||||||
chmod +x "$SNIPE_DIR/serve-ui.sh"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
ok "Snipe installed (no-Docker mode)"
|
|
||||||
hr
|
|
||||||
echo " Start API: cd $SNIPE_DIR && ./start-local.sh"
|
|
||||||
echo " Serve UI: cd $SNIPE_DIR && ./serve-ui.sh (separate terminal)"
|
|
||||||
echo " API docs: http://localhost:8510/docs"
|
|
||||||
echo " Web UI: http://localhost:8509 (after ./serve-ui.sh)"
|
|
||||||
echo ""
|
|
||||||
echo " For production, point nginx at web/dist/ and proxy /api/ to localhost:8510"
|
|
||||||
hr
|
|
||||||
echo ""
|
|
||||||
|
|
@ -78,7 +78,7 @@ case "$cmd" in
|
||||||
test)
|
test)
|
||||||
echo "Running test suite..."
|
echo "Running test suite..."
|
||||||
docker compose -f "$COMPOSE_FILE" exec api \
|
docker compose -f "$COMPOSE_FILE" exec api \
|
||||||
python -m pytest /app/snipe/tests/ -v "${@}"
|
conda run -n job-seeker python -m pytest /app/snipe/tests/ -v "${@}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# ── Cloud commands ────────────────────────────────────────────────────────
|
# ── Cloud commands ────────────────────────────────────────────────────────
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ version = "0.1.0"
|
||||||
description = "Auction listing monitor and trust scorer"
|
description = "Auction listing monitor and trust scorer"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"circuitforge-core>=0.8.0",
|
"circuitforge-core",
|
||||||
"streamlit>=1.32",
|
"streamlit>=1.32",
|
||||||
"requests>=2.31",
|
"requests>=2.31",
|
||||||
"imagehash>=4.3",
|
"imagehash>=4.3",
|
||||||
|
|
|
||||||
|
|
@ -1,134 +0,0 @@
|
||||||
"""Tests for the shared feedback router (circuitforge-core) mounted in snipe."""
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from collections.abc import Callable
|
|
||||||
from unittest.mock import MagicMock, patch
|
|
||||||
|
|
||||||
from fastapi import FastAPI
|
|
||||||
from fastapi.testclient import TestClient
|
|
||||||
|
|
||||||
from circuitforge_core.api.feedback import make_feedback_router
|
|
||||||
|
|
||||||
|
|
||||||
# ── Test app factory ──────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
def _make_client(demo_mode_fn: Callable[[], bool] | None = None) -> TestClient:
|
|
||||||
app = FastAPI()
|
|
||||||
router = make_feedback_router(
|
|
||||||
repo="Circuit-Forge/snipe",
|
|
||||||
product="snipe",
|
|
||||||
demo_mode_fn=demo_mode_fn,
|
|
||||||
)
|
|
||||||
app.include_router(router, prefix="/api/feedback")
|
|
||||||
return TestClient(app)
|
|
||||||
|
|
||||||
|
|
||||||
# ── GET /api/feedback/status ──────────────────────────────────────────────────
|
|
||||||
|
|
||||||
def test_status_disabled_when_no_token(monkeypatch):
|
|
||||||
monkeypatch.delenv("FORGEJO_API_TOKEN", raising=False)
|
|
||||||
monkeypatch.delenv("DEMO_MODE", raising=False)
|
|
||||||
client = _make_client(demo_mode_fn=lambda: False)
|
|
||||||
res = client.get("/api/feedback/status")
|
|
||||||
assert res.status_code == 200
|
|
||||||
assert res.json() == {"enabled": False}
|
|
||||||
|
|
||||||
|
|
||||||
def test_status_enabled_when_token_set(monkeypatch):
|
|
||||||
monkeypatch.setenv("FORGEJO_API_TOKEN", "test-token")
|
|
||||||
client = _make_client(demo_mode_fn=lambda: False)
|
|
||||||
res = client.get("/api/feedback/status")
|
|
||||||
assert res.status_code == 200
|
|
||||||
assert res.json() == {"enabled": True}
|
|
||||||
|
|
||||||
|
|
||||||
def test_status_disabled_in_demo_mode(monkeypatch):
|
|
||||||
monkeypatch.setenv("FORGEJO_API_TOKEN", "test-token")
|
|
||||||
demo = True
|
|
||||||
client = _make_client(demo_mode_fn=lambda: demo)
|
|
||||||
res = client.get("/api/feedback/status")
|
|
||||||
assert res.status_code == 200
|
|
||||||
assert res.json() == {"enabled": False}
|
|
||||||
|
|
||||||
|
|
||||||
# ── POST /api/feedback ────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
def test_submit_returns_503_when_no_token(monkeypatch):
|
|
||||||
monkeypatch.delenv("FORGEJO_API_TOKEN", raising=False)
|
|
||||||
client = _make_client(demo_mode_fn=lambda: False)
|
|
||||||
res = client.post("/api/feedback", json={
|
|
||||||
"title": "Test", "description": "desc", "type": "bug",
|
|
||||||
})
|
|
||||||
assert res.status_code == 503
|
|
||||||
|
|
||||||
|
|
||||||
def test_submit_returns_403_in_demo_mode(monkeypatch):
|
|
||||||
monkeypatch.setenv("FORGEJO_API_TOKEN", "test-token")
|
|
||||||
demo = True
|
|
||||||
client = _make_client(demo_mode_fn=lambda: demo)
|
|
||||||
res = client.post("/api/feedback", json={
|
|
||||||
"title": "Test", "description": "desc", "type": "bug",
|
|
||||||
})
|
|
||||||
assert res.status_code == 403
|
|
||||||
|
|
||||||
|
|
||||||
def test_submit_creates_issue(monkeypatch):
|
|
||||||
monkeypatch.setenv("FORGEJO_API_TOKEN", "test-token")
|
|
||||||
|
|
||||||
label_response = MagicMock()
|
|
||||||
label_response.ok = True
|
|
||||||
label_response.json.return_value = [
|
|
||||||
{"id": 1, "name": "beta-feedback"},
|
|
||||||
{"id": 2, "name": "needs-triage"},
|
|
||||||
{"id": 3, "name": "bug"},
|
|
||||||
]
|
|
||||||
|
|
||||||
issue_response = MagicMock()
|
|
||||||
issue_response.ok = True
|
|
||||||
issue_response.json.return_value = {
|
|
||||||
"number": 7,
|
|
||||||
"html_url": "https://git.opensourcesolarpunk.com/Circuit-Forge/snipe/issues/7",
|
|
||||||
}
|
|
||||||
|
|
||||||
client = _make_client(demo_mode_fn=lambda: False)
|
|
||||||
|
|
||||||
with patch("circuitforge_core.api.feedback.requests.get", return_value=label_response), \
|
|
||||||
patch("circuitforge_core.api.feedback.requests.post", return_value=issue_response):
|
|
||||||
res = client.post("/api/feedback", json={
|
|
||||||
"title": "Listing scores wrong",
|
|
||||||
"description": "Trust score shows 0 when seller has 1000 feedback",
|
|
||||||
"type": "bug",
|
|
||||||
"repro": "1. Search for anything\n2. Check trust score",
|
|
||||||
"tab": "search",
|
|
||||||
})
|
|
||||||
|
|
||||||
assert res.status_code == 200
|
|
||||||
data = res.json()
|
|
||||||
assert data["issue_number"] == 7
|
|
||||||
assert data["issue_url"] == "https://git.opensourcesolarpunk.com/Circuit-Forge/snipe/issues/7"
|
|
||||||
|
|
||||||
|
|
||||||
def test_submit_returns_502_on_forgejo_error(monkeypatch):
|
|
||||||
monkeypatch.setenv("FORGEJO_API_TOKEN", "test-token")
|
|
||||||
|
|
||||||
label_response = MagicMock()
|
|
||||||
label_response.ok = True
|
|
||||||
label_response.json.return_value = [
|
|
||||||
{"id": 1, "name": "beta-feedback"},
|
|
||||||
{"id": 2, "name": "needs-triage"},
|
|
||||||
{"id": 3, "name": "question"},
|
|
||||||
]
|
|
||||||
|
|
||||||
bad_response = MagicMock()
|
|
||||||
bad_response.ok = False
|
|
||||||
bad_response.text = "internal server error"
|
|
||||||
|
|
||||||
client = _make_client(demo_mode_fn=lambda: False)
|
|
||||||
|
|
||||||
with patch("circuitforge_core.api.feedback.requests.get", return_value=label_response), \
|
|
||||||
patch("circuitforge_core.api.feedback.requests.post", return_value=bad_response):
|
|
||||||
res = client.post("/api/feedback", json={
|
|
||||||
"title": "Oops", "description": "desc", "type": "other",
|
|
||||||
})
|
|
||||||
|
|
||||||
assert res.status_code == 502
|
|
||||||
|
|
@ -80,45 +80,6 @@ def test_suspicious_price_flagged_when_price_genuinely_low():
|
||||||
assert "suspicious_price" in result.red_flags_json
|
assert "suspicious_price" in result.red_flags_json
|
||||||
|
|
||||||
|
|
||||||
def test_scratch_dent_flagged_from_title_slash_variant():
|
|
||||||
"""Title containing 'parts/repair' (slash variant, no 'or') must trigger scratch_dent_mentioned."""
|
|
||||||
agg = Aggregator()
|
|
||||||
scores = {k: 15 for k in ["account_age", "feedback_count",
|
|
||||||
"feedback_ratio", "price_vs_market", "category_history"]}
|
|
||||||
result = agg.aggregate(
|
|
||||||
scores, photo_hash_duplicate=False, seller=None,
|
|
||||||
listing_title="Generic Widget XL - Parts/Repair",
|
|
||||||
)
|
|
||||||
assert "scratch_dent_mentioned" in result.red_flags_json
|
|
||||||
|
|
||||||
|
|
||||||
def test_scratch_dent_flagged_from_condition_field():
|
|
||||||
"""eBay formal condition 'for parts or not working' must trigger scratch_dent_mentioned
|
|
||||||
even when the listing title contains no damage keywords."""
|
|
||||||
agg = Aggregator()
|
|
||||||
scores = {k: 15 for k in ["account_age", "feedback_count",
|
|
||||||
"feedback_ratio", "price_vs_market", "category_history"]}
|
|
||||||
result = agg.aggregate(
|
|
||||||
scores, photo_hash_duplicate=False, seller=None,
|
|
||||||
listing_title="Generic Widget XL",
|
|
||||||
listing_condition="for parts or not working",
|
|
||||||
)
|
|
||||||
assert "scratch_dent_mentioned" in result.red_flags_json
|
|
||||||
|
|
||||||
|
|
||||||
def test_scratch_dent_not_flagged_for_clean_listing():
|
|
||||||
"""Clean title + 'New' condition must NOT trigger scratch_dent_mentioned."""
|
|
||||||
agg = Aggregator()
|
|
||||||
scores = {k: 15 for k in ["account_age", "feedback_count",
|
|
||||||
"feedback_ratio", "price_vs_market", "category_history"]}
|
|
||||||
result = agg.aggregate(
|
|
||||||
scores, photo_hash_duplicate=False, seller=None,
|
|
||||||
listing_title="Generic Widget XL",
|
|
||||||
listing_condition="new",
|
|
||||||
)
|
|
||||||
assert "scratch_dent_mentioned" not in result.red_flags_json
|
|
||||||
|
|
||||||
|
|
||||||
def test_new_account_not_flagged_when_age_absent():
|
def test_new_account_not_flagged_when_age_absent():
|
||||||
"""account_age_days=None (scraper tier) must NOT trigger new_account or account_under_30_days."""
|
"""account_age_days=None (scraper tier) must NOT trigger new_account or account_under_30_days."""
|
||||||
agg = Aggregator()
|
agg = Aggregator()
|
||||||
|
|
|
||||||
|
|
@ -8,28 +8,23 @@
|
||||||
<a href="#main-content" class="skip-link">Skip to main content</a>
|
<a href="#main-content" class="skip-link">Skip to main content</a>
|
||||||
<RouterView />
|
<RouterView />
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<!-- Feedback FAB — hidden when FORGEJO_API_TOKEN not configured -->
|
|
||||||
<FeedbackButton :current-view="String(route.name ?? 'unknown')" />
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted } from 'vue'
|
import { onMounted } from 'vue'
|
||||||
import { RouterView, useRoute } from 'vue-router'
|
import { RouterView } from 'vue-router'
|
||||||
import { useMotion } from './composables/useMotion'
|
import { useMotion } from './composables/useMotion'
|
||||||
import { useSnipeMode } from './composables/useSnipeMode'
|
import { useSnipeMode } from './composables/useSnipeMode'
|
||||||
import { useKonamiCode } from './composables/useKonamiCode'
|
import { useKonamiCode } from './composables/useKonamiCode'
|
||||||
import { useSessionStore } from './stores/session'
|
import { useSessionStore } from './stores/session'
|
||||||
import { useBlocklistStore } from './stores/blocklist'
|
import { useBlocklistStore } from './stores/blocklist'
|
||||||
import AppNav from './components/AppNav.vue'
|
import AppNav from './components/AppNav.vue'
|
||||||
import FeedbackButton from './components/FeedbackButton.vue'
|
|
||||||
|
|
||||||
const motion = useMotion()
|
const motion = useMotion()
|
||||||
const { activate, restore } = useSnipeMode()
|
const { activate, restore } = useSnipeMode()
|
||||||
const session = useSessionStore()
|
const session = useSessionStore()
|
||||||
const blocklistStore = useBlocklistStore()
|
const blocklistStore = useBlocklistStore()
|
||||||
const route = useRoute()
|
|
||||||
|
|
||||||
useKonamiCode(activate)
|
useKonamiCode(activate)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,413 +0,0 @@
|
||||||
<template>
|
|
||||||
<!-- Floating trigger button -->
|
|
||||||
<button
|
|
||||||
v-if="enabled"
|
|
||||||
class="feedback-fab"
|
|
||||||
@click="open = true"
|
|
||||||
aria-label="Send feedback or report a bug"
|
|
||||||
title="Send feedback or report a bug"
|
|
||||||
>
|
|
||||||
<svg class="feedback-fab-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
||||||
<path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"/>
|
|
||||||
</svg>
|
|
||||||
<span class="feedback-fab-label">Feedback</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<!-- Modal — teleported to body to avoid z-index / overflow clipping -->
|
|
||||||
<Teleport to="body">
|
|
||||||
<Transition name="modal-fade">
|
|
||||||
<div v-if="open" class="feedback-overlay" @click.self="close">
|
|
||||||
<div class="feedback-modal" role="dialog" aria-modal="true" aria-label="Send Feedback">
|
|
||||||
|
|
||||||
<!-- Header -->
|
|
||||||
<div class="feedback-header">
|
|
||||||
<h2 class="feedback-title">{{ step === 1 ? "What's on your mind?" : "Review & submit" }}</h2>
|
|
||||||
<button class="feedback-close" @click="close" aria-label="Close">
|
|
||||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
|
|
||||||
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- ── Step 1: Form ─────────────────────────────────────────── -->
|
|
||||||
<div v-if="step === 1" class="feedback-body">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label">Type</label>
|
|
||||||
<div class="filter-chip-row">
|
|
||||||
<button
|
|
||||||
v-for="t in types"
|
|
||||||
:key="t.value"
|
|
||||||
:class="['btn-chip', { active: form.type === t.value }]"
|
|
||||||
@click="form.type = t.value"
|
|
||||||
type="button"
|
|
||||||
>{{ t.label }}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label">Title <span class="form-required">*</span></label>
|
|
||||||
<input
|
|
||||||
v-model="form.title"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
placeholder="Short summary of the issue or idea"
|
|
||||||
maxlength="120"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label">Description <span class="form-required">*</span></label>
|
|
||||||
<textarea
|
|
||||||
v-model="form.description"
|
|
||||||
class="form-input feedback-textarea"
|
|
||||||
placeholder="Describe what happened or what you'd like to see…"
|
|
||||||
rows="4"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="form.type === 'bug'" class="form-group">
|
|
||||||
<label class="form-label">Reproduction steps</label>
|
|
||||||
<textarea
|
|
||||||
v-model="form.repro"
|
|
||||||
class="form-input feedback-textarea"
|
|
||||||
placeholder="1. Go to… 2. Tap… 3. See error"
|
|
||||||
rows="3"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p v-if="stepError" class="feedback-error">{{ stepError }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- ── Step 2: Attribution + confirm ──────────────────────────── -->
|
|
||||||
<div v-if="step === 2" class="feedback-body">
|
|
||||||
<div class="feedback-summary card">
|
|
||||||
<div class="feedback-summary-row">
|
|
||||||
<span class="text-muted text-sm">Type</span>
|
|
||||||
<span class="text-sm font-semibold">{{ typeLabel }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="feedback-summary-row">
|
|
||||||
<span class="text-muted text-sm">Title</span>
|
|
||||||
<span class="text-sm">{{ form.title }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="feedback-summary-row">
|
|
||||||
<span class="text-muted text-sm">Description</span>
|
|
||||||
<span class="text-sm feedback-summary-desc">{{ form.description }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group mt-md">
|
|
||||||
<label class="form-label">Attribution (optional)</label>
|
|
||||||
<input
|
|
||||||
v-model="form.submitter"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
placeholder="Your name <email@example.com>"
|
|
||||||
/>
|
|
||||||
<p class="text-muted text-xs mt-xs">Include your name and email in the issue if you'd like a response. Never required.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p v-if="submitError" class="feedback-error">{{ submitError }}</p>
|
|
||||||
<div v-if="submitted" class="feedback-success">
|
|
||||||
Issue filed! <a :href="issueUrl" target="_blank" rel="noopener" class="feedback-link">View on Forgejo →</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Footer nav -->
|
|
||||||
<div class="feedback-footer">
|
|
||||||
<button v-if="step === 2 && !submitted" class="btn btn-ghost" @click="step = 1" :disabled="loading">← Back</button>
|
|
||||||
<button v-if="!submitted" class="btn btn-ghost" @click="close" :disabled="loading">Cancel</button>
|
|
||||||
<button
|
|
||||||
v-if="step === 1"
|
|
||||||
class="btn btn-primary"
|
|
||||||
@click="nextStep"
|
|
||||||
>Next →</button>
|
|
||||||
<button
|
|
||||||
v-if="step === 2 && !submitted"
|
|
||||||
class="btn btn-primary"
|
|
||||||
@click="submit"
|
|
||||||
:disabled="loading"
|
|
||||||
>{{ loading ? 'Filing…' : 'Submit' }}</button>
|
|
||||||
<button v-if="submitted" class="btn btn-primary" @click="close">Done</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Transition>
|
|
||||||
</Teleport>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { ref, computed, onMounted } from 'vue'
|
|
||||||
|
|
||||||
const props = defineProps<{ currentView?: string }>()
|
|
||||||
|
|
||||||
// Probe once on mount — hidden until confirmed enabled so button never flashes
|
|
||||||
const enabled = ref(false)
|
|
||||||
onMounted(async () => {
|
|
||||||
try {
|
|
||||||
const res = await fetch('/api/feedback/status')
|
|
||||||
if (res.ok) {
|
|
||||||
const data = await res.json()
|
|
||||||
enabled.value = data.enabled === true
|
|
||||||
}
|
|
||||||
} catch { /* network error — stay hidden */ }
|
|
||||||
})
|
|
||||||
|
|
||||||
const open = ref(false)
|
|
||||||
const step = ref(1)
|
|
||||||
const loading = ref(false)
|
|
||||||
const stepError = ref('')
|
|
||||||
const submitError = ref('')
|
|
||||||
const submitted = ref(false)
|
|
||||||
const issueUrl = ref('')
|
|
||||||
|
|
||||||
const types: { value: 'bug' | 'feature' | 'other'; label: string }[] = [
|
|
||||||
{ value: 'bug', label: '🐛 Bug' },
|
|
||||||
{ value: 'feature', label: '✨ Feature request' },
|
|
||||||
{ value: 'other', label: '💬 Other' },
|
|
||||||
]
|
|
||||||
|
|
||||||
const form = ref({
|
|
||||||
type: 'bug' as 'bug' | 'feature' | 'other',
|
|
||||||
title: '',
|
|
||||||
description: '',
|
|
||||||
repro: '',
|
|
||||||
submitter: '',
|
|
||||||
})
|
|
||||||
|
|
||||||
const typeLabel = computed(() => types.find(t => t.value === form.value.type)?.label ?? '')
|
|
||||||
|
|
||||||
function close() {
|
|
||||||
open.value = false
|
|
||||||
// reset after transition
|
|
||||||
setTimeout(reset, 300)
|
|
||||||
}
|
|
||||||
|
|
||||||
function reset() {
|
|
||||||
step.value = 1
|
|
||||||
loading.value = false
|
|
||||||
stepError.value = ''
|
|
||||||
submitError.value = ''
|
|
||||||
submitted.value = false
|
|
||||||
issueUrl.value = ''
|
|
||||||
form.value = { type: 'bug', title: '', description: '', repro: '', submitter: '' }
|
|
||||||
}
|
|
||||||
|
|
||||||
function nextStep() {
|
|
||||||
stepError.value = ''
|
|
||||||
if (!form.value.title.trim() || !form.value.description.trim()) {
|
|
||||||
stepError.value = 'Please fill in both Title and Description.'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
step.value = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submit() {
|
|
||||||
loading.value = true
|
|
||||||
submitError.value = ''
|
|
||||||
try {
|
|
||||||
const res = await fetch('/api/feedback', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({
|
|
||||||
title: form.value.title.trim(),
|
|
||||||
description: form.value.description.trim(),
|
|
||||||
type: form.value.type,
|
|
||||||
repro: form.value.repro.trim(),
|
|
||||||
view: props.currentView ?? 'unknown',
|
|
||||||
submitter: form.value.submitter.trim(),
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
if (!res.ok) {
|
|
||||||
const err = await res.json().catch(() => ({ detail: res.statusText }))
|
|
||||||
submitError.value = err.detail ?? 'Submission failed.'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const data = await res.json()
|
|
||||||
issueUrl.value = data.issue_url
|
|
||||||
submitted.value = true
|
|
||||||
} catch (e) {
|
|
||||||
submitError.value = 'Network error — please try again.'
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
/* ── Floating action button ─────────────────────────────────────────── */
|
|
||||||
.feedback-fab {
|
|
||||||
position: fixed;
|
|
||||||
right: var(--spacing-md);
|
|
||||||
bottom: calc(68px + var(--spacing-md)); /* above mobile bottom nav */
|
|
||||||
z-index: 190;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--spacing-xs);
|
|
||||||
padding: 9px var(--spacing-md);
|
|
||||||
background: var(--color-bg-elevated);
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 999px;
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
font-size: var(--font-size-sm);
|
|
||||||
font-family: var(--font-body);
|
|
||||||
font-weight: 500;
|
|
||||||
cursor: pointer;
|
|
||||||
box-shadow: var(--shadow-md);
|
|
||||||
transition: background 0.15s, color 0.15s, box-shadow 0.15s, border-color 0.15s;
|
|
||||||
}
|
|
||||||
.feedback-fab:hover {
|
|
||||||
background: var(--color-bg-card);
|
|
||||||
color: var(--color-text-primary);
|
|
||||||
border-color: var(--color-border-focus);
|
|
||||||
box-shadow: var(--shadow-lg);
|
|
||||||
}
|
|
||||||
.feedback-fab-icon { width: 15px; height: 15px; flex-shrink: 0; }
|
|
||||||
.feedback-fab-label { white-space: nowrap; }
|
|
||||||
|
|
||||||
/* On desktop, bottom nav is gone — drop to standard corner */
|
|
||||||
@media (min-width: 769px) {
|
|
||||||
.feedback-fab {
|
|
||||||
bottom: var(--spacing-lg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Overlay ──────────────────────────────────────────────────────────── */
|
|
||||||
.feedback-overlay {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
background: rgba(0, 0, 0, 0.55);
|
|
||||||
z-index: 1000;
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-end;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 500px) {
|
|
||||||
.feedback-overlay {
|
|
||||||
align-items: center;
|
|
||||||
padding: var(--spacing-md);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Modal ────────────────────────────────────────────────────────────── */
|
|
||||||
.feedback-modal {
|
|
||||||
background: var(--color-bg-elevated);
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: var(--radius-lg) var(--radius-lg) 0 0;
|
|
||||||
width: 100%;
|
|
||||||
max-height: 90vh;
|
|
||||||
overflow-y: auto;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
box-shadow: var(--shadow-xl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 500px) {
|
|
||||||
.feedback-modal {
|
|
||||||
border-radius: var(--radius-lg);
|
|
||||||
width: 100%;
|
|
||||||
max-width: 520px;
|
|
||||||
max-height: 85vh;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.feedback-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: var(--spacing-md) var(--spacing-md) var(--spacing-sm);
|
|
||||||
border-bottom: 1px solid var(--color-border);
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
.feedback-title {
|
|
||||||
font-family: var(--font-display);
|
|
||||||
font-size: var(--font-size-lg);
|
|
||||||
font-weight: 600;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
.feedback-close {
|
|
||||||
background: transparent;
|
|
||||||
border: none;
|
|
||||||
color: var(--color-text-muted);
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 4px;
|
|
||||||
border-radius: var(--radius-sm);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
.feedback-close:hover { color: var(--color-text-primary); }
|
|
||||||
|
|
||||||
.feedback-body {
|
|
||||||
padding: var(--spacing-md);
|
|
||||||
flex: 1;
|
|
||||||
overflow-y: auto;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--spacing-md);
|
|
||||||
}
|
|
||||||
|
|
||||||
.feedback-footer {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: var(--spacing-sm);
|
|
||||||
padding: var(--spacing-sm) var(--spacing-md);
|
|
||||||
border-top: 1px solid var(--color-border);
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.feedback-textarea {
|
|
||||||
resize: vertical;
|
|
||||||
min-height: 80px;
|
|
||||||
font-family: var(--font-body);
|
|
||||||
font-size: var(--font-size-sm);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-required { color: var(--color-error); margin-left: 2px; }
|
|
||||||
|
|
||||||
.feedback-error {
|
|
||||||
color: var(--color-error);
|
|
||||||
font-size: var(--font-size-sm);
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.feedback-success {
|
|
||||||
color: var(--color-success);
|
|
||||||
font-size: var(--font-size-sm);
|
|
||||||
padding: var(--spacing-sm) var(--spacing-md);
|
|
||||||
background: var(--color-success-bg);
|
|
||||||
border: 1px solid var(--color-success-border);
|
|
||||||
border-radius: var(--radius-md);
|
|
||||||
}
|
|
||||||
.feedback-link { color: var(--color-success); font-weight: 600; text-decoration: underline; }
|
|
||||||
|
|
||||||
/* Summary card (step 2) */
|
|
||||||
.feedback-summary {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--spacing-xs);
|
|
||||||
padding: var(--spacing-sm) var(--spacing-md);
|
|
||||||
background: var(--color-bg-secondary);
|
|
||||||
border-radius: var(--radius-md);
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
}
|
|
||||||
.feedback-summary-row {
|
|
||||||
display: flex;
|
|
||||||
gap: var(--spacing-md);
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
.feedback-summary-row > :first-child { min-width: 72px; flex-shrink: 0; }
|
|
||||||
.feedback-summary-desc {
|
|
||||||
white-space: pre-wrap;
|
|
||||||
word-break: break-word;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mt-md { margin-top: var(--spacing-md); }
|
|
||||||
.mt-xs { margin-top: var(--spacing-xs); }
|
|
||||||
|
|
||||||
/* Transition */
|
|
||||||
.modal-fade-enter-active, .modal-fade-leave-active { transition: opacity 0.2s ease; }
|
|
||||||
.modal-fade-enter-from, .modal-fade-leave-to { opacity: 0; }
|
|
||||||
</style>
|
|
||||||
|
|
@ -120,7 +120,6 @@ export const useSearchStore = defineStore('search', () => {
|
||||||
)
|
)
|
||||||
const marketPrice = ref<number | null>(cached?.marketPrice ?? null)
|
const marketPrice = ref<number | null>(cached?.marketPrice ?? null)
|
||||||
const adapterUsed = ref<'api' | 'scraper' | null>(cached?.adapterUsed ?? null)
|
const adapterUsed = ref<'api' | 'scraper' | null>(cached?.adapterUsed ?? null)
|
||||||
const affiliateActive = ref<boolean>(false)
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const error = ref<string | null>(null)
|
const error = ref<string | null>(null)
|
||||||
|
|
||||||
|
|
@ -165,7 +164,6 @@ export const useSearchStore = defineStore('search', () => {
|
||||||
sellers: Record<string, Seller>
|
sellers: Record<string, Seller>
|
||||||
market_price: number | null
|
market_price: number | null
|
||||||
adapter_used: 'api' | 'scraper'
|
adapter_used: 'api' | 'scraper'
|
||||||
affiliate_active: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
results.value = data.listings ?? []
|
results.value = data.listings ?? []
|
||||||
|
|
@ -173,7 +171,6 @@ export const useSearchStore = defineStore('search', () => {
|
||||||
sellers.value = new Map(Object.entries(data.sellers ?? {}))
|
sellers.value = new Map(Object.entries(data.sellers ?? {}))
|
||||||
marketPrice.value = data.market_price ?? null
|
marketPrice.value = data.market_price ?? null
|
||||||
adapterUsed.value = data.adapter_used ?? null
|
adapterUsed.value = data.adapter_used ?? null
|
||||||
affiliateActive.value = data.affiliate_active ?? false
|
|
||||||
saveCache({
|
saveCache({
|
||||||
query: q,
|
query: q,
|
||||||
results: results.value,
|
results: results.value,
|
||||||
|
|
@ -228,7 +225,6 @@ export const useSearchStore = defineStore('search', () => {
|
||||||
sellers,
|
sellers,
|
||||||
marketPrice,
|
marketPrice,
|
||||||
adapterUsed,
|
adapterUsed,
|
||||||
affiliateActive,
|
|
||||||
loading,
|
loading,
|
||||||
error,
|
error,
|
||||||
search,
|
search,
|
||||||
|
|
|
||||||
|
|
@ -91,17 +91,6 @@
|
||||||
aria-label="Search filters"
|
aria-label="Search filters"
|
||||||
>
|
>
|
||||||
|
|
||||||
<!-- Clear all filters — only shown when at least one filter is active -->
|
|
||||||
<button
|
|
||||||
v-if="activeFilterCount > 0"
|
|
||||||
type="button"
|
|
||||||
class="filter-clear-btn"
|
|
||||||
@click="resetFilters"
|
|
||||||
aria-label="Clear all filters"
|
|
||||||
>
|
|
||||||
✕ Clear filters ({{ activeFilterCount }})
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<!-- ── eBay Search Parameters ─────────────────────────────────────── -->
|
<!-- ── eBay Search Parameters ─────────────────────────────────────── -->
|
||||||
<!-- These are sent to eBay. Changes require a new search to take effect. -->
|
<!-- These are sent to eBay. Changes require a new search to take effect. -->
|
||||||
<h2 class="filter-section-heading filter-section-heading--search">
|
<h2 class="filter-section-heading filter-section-heading--search">
|
||||||
|
|
@ -307,9 +296,6 @@
|
||||||
<span v-if="hiddenCount > 0" class="results-hidden">
|
<span v-if="hiddenCount > 0" class="results-hidden">
|
||||||
· {{ hiddenCount }} hidden by filters
|
· {{ hiddenCount }} hidden by filters
|
||||||
</span>
|
</span>
|
||||||
<span v-if="store.affiliateActive" class="affiliate-disclosure">
|
|
||||||
· Links may include an affiliate code
|
|
||||||
</span>
|
|
||||||
</p>
|
</p>
|
||||||
<div class="toolbar-actions">
|
<div class="toolbar-actions">
|
||||||
<label for="sort-select" class="sr-only">Sort by</label>
|
<label for="sort-select" class="sr-only">Sort by</label>
|
||||||
|
|
@ -416,7 +402,7 @@ onMounted(() => {
|
||||||
|
|
||||||
// ── Filters ──────────────────────────────────────────────────────────────────
|
// ── Filters ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const DEFAULT_FILTERS: SearchFilters = {
|
const filters = reactive<SearchFilters>({
|
||||||
minTrustScore: 0,
|
minTrustScore: 0,
|
||||||
minPrice: undefined,
|
minPrice: undefined,
|
||||||
maxPrice: undefined,
|
maxPrice: undefined,
|
||||||
|
|
@ -435,13 +421,7 @@ const DEFAULT_FILTERS: SearchFilters = {
|
||||||
mustExclude: '',
|
mustExclude: '',
|
||||||
categoryId: '',
|
categoryId: '',
|
||||||
adapter: 'auto' as 'auto' | 'api' | 'scraper',
|
adapter: 'auto' as 'auto' | 'api' | 'scraper',
|
||||||
}
|
})
|
||||||
|
|
||||||
const filters = reactive<SearchFilters>({ ...DEFAULT_FILTERS })
|
|
||||||
|
|
||||||
function resetFilters() {
|
|
||||||
Object.assign(filters, DEFAULT_FILTERS)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse comma-separated keyword strings into trimmed, lowercase, non-empty term arrays
|
// Parse comma-separated keyword strings into trimmed, lowercase, non-empty term arrays
|
||||||
const parsedMustInclude = computed(() =>
|
const parsedMustInclude = computed(() =>
|
||||||
|
|
@ -784,27 +764,6 @@ async function onSearch() {
|
||||||
margin-bottom: var(--space-2);
|
margin-bottom: var(--space-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear all filters button */
|
|
||||||
.filter-clear-btn {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-1);
|
|
||||||
width: 100%;
|
|
||||||
padding: var(--space-1) var(--space-2);
|
|
||||||
margin-bottom: var(--space-2);
|
|
||||||
background: color-mix(in srgb, var(--color-red, #ef4444) 12%, transparent);
|
|
||||||
color: var(--color-red, #ef4444);
|
|
||||||
border: 1px solid color-mix(in srgb, var(--color-red, #ef4444) 30%, transparent);
|
|
||||||
border-radius: var(--radius-sm);
|
|
||||||
font-size: 0.75rem;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background 0.15s, color 0.15s;
|
|
||||||
}
|
|
||||||
.filter-clear-btn:hover {
|
|
||||||
background: color-mix(in srgb, var(--color-red, #ef4444) 22%, transparent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Section headings that separate eBay Search params from local filters */
|
/* Section headings that separate eBay Search params from local filters */
|
||||||
.filter-section-heading {
|
.filter-section-heading {
|
||||||
font-size: 0.6875rem;
|
font-size: 0.6875rem;
|
||||||
|
|
@ -1070,7 +1029,6 @@ async function onSearch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
.results-hidden { color: var(--color-warning); }
|
.results-hidden { color: var(--color-warning); }
|
||||||
.affiliate-disclosure { color: var(--color-text-muted, #8b949e); font-size: 0.8em; }
|
|
||||||
|
|
||||||
.toolbar-actions {
|
.toolbar-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue