# Multi-Platform Tools Plan: Bluesky, Reddit, LinkedIn, X/Twitter
# Mimics tools/facebook: same structure, styling, FTP upload pattern, API flow.
# No workarounds; confirmation of success in chat after validation.

name: multi-platform-tools
description: Add Bluesky, Reddit, LinkedIn, and X/Twitter tools mirroring Facebook tool structure, styling, and FTP upload.
version: "1.0"

scope:
  - tools/bluesky/
  - tools/reddit/
  - tools/linkedin/
  - tools/twitter/
  - ftp/upload_tools_bluesky.py
  - ftp/upload_tools_reddit.py
  - ftp/upload_tools_linkedin.py
  - ftp/upload_tools_twitter.py
  - ftp/state/ (state files per platform)

reference:
  - tools/facebook/ (structure, styling, auth, storage, api pattern)
  - ftp/upload_tools_facebook.py
  - ftp/tool_upload_common.py

structure_per_platform:
  root_files:
    - index.php       # Dashboard (setup, request access, usage, Open Console)
    - api.php         # JSON API (Bearer auth; status, platform actions)
    - setup.php       # Grant flow: ?key= -> redirect to platform OAuth
    - callback.php    # OAuth callback: exchange code, save token, redirect
    - grant_success.php # Post-OAuth for granted user: show token, link to widgets
    - widgets.php     # Console: token gate, API Token section, Admin (if admin), User, widgets
    - .htaccess       # Rewrite callback, api; deny .json/.log
  includes:
    - config.php      # DATA_DIR, file paths, platform OAuth/API constants
    - storage.php     # Same as Facebook (credentials, token, usage, grants, allowed_tokens, revoked, user data)
    - auth.php        # Same as Facebook (generate_api_token, validate, get_bearer_token, require_auth)
    - mail.php        # Same as Facebook (load_mail_config, send_tool_mail; from_name per platform)
    - bluesky.php / reddit.php / linkedin.php / twitter.php  # Platform API helpers (OAuth URL, token exchange, API calls)
  data:
    - .htaccess       # Deny all
    - (runtime: credentials.enc, token.json, usage.json, etc.)
  widgets:
    - 01_status.php    # Health / status widget
    - 02_*.php        # Platform-specific (e.g. accounts, post, message equivalent)

styling:
  - Reuse Facebook CSS variables: --bg, --surface, --border, --text, --accent
  - Platform accent colors: Bluesky #0085ff, Reddit #ff4500, LinkedIn #0a66c2, X/Twitter #1da1f2
  - Same layout: app-header, .wrap, .card, .modal-overlay, .stats-grid, .alert-*

ftp_upload:
  - Script: ftp/upload_tools_<platform>.py
  - REMOTE_BASE: tools/bluesky | tools/reddit | tools/linkedin | tools/twitter
  - TOOL_STATE_NAME: upload_tools_<platform>
  - Same flow: syntax check -> lint (optional) -> upload changed -> verify curl (base + api.php) -> save state, write changed log

platform_oauth_apis:
  Bluesky:
    auth: App password or OAuth (AT Protocol); placeholder endpoints until configured
  Reddit:
    auth: OAuth2 (script or installed app); redirect_uri, client_id, client_secret
  LinkedIn:
    auth: OAuth2; authorize + token endpoints, scopes
  X_Twitter:
    auth: OAuth 2.0 PKCE; authorize + token endpoints

testing:
  - Run php -l on every .php file in each tool directory (syntax check)
  - Run python -m ftp.upload_tools_<platform> --skip-verify from repo root (no deploy required for structure test)
  - Confirm: no leftover test files; no null coalescing operators; isset used for $_GET/$_POST

validation:
  - All PHP files pass php -l
  - Each upload script runs without FileNotFoundError (tools/<platform> exists)
  - Folder structure matches plan; styling tokens (accent, brand name) swapped per platform

success_criteria:
  - Four tool directories created with full file set
  - Four FTP upload scripts created and runnable
  - PHP syntax valid on all new files
  - Plan YAML committed; confirmation of success stated in chat
