Skip to content

Feature/experimental#559

Draft
dgs-one wants to merge 164 commits into
masterfrom
feature/experimental
Draft

Feature/experimental#559
dgs-one wants to merge 164 commits into
masterfrom
feature/experimental

Conversation

@dgs-one
Copy link
Copy Markdown
Collaborator

@dgs-one dgs-one commented May 14, 2026

No description provided.

This major feature release adds an AI assistant capable of automatically
finding and extracting geographical coordinates from post content and titles.

Core Additions:
- Implemented robust AI adapters for Google Gemini (2.5 Flash), OpenAI (GPT-4o), and DeepSeek.
- Added strict Prompt Engineering directives (API Level) to enforce structured JSON output and reduce hallucinations (temperature: 0.1).
- Added an intermediate Approval Modal in the Gutenberg Editor to review AI suggestions (including the source 'quote') before saving metadata.
- Built an 'AI Prompt Engineer Assistant' UI inside Settings, allowing users to generate optimized prompts through an LLM.
- Built a 'Validate Custom Prompt' tool to simulate AI behavior safely.
- Added an exclusive 'AI Debug Logs' WP List Table to track raw inputs, outputs, and errors for easy debugging.

UX/UI Improvements:
- Redesigned the JEO Settings panel with a modern 1-second Skeleton Loader and FOUC prevention.
- Added dynamic 'gettext' hooks to seamlessly translate the new AI interface to pt_BR without recompiling .mo files.
- Updated menu initialization to prevent 404 errors by safely redirecting the parent slug.

Release:
- Updated plugin version to 3.5.0 across all main files.
- Added 'build.sh' deployment script to safely package the plugin for production environments.
…hance Dashboard camera

Detailed changes:
- Fixed PHP 7.4 'FILTER_VALIDATE_BOOL' undefined constant warning.
- Registered '_ai_quote' in register_post_meta and allowed 'additionalProperties' to fix WP REST data persistence failures.
- Optimized 'saveAiLocations' in React to clean dirty JSON keys before DB submission.
- Added 'X-WP-Nonce' to Dashboard fetch requests to fix 401 Unauthorized errors.
- Refactored Dashboard Header with full-width collapsible UI and Bezier animations.
- Implemented cinematic 'fitBounds' camera transition in Dashboard to auto-frame all global pins.
- Corrected API Key Test endpoint to use mock JSON to bypass internal georeference validators.
- Standardized 'maplibregl' as the default rendering engine for new installations.
…policies

