=== Synthocode AI Companion ===
Contributors: slim1167
Tags: woocommerce, ai, openai, content-generation, image-generation
Requires at least: 6.4
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Generate WooCommerce product descriptions (Groq, OpenAI) and photorealistic product images (fal.ai FLUX) in one click. BYOK, no middleman.

== Description ==

Synthocode AI Companion adds AI-powered buttons to your WooCommerce product editor:

* **Generate description with AI** — uses Groq Llama 3 or OpenAI GPT to write an SEO-optimized product description from the product title.
* **Generate product image with AI (fal.ai)** — uses fal.ai FLUX to generate a photorealistic product image, automatically uploads it to the Media Library, and sets it as the featured image.
* **Generate reviews summary with AI** — uses Groq or OpenAI to summarize the product's approved customer reviews (strengths, weaknesses, final recommendation). The result is stored and displayed via the "Resume IA des avis" block.

= Non-blocking architecture =

The fal.ai queue polling is done in the browser (JavaScript), not in PHP. The server is never blocked by a long-running `sleep` call. No risk of PHP timeouts or 504 errors, even with multiple concurrent users.

= Security =

* Nonces on every AJAX endpoint.
* `edit_products` capability check for product actions, `manage_options` for settings.
* Anti-SSRF: only HTTPS URLs hosted on `queue.fal.run` are accepted by the status/finalize endpoints.
* API keys stored in WordPress options, never exposed to the frontend.

= BYOK (Bring Your Own Key) =

This plugin contacts external AI providers using **your own API keys**. No data is ever sent to Synthocode. You stay in full control of your usage and costs.

== External services ==

This plugin is a BYOK ("Bring Your Own Key") tool. It does NOT send any data to Synthocode. Instead, it connects directly from your server to the third-party AI provider(s) that you choose and configure with your own API keys.

Each service below is OPTIONAL and is contacted ONLY when a logged-in administrator explicitly clicks the corresponding "Generate ... with AI" button in the WooCommerce product editor, and ONLY if the matching API key has been entered in Settings > Synthocode AI. If no key is set for a provider, that provider is never contacted.

= 1. Groq API (optional — text generation) =

Groq is an AI inference service used to generate product descriptions and review summaries.

* Domain contacted: `api.groq.com` (endpoint `https://api.groq.com/openai/v1/chat/completions`).
* When: each time you click "Generate description with AI" or "Generate reviews summary with AI" while Groq is the selected text provider.
* Data sent: the product title and/or the text of the product's approved customer reviews (as part of a prompt), plus the chosen model name. Your Groq API key is sent in the request header.
* Terms of use: https://groq.com/terms-of-use
* Privacy policy: https://groq.com/privacy-policy

= 2. OpenAI API (optional — text generation) =

OpenAI is an AI service used to generate product descriptions and review summaries.

* Domain contacted: `api.openai.com` (endpoint `https://api.openai.com/v1/chat/completions`).
* When: each time you click "Generate description with AI" or "Generate reviews summary with AI" while OpenAI is the selected text provider.
* Data sent: the product title and/or the text of the product's approved customer reviews (as part of a prompt), plus the chosen model name. Your OpenAI API key is sent in the request header.
* Terms of use: https://openai.com/policies/terms-of-use/
* Privacy policy: https://openai.com/policies/privacy-policy/

= 3. fal.ai API (optional — image generation) =

fal.ai is an AI image-generation service (FLUX models). The plugin contacts fal.ai through its queue API, which is served from the `queue.fal.run` domain (operated by fal.ai).

* Domains contacted: `queue.fal.run` to submit a generation job (endpoint `https://queue.fal.run/<model>`) and to poll the job status / fetch the result URLs returned by fal.ai.
* When: each time you click "Generate product image with AI (fal.ai FLUX)".
* Data sent: a text prompt derived from the product title and image-generation parameters. Your fal.ai API key is sent in the request header.
* Data received: a generated image URL, which is then downloaded and stored in your Media Library.
* Terms of service: https://www.fal.ai/legal/terms-of-service
* Privacy policy: https://www.fal.ai/legal/privacy-policy

== Installation ==

1. Install and activate the plugin.
2. Go to Settings > Synthocode AI.
3. Paste your Groq, OpenAI, and/or fal.ai API keys.
4. Edit a WooCommerce product. The two AI buttons appear above the editor.

== Frequently Asked Questions ==

= Do I need all three API keys? =

No. Each provider is optional. You can use only Groq for text and skip image generation, or vice versa.

= Is any of my data sent to Synthocode? =

No. All API calls go directly from your server to the provider you configured.

== Screenshots ==

1. BYOK settings page (Groq / OpenAI / fal.ai). API keys are encrypted at rest and never displayed in clear text.
2. WooCommerce product editor with the AI generation buttons and a Groq-generated description.
3. Final product page on the front-end with the AI-generated copy and visual.

== Changelog ==

= 1.0.1 =
* Documentation: expanded the "External services" section to explicitly list every domain contacted (api.groq.com, api.openai.com, queue.fal.run), the exact data sent and when, and verified terms/privacy links for each provider.
* No functional change.

= 1.0.0 =
* Initial release.
* One-click "Generate description with AI" on the WooCommerce product editor (Groq Llama / OpenAI GPT), with a per-product text-provider selector.
* One-click "Generate product image with AI (fal.ai FLUX)" with non-blocking client-side queue polling; the image is sideloaded to the Media Library and set as the featured image.
* One-click "Generate reviews summary with AI" (Groq / OpenAI), built only from the product's approved reviews and cached in post meta.
* Dynamic block "Resume IA des avis" (synthocode/ai-reviews-summary) that displays the stored summary on the product page.
* BYOK settings screen for Groq, OpenAI, and fal.ai API keys, with a "Settings" link on the Plugins page.