Core Changes:
- Updated version to 3.5.1-experimental across all components.
- Launched 'Knowledge Base' tab with 10 embedded Brazilian Data Dictionaries.
- Implemented Unified Dictionary Visualizer (Modal) with sticky headers and terminal-style JSON preview.
- Added secure Dictionary Download feature via admin-post.
- Implemented cinematic 'fitBounds' camera transition for the JEO Dashboard.
- Isolated Settings navigation JS to prevent URL hash leaks from modals (#tab-undefined fix).

Security & Lifecycle:
- Added 'uninstall.php' for complete settings cleanup upon deletion.
- Implemented automatic AI API Key clearing during plugin deactivation to protect credentials.
- Added a JS confirmation prompt on the WP Plugins page to warn about deactivation effects.
- Guaranteed preservation of post geolocation metadata during deactivation/uninstall.

Data Dictionaries:
- Embedded 10 curated datasets including Biomes, Indigenous Territories, Quilombos, Extractive Reserves, and more.
This commit establishes the definitive architectural documentation for JEO's AI Ecosystem.

Key Engineering Insights documented:
- Strict WP REST Schema metadata validation for '_ai_quote' persistence.
- PHP 7.4 legacy compatibility fix for FILTER_VALIDATE_BOOLEAN.
- Aggressive JSON Parser with Colbracket-hunting logic for LLM resilience.
- Professional Menu Hierarchy locking and the Welcome Page dynamic documentation engine.
- Staggered Drop Animation and fitBounds cinematic transitions for the Dashboard.
- Strict security policies for API Key clearing on deactivation vs full uninstall cleanup.
This commit introduces:
- Google Maps API Key setting in General Settings.
- Support for selecting Google Maps as the rendering library.
- Native Google Maps rendering on the JEO Dashboard with DROP animation and popups.
- Dynamic enqueuing of the Google Maps JS API script.
- Data normalization for consistent lat/lng handling across all renderers.
This commit:
- Implements the GoogleMaps geocoder class.
- Supports address geocoding and reverse geocoding via Google Maps API.
- Registers Google Maps as a core geocoder option in JEO.
- Updates documentation to reflect Google Maps geocoding support.
…ders

- Added Google Maps and Mapbox as selectable Geocoders.
- Implemented data normalization for Google Maps geocoding results.
- Updated documentation (GEMINI.md and README.md) to reflect full multi-engine capabilities.
- Standardized versioning to 3.5.3-experimental.
…er support

This commit consolidates all recent advancements in mapping infrastructure and user experience.

Key Improvements:
- Geodata Infrastructure: Added official support for Google Maps and Mapbox as Geocoder providers, complementing Nominatim.
- Renderers: Implemented native Google Maps JS API support for the JEO Dashboard, including DROP animations and InfoWindows.
- Normalization: Ensured strict coordinate handling (Numbers vs Strings) across all mapping engines to prevent silent failures.
- Versioning: Standardized all project files and the build script to v3.5.3-experimental.
- Documentation: Updated the Master Blueprint (GEMINI.md) with detailed architectural insights on REST Schema validation, RAG Lightweight engine, and professional menu hierarchy.
This commit unifies the JEO admin experience into a professional product hierarchy:
- Reordered JEO menu: Welcome (Default) -> Experimental (Dashboard) -> Maps -> Layers -> Storymaps -> Settings -> AI Debug Logs.
- Implemented a dynamic 'Welcome' page that renders 'README*.md' files as documentation tabs.
- Created 'README_BR.md' with a full Portuguese translation of the project guide.
- Added dynamic 'gettext' translations for all sidebar menu items to ensure a localized PT-BR experience.
- Fixed a potential Fatal Error caused by CPT registration priority conflicts.
- Updated 'GEMINI.md' to the v3.5.3-experimental Master Blueprint, documenting the full architectural state.
- Standardized versioning across all core files and build scripts.
- Refatora interface de Configurações 'Enabled Post Types' removendo input texto por matriz dinâmica de checkboxes detectando Custom Post Types registrados (ACF, Pods).
- Refatora acoplamento rígido de metadados em 'class-geocode-handler.php', substituindo registro isolado em 'post' pela iteração de post_types dinâmicos.
- Desloca gancho 'init' de geolocalização e schema IA para prioridade 99, garantindo resiliência de leitura para CPTs de terceiros.
- Atualiza CHANGELOGs, GEMINI.md e aumenta versão para 3.5.4-experimental.
…ados

Corrige bug em que Custom Post Types (como ACF ou Pods) que não possuem suporte
nativo a 'custom-fields' falhavam ao salvar as localizações no banco (sem erros).
A REST API do WordPress descarta silenciosamente o payload 'meta' se o object
subtype não tiver essa flag habilitada.
- Detalha suporte forçado de `custom-fields` no GEMINI.md.
- Adiciona entradas da v3.5.4 no changelog dos arquivos README.txt (src e trunk).
- Enforce PHP 8.2 minimum requirement for JEO activation.
- Integrate Composer via build and autoloading logic.
- Add Neuron AI to composer.json dependencies.
- Update Docker environment to Node 20 and PHP 8.2 Apache.
- Introduce `setup.sh` for dynamic local development testing (--test-env).
- Bump version to 3.6.0-experimental.
- Replace hardcoded OpenAI/Gemini/Deepseek adapters with Neuron AI Agent.
- Create Universal `Neuron_Adapter` to centralize Georeference logic.
- Expand `Neuron_Agent` to natively support 10 LLM providers via switch.
- Establish `AI_Logger` CPT to permanently store token usage data (`input_tokens`, `output_tokens`) for a robust Cost Dashboard.
- Deprecate and remove legacy manual API adapter files.
- Overhaul ai-logs-page.php to query and render the new jeo-ai-log CPT.
- Replace manual log view with professional Dashboard (In/Out Tokens).
- Add robust HTML dialog modals to display sanitized JSON payload data.
- Refactor settings-page.php and settings-page.js to dynamically load configs for all 10 providers.
- Add specific endpoint configuration for locally hosted Ollama API.
- Update docker-compose to a modern structure with healthchecks for MariaDB.
- Fix redirection bug by injecting dynamic WP_HOME and WP_SITEURL via WORDPRESS_CONFIG_EXTRA.
- Update installation entrypoint to use localhost:8072 as the default core URL.
- Standardize vendor volume mapping to mirror production layout.
hacklab-dgs and others added 30 commits May 12, 2026 10:54
- Create uninstall confirmation page (admin.php?page=jeo-uninstall-confirm)
  that lists all data to be removed: settings, AI logs, post meta,
  transient caches, cron hooks, and RAG vector store files.
- Replace default 'Delete' plugin link with link to confirmation page
  via plugin_action_links filter.
- Require checkbox acknowledgment + JS confirm before executing deletion.
- Expand uninstall.php with detailed comments and explicit cleanup of
  all _geocode_* index meta fields.
- Update .architecture/deployment/README.md and AGENTS.md
- Create .docker/docker-compose.yml with WordPress (php8.2-apache)
  and MariaDB (10.11) containers.
- Use personalized JEO container names (jeo-dev-wordpress,
  jeo-dev-mariadb) and isolated network (jeo-dev-network)
  to avoid conflicts with other projects.
- Map src/ as a live volume into wp-content/plugins/jeo.
- Add bash .docker/start.sh helper script.
- Add .docker/ to .gitignore so environment data is not committed.
- Document usage in AGENTS.md and .architecture/build/README.md.
- get_active_adapter() now returns WP_Error early when the active
  provider has no API key configured, instead of constructing a
  Neuron_Adapter with an empty key.
- api_georeference() wraps the entire flow in try/catch (Throwable)
  to prevent fatal errors from bubbling up to WordPress.
- Neuron_Adapter::georeference() catches Throwable instead of
  Exception to cover TypeErrors and ValueErrors from Neuron providers.
- Update all callers (bulk processor, AI test, prompt generator,
  prompt validator) to check is_wp_error() before using the adapter.
- Returns friendly user-facing messages like:
  'No API key configured for Google Gemini. Please add it in
   JEO → AI Settings.'
The shell environment had NODE_ENV=development set, which caused
wp-scripts build to generate unminified bundles (10MB+ instead of
~1.2MB). The build script now explicitly sets NODE_ENV=production
to ensure consistent production builds regardless of shell state.
The AI settings tabs (Provider, Knowledge, Bulk, Embedded) were
permanently stuck on the skeleton loader because no JavaScript was
hiding it and revealing the actual tab content. Added a DOMContentLoaded
handler that hides #jeo-skeleton and shows .jeo-tab-content-wrapper.
…ols and fullscreen UX

Add three major improvements to the AI georeferencing settings:

1. Taxonomy inclusion for georeferencing
   - New setting 'ai_include_taxonomies' with checkbox in Provider tab
   - PHP logic appends categories/tags to AI content when enabled
   - Method get_post_taxonomy_context() fetches terms cleanly

2. Fullscreen textarea UX for both prompt editors
   - AI Prompt Engineer Assistant (#jeo-ai-chat-input) and System Prompt
     Configuration (#ai_system_prompt) both support fullscreen expand/collapse
   - Min-height increased to 50vh for better writing experience
   - Fixed-position 'Back' button appears only in fullscreen mode
   - Independent toggle handlers with e.stopPropagation() to prevent conflicts
   - Browser state restoration safeguard: .hide() on DOM ready

3. Georeferencing Calibration controls
   - Location Granularity (broad / balanced / fine)
   - Minimum Confidence slider (0-100)
   - Prioritize Title Mentions slider (0-100)
   - Prompt Token Budget slider (1,000-100,000) with live quality thermometer
   - Each control has an individual 'Use' toggle
   - Disabled controls show reduced opacity and are excluded from API payload
   - Unlimited token warning appears when Token Budget toggle is off
   - All preferences persist via WordPress Settings API

PHP backend changes:
   - api_chat_prompt_generator() receives calibration params and injects
     conditional rules into the meta-prompt based on active toggles
   - Settings defaults, sanitization, and checkbox handling added to
     class-settings.php

JS changes:
   - Calibration values sent to REST endpoint only when toggle is active
   - Live thermometer updates with color-coded quality labels
   - Formatted number display for token budget (toLocaleString)

CSS changes:
   - Focus states with smooth transitions
   - is-disabled styling for deactivated rows
   - Toggle label styling aligned with WordPress admin aesthetic
…alidation in knowledge tab

- Add file_exists() guards before all .asset.php includes to prevent PHP
  warnings when src/js/build/ is missing (fresh Docker mounts without
  npm run build).
- Affected files: class-jeo.php, class-layer-types.php,
  class-legend-types.php, class-sidebars.php, class-stories-near-you.php.
- Add early guard clause in tab-knowledge.php to show 'AI Provider Required'
  card when no API keys are configured, preventing fatal errors from
  missing vendor dependencies and skeleton freeze.
…ed locations

Add two new calibration settings to Georeferencing Calibration:
- Primary Threshold (default 75): confidence >= threshold = primary
- Secondary Threshold (default 35): confidence >= threshold = secondary,
  below = disabled/discarded

Changes across 7 files:
- class-settings.php: new defaults, checkbox handling, sanitization
- tab-provider.php: two new slider rows with toggles
- settings-page.js: toggle/slider bindings + AJAX params
- class-ai-handler.php: read thresholds and inject classification rules
  into the prompt generator meta-prompt
- class-jeo.php: expose thresholds via wp_localize_script to sidebar JS
- posts-sidebar/index.js: replace hardcoded 35/75 with configurable values
- class-bulk-processor.php: use configured thresholds + discard below
  secondary threshold instead of hardcoded 75
Add an 'is_primary' boolean field to the AI's JSON response so the LLM
can use editorial judgment (based on the user's detailed prompt) to flag
primary vs secondary locations, rather than relying solely on confidence
thresholds.

Changes:
- class-ai-adapter.php: enforce 'is_primary' in the JSON schema with
  description and example
- class-ai-handler.php: validate is_primary during prompt validation;
  inject is_primary instruction into the prompt generator's calibration
  rules
- posts-sidebar/index.js: respect AI's is_primary when available,
  fallback to confidence thresholds for backward compatibility
- class-bulk-processor.php: respect AI's is_primary when available
- geo-posts-ai.js: display a '★ Primary' badge when AI flagged a
  location as primary
Add two new settings under Appearance > Map Marker Icons:
- Primary Pin URL (default: blue marker from CDN)
- Secondary Pin URL (default: grey marker from CDN)

Changes:
- class-settings.php: new defaults and sanitization for pin URLs
- settings-page.php: new Map Marker Icons section with URL inputs
- class-jeo.php: expose pin_urls via wp_localize_script to both
  sidebar JS (jeo-js) and frontend map JS (jeo-map)
- geo-posts.js & geo-posts-ai.js: use window.jeo.pin_urls with
  fallback to the public CDN URLs
Remove /master/ from the jsDelivr path which was causing 404s.
The correct jsDelivr path serves directly from repo root:
  cdn.jsdelivr.net/gh/pointhi/leaflet-color-markers/img/...

Updated in defaults, placeholders, fallbacks, and built assets.
…dals

Redesign both geolocation modals (manual + AI) so the map fills the
entire viewport and the left-column info becomes a floating overlay
panel that can be minimized/expanded.

Changes:
- geo-posts.css: add fullscreen modal styles, floating panel with
  backdrop blur, collapse/expand transitions, responsive breakpoints,
  and floating action bar
- geo-posts-ai.js: rewrite layout as fullscreen map + overlay panel
  with useState for isMinimized toggle; action buttons moved to
  bottom-right floating bar
- geo-posts.js: same fullscreen overlay pattern for class component;
  add isPanelMinimized state and togglePanel method; keep all
  existing functionality (add/edit/drag markers, forms)
- Both panels show a compact header when collapsed with item count
  and a ◀/▶ toggle button
…ngs tab

- Refactor geolocation modals (manual + AI) to use fullscreen Leaflet map
  with floating collapsible overlay panel
- Add drag-and-drop to overlay panel header via useDraggable hook
- Move action buttons (Discard All / Add to Map) inside AI panel for
  better UX
- Improve AI map fitBounds to center on all suggestion pins
- Add new 'Settings' tab in Jeo -> AI for generic AI configuration:
  - Move Debug Mode from Provider tab
  - Add JEO AI API Debugger toggle
- Fix sprintf import in geo-posts.js
- Fix undefined array key warning in tab-embedded.php
- Add scripts/build.sh to generate WordPress-ready ZIP from src/
  - Validates release metadata
  - Runs npm run build + composer install --no-dev
  - Copies vendor into src/ and packages as jeo-{version}.zip
  - Cleans up src/vendor after packaging
- Make scripts/wordpress-smoke.sh executable
- Add dist/ to .gitignore
- Add 'Retry AI' button alongside Discard All and Add to Map in the
  Review AI Suggestions panel
- Re-runs /jeo/v1/ai-georeference with loading feedback (isBusy spinner)
- Disables Add to Map during retry to prevent conflicting actions
- Updates suggestions list and map pins automatically on completion
Add native schema enforcement via NeuronAI Structured Output as the primary
path for AI georeferencing, with the existing regex-based parser as fallback.

New classes:
- Location_Output: typed schema with validation rules (NotBlank, range checks)
- Georeference_Result: wrapper array for NeuronAI root schema

Adapter changes:
- Neuron_Agent::run_georeference_structured() uses structured() with 3 retries
- Neuron_Adapter::georeference() tries structured first, falls back to text
- Bypass structured output for internal tools using [SKIP_ENFORCED_SCHEMA]

Settings:
- Add ai_use_structured_output toggle (default false) in AI Settings tab
- Sanitize as boolean in class-settings.php

Prompt hygiene:
- get_system_prompt() returns clean prompt when structured output is active
- strip_legacy_json_instructions() removes residual CRITICAL INSTRUCTION blocks
- Prompt Engineering Assistant omits JSON formatting blocks when structured output is on

Zero impact on existing installations; fallback to parse_json_from_text() is
automatic and preserves all current behavior.
Update runtime validation, docs, and plugin metadata to reflect PHP 8.3+
requirement. This aligns with the hacklabr/ai-assistant dependency which uses
typed class constants (PHP 8.3 feature) and the Docker dev environment which
now runs wordpress:php8.3-apache.

Files updated:
- src/jeo.php: version_compare check and error message
- src/readme.txt: Requires PHP header and changelog
- AGENTS.md: stack documentation
- README.md: prerequisites
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants