mcp-relight-harmonize 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/mcp-relight-harmonize/SKILL.md +46 -51
- package/.agents/skills/mcp-relight-harmonize/references/diffusion_guide.md +10 -8
- package/.agents/skills/mcp-relight-harmonize/scripts/extract_layers.py +23 -8
- package/MASTER.md +74 -91
- package/README.md +21 -8
- package/dist/contracts/schemas.js +2 -2
- package/dist/contracts/types.d.ts +2 -2
- package/dist/domain/layer_extractor.d.ts +1 -1
- package/dist/domain/layer_extractor.js +8 -6
- package/dist/domain/prompt_synthesizer.js +10 -6
- package/dist/index.js +1 -1
- package/dist/resources/presets.js +2 -2
- package/dist/server.js +11 -11
- package/dist/tools/analyze_optical.js +1 -1
- package/dist/tools/generate_relight.js +1 -1
- package/dist/tools/harmonize.js +1 -1
- package/dist/tools/synthesize_prompt.js +1 -1
- package/docs/architecture.md +2 -2
- package/package.json +3 -3
|
@@ -1,40 +1,60 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mcp-relight-harmonize
|
|
3
3
|
description: >-
|
|
4
|
-
Execute end-to-end optical image profiling, physically-grounded relighting variations, contact-aware composite harmonization,
|
|
5
|
-
and precision diffusion prompt synthesis
|
|
4
|
+
Execute end-to-end 6-layer optical image profiling, physically-grounded relighting variations, contact-aware composite harmonization,
|
|
5
|
+
and precision diffusion prompt synthesis compatible with Any Image Generator Model (optimized for GEMINI Nano Banana in Antigravity). Use when inspecting lighting angles or color temperature,
|
|
6
6
|
generating alternative illumination schemes (Ambient, Dramatic, Rim, Mood), blending foreground cutouts into backgrounds,
|
|
7
7
|
or drafting photorealistic prompts.
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# `mcp-relight-harmonize` Skill Specification
|
|
11
11
|
|
|
12
|
-
Created by **MarwanDevSpace**, this skill empowers the agent to execute physical lighting analysis, generate relighted variations, perform seamless composite harmonization, and craft production diffusion prompts tailored for **
|
|
12
|
+
Created by **MarwanDevSpace**, this skill empowers the agent to execute physical lighting analysis, decompose images into 6 visual layers in `Layers/`, generate relighted variations, perform seamless composite harmonization, and craft production diffusion prompts tailored for **Any Image Generator Model** (specifically optimized for **GEMINI Nano Banana** in **Google Antigravity**).
|
|
13
|
+
|
|
14
|
+
> [!NOTE]
|
|
15
|
+
> **Antigravity Recommended**: This skill is optimized to work with **any Image Generator**, and is **strongly preferred inside Google Antigravity** where native desktop image generation (`generate_image`) with **GEMINI Nano Banana** can immediately execute the desired modifications.
|
|
13
16
|
|
|
14
17
|
---
|
|
15
18
|
|
|
16
19
|
## 1. When to Activate This Skill
|
|
17
20
|
|
|
18
21
|
Activate this skill whenever the user asks to:
|
|
19
|
-
1. **Analyze an image's lighting:**
|
|
20
|
-
2. **Relight an image:** Produce
|
|
22
|
+
1. **Decompose & Analyze an image's lighting:** Generate 6 analytical layers into `Layers/` and determine CCT (Kelvin), lighting direction, azimuth/elevation angles, contrast ratio, or surface roughness.
|
|
23
|
+
2. **Relight an image:** Produce physically-grounded lighting variants (`Ambient`, `Dramatic`, `Rim`, `Mood`).
|
|
21
24
|
3. **Composite/Harmonize an image:** Place a cutout foreground onto a background scene, matching ambient color statistics and adding physically grounded contact shadows.
|
|
22
|
-
4. **Generate `/prompt` for diffusion:** Create exact physical lighting and detail enhancement prompts for **
|
|
25
|
+
4. **Generate `/prompt` for diffusion:** Create exact physical lighting and detail enhancement prompts for **Any Image Generator** / **GEMINI Nano Banana** with calibrated denoising strength (`0.35 - 0.45`).
|
|
23
26
|
|
|
24
27
|
---
|
|
25
28
|
|
|
26
29
|
## 2. Core Workflows & Execution Procedures
|
|
27
30
|
|
|
28
|
-
### Workflow A: Optical Profiling
|
|
31
|
+
### Workflow A: Optical Profiling & 6-Layer Decomposition
|
|
29
32
|
Before modifying or inpainting an image, extract its optical geometry:
|
|
30
|
-
1. Call tool `analyze_optical_profile({ image_path: "<path_to_image>" })
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
33
|
+
1. Call tool `analyze_optical_profile({ image_path: "<path_to_image>", extract_layers: true })` or run:
|
|
34
|
+
`python scripts/extract_layers.py --image <path> [--intent "<intent>"]`
|
|
35
|
+
2. Python decomposes the image into 6 visual layers inside `Layers/`:
|
|
36
|
+
- `01_highlights.png` (Highlights / Specular Zones)
|
|
37
|
+
- `02_shadows.png` (Shadows / Low-Key Zones)
|
|
38
|
+
- `03_ambient_occlusion.png` (Deep Ambient Occlusion & Ground Contact)
|
|
39
|
+
- `04_edges.png` (Sobel High-Frequency Contours)
|
|
40
|
+
- `05_depth_normals.png` (3D Surface Normal Gradient Field)
|
|
41
|
+
- `06_chroma_saturation.png` (Chrominance & Saturation Distribution)
|
|
42
|
+
3. Review the resulting `OpticalProfileReport` and dynamic `Layer.md`:
|
|
43
|
+
- **`colorTemperatureKelvin`**: e.g., 3200K tungsten vs 5500K daylight.
|
|
44
|
+
- **`lightingAngles`**: `azimuthDeg` and `elevationDeg`.
|
|
34
45
|
- **`luminanceDynamics.contrastRatio`**: Key-to-fill ratio.
|
|
35
|
-
|
|
46
|
+
- **`aoCoveragePct`**: Contact shadow presence vs floating subject.
|
|
47
|
+
4. Store findings in memory / CoT to guide subsequent generation.
|
|
48
|
+
|
|
49
|
+
### Workflow B: Interactive Decision & Direct Image Generation
|
|
50
|
+
1. Address the user with the mandatory prompt:
|
|
51
|
+
**"ماذا تريد من تعديل؟"**
|
|
52
|
+
accompanied by tailored recommendations derived strictly from the image's detected optical profile.
|
|
53
|
+
2. Upon user selection or intent:
|
|
54
|
+
- Synthesize the photorealistic prompt for the **Image Generator**.
|
|
55
|
+
- **Inside Google Antigravity**: Directly trigger `generate_image` using the synthesized prompt to produce the modified image on the spot!
|
|
36
56
|
|
|
37
|
-
### Workflow
|
|
57
|
+
### Workflow C: Physical Relighting Variations
|
|
38
58
|
To produce visual lighting alternatives on disk:
|
|
39
59
|
1. Call tool `generate_relight_variations({ image_path: "<path_to_image>", target_lighting: "All" })`.
|
|
40
60
|
2. The tool produces 4 files in `OUTPUT_CACHE_DIR`:
|
|
@@ -42,61 +62,36 @@ To produce visual lighting alternatives on disk:
|
|
|
42
62
|
- `*_relight_dramatic.png` (-1.5 EV shadow crush, top-left directional chiaroscuro).
|
|
43
63
|
- `*_relight_rim.png` (+1.2 EV high-pass edge halo, cool cyan perimeter).
|
|
44
64
|
- `*_relight_mood.png` (3200K tungsten amber shift, highlight bloom diffusion).
|
|
45
|
-
3. Present the resulting artifact paths to the user with their mathematical adjustment logs.
|
|
46
65
|
|
|
47
|
-
### Workflow
|
|
66
|
+
### Workflow D: Composite Harmonization
|
|
48
67
|
To blend a subject or product into a new background:
|
|
49
68
|
1. Call tool `harmonize_composite({ foreground_path: "<fg>", background_path: "<bg>", blend_mode: "seamless" })`.
|
|
50
|
-
2. The engine executes
|
|
51
|
-
- **Reinhard Color Statistics Transfer:** Normalizes foreground means and deviations to match background in Ruderman $l\alpha\beta$ space.
|
|
52
|
-
- **Contact Shadow Synthesis:** Projects an elliptical Gaussian shadow beneath the subject's lowest contact plane.
|
|
53
|
-
- **Smooth Blending:** Eliminates boundary halo artifacts.
|
|
54
|
-
3. Return the composite image file path.
|
|
69
|
+
2. The engine executes Reinhard Color Statistics Transfer in Ruderman $l\alpha\beta$ space, applies Ground Contact Shadows, and smooths boundaries.
|
|
55
70
|
|
|
56
|
-
### Workflow
|
|
71
|
+
### Workflow E: Diffusion Prompt Synthesis (`/prompt`)
|
|
57
72
|
To craft targeted generative prompts:
|
|
58
|
-
1. Call tool `synthesize_diffusion_prompt({ image_path: "<path>", user_intent: "<intent>", target_model: "
|
|
59
|
-
2. Extract the
|
|
60
|
-
- **`enhancementPrompt`**:
|
|
61
|
-
- **`relightingPrompt`**:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
### Workflow E: Output Cache Inspection
|
|
66
|
-
To inspect or discover previously generated relight variations or composite outputs:
|
|
67
|
-
1. Call tool `list_cached_variations({ cache_dir?: "<path>" })`.
|
|
68
|
-
2. Inspect `files` list containing filename, full path, byte size, and last modified timestamp for all output artifacts.
|
|
69
|
-
|
|
70
|
-
### Workflow F: Dynamic 6-Layer Decomposition & Interactive Modification Loop
|
|
71
|
-
For comprehensive optical intelligence and guided generation:
|
|
72
|
-
1. Call tool `analyze_optical_profile({ image_path: "<path>", extract_layers: true, user_intent?: "<intent>" })` or execute Python script:
|
|
73
|
-
`python scripts/extract_layers.py --image <path> [--intent "<intent>"]`
|
|
74
|
-
2. The engine generates 6 visual analytical layers into `Layers/`:
|
|
75
|
-
- `01_highlights.png` (Highlights / Specular Zones)
|
|
76
|
-
- `02_shadows.png` (Shadows / Low-Key Zones)
|
|
77
|
-
- `03_ambient_occlusion.png` (Deep Ambient Occlusion & Contact Umbra)
|
|
78
|
-
- `04_edges.png` (Sobel High-Frequency Contours)
|
|
79
|
-
- `05_depth_normals.png` (3D Surface Normal Gradient Field)
|
|
80
|
-
- `06_chroma_saturation.png` (Chrominance & Saturation Distribution)
|
|
81
|
-
3. Examine each layer and retain optical findings in memory / CoT.
|
|
82
|
-
4. Present the dynamic `Layer.md` and address the user with the mandatory decision prompt:
|
|
83
|
-
**"ماذا تريد من تعديل؟"**
|
|
84
|
-
presenting dynamically generated options tailored specifically to the image's detected optical profile.
|
|
85
|
-
5. Upon the user's decision, immediately formulate the target prompt for **GPT Image** or **Nano Banana**. If the client/agent has an embedded image generator (`generate_image`), trigger generation immediately!
|
|
73
|
+
1. Call tool `synthesize_diffusion_prompt({ image_path: "<path>", user_intent: "<intent>", target_model: "universal" | "nano_banana" })`.
|
|
74
|
+
2. Extract the specialized prompts:
|
|
75
|
+
- **`enhancementPrompt`**: Micro-surface textures, pore fidelity, lens sharpness, and subsurface scattering.
|
|
76
|
+
- **`relightingPrompt`**: Exact lighting angles, Kelvin temperature, volumetric dust rays, and contact shadows.
|
|
77
|
+
|
|
78
|
+
### Workflow F: Output Cache Inspection
|
|
79
|
+
1. Call tool `list_cached_variations({ cache_dir?: "<path>" })` to inspect generated artifacts.
|
|
86
80
|
|
|
87
81
|
---
|
|
88
82
|
|
|
89
83
|
## 3. Reference Documentation
|
|
90
84
|
|
|
91
|
-
For in-depth mathematical formulations and model guides:
|
|
92
85
|
- [Optical Mathematics & Formulations](./references/optical_math.md)
|
|
93
86
|
- [Tool Orchestration & Chaining Standards](./references/tool_orchestration.md)
|
|
94
|
-
- [
|
|
87
|
+
- [Image Generator & GEMINI Nano Banana Guide](./references/diffusion_guide.md)
|
|
95
88
|
|
|
96
89
|
---
|
|
97
90
|
|
|
98
91
|
## 4. Executable Helper Scripts
|
|
99
92
|
|
|
93
|
+
- Execute 6-layer optical extraction:
|
|
94
|
+
`python scripts/extract_layers.py --image <image_path> [--intent "<intent>"]`
|
|
100
95
|
- Execute full end-to-end analysis & prompt synthesis from CLI:
|
|
101
96
|
`node .agents/skills/mcp-relight-harmonize/scripts/run_pipeline.js <image_path>`
|
|
102
97
|
- Verify server health and tool registration:
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Image Generator Prompt Engineering Guide: Universal & GEMINI Nano Banana
|
|
2
2
|
|
|
3
|
-
This document maps physical optical metrics into specialized prompt directives
|
|
3
|
+
This document maps physical optical metrics into specialized prompt directives compatible with **Any Image Generator Model**, with specific optimization for **GEMINI Nano Banana** in **Google Antigravity**.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
## 1. Target Engine
|
|
7
|
+
## 1. Target Engine Paradigms
|
|
8
8
|
|
|
9
|
-
| Parameter |
|
|
9
|
+
| Parameter | Universal Image Generator (Natural Studio) | GEMINI Nano Banana (Optical Shaders) |
|
|
10
10
|
|---|---|---|
|
|
11
|
-
| **Prompt Paradigm** | Natural language, photographic directives | Dense tokenized optical descriptors |
|
|
11
|
+
| **Prompt Paradigm** | Natural language, photographic studio directives | Dense tokenized optical descriptors & shaders |
|
|
12
12
|
| **Optics Formulation** | 85mm prime lens f/2.0, authentic falloff | Micro-surface specular roughness, normal angle |
|
|
13
13
|
| **Contact Shadows** | "physically-based contact shadows at base" | "ground contact shadow, ambient occlusion caster" |
|
|
14
14
|
| **Volumetrics** | "subtle volumetric dust rays in air" | "volumetric raytraced bounce" |
|
|
15
15
|
| **Denoising Default** | `0.38` | `0.38` (subtle) to `0.42` (dramatic) |
|
|
16
|
+
| **Recommended Environment** | Any diffusion generator | **Google Antigravity (`generate_image`)** |
|
|
16
17
|
|
|
17
18
|
---
|
|
18
19
|
|
|
19
|
-
## 2.
|
|
20
|
+
## 2. Universal Image Generator Prompt Architecture
|
|
20
21
|
|
|
21
22
|
### Enhancement Prompt Template:
|
|
22
23
|
```text
|
|
@@ -34,7 +35,7 @@ authentic photometric falloff, [User Intent].
|
|
|
34
35
|
|
|
35
36
|
---
|
|
36
37
|
|
|
37
|
-
## 3. Nano Banana Prompt Architecture
|
|
38
|
+
## 3. GEMINI Nano Banana Prompt Architecture
|
|
38
39
|
|
|
39
40
|
### Enhancement Prompt Template:
|
|
40
41
|
```text
|
|
@@ -50,7 +51,8 @@ denoising 0.38, light_azimuth_[Azimuth]deg, [User Intent]
|
|
|
50
51
|
```
|
|
51
52
|
|
|
52
53
|
### Recommended Parameters:
|
|
53
|
-
- `model`: `"nano-banana
|
|
54
|
+
- `model`: `"gemini-nano-banana"`
|
|
55
|
+
- `target_environment`: `"Google Antigravity"`
|
|
54
56
|
- `denoising_strength`: `0.38`
|
|
55
57
|
- `guidance_scale`: `4.5`
|
|
56
58
|
- `steps`: `32`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""
|
|
3
|
-
MarwanDevSpace - Dynamic 6-Layer Optical Decomposition & Intelligence Engine
|
|
3
|
+
MarwanDevSpace - Dynamic 6-Layer Optical Decomposition & Intelligence Engine
|
|
4
4
|
Extracts 6 analytical visual layers into Layers/ directory:
|
|
5
5
|
1. 01_highlights.png - طبقة الألوان الفاتحة (Highlights / Specular Zones)
|
|
6
6
|
2. 02_shadows.png - طبقة الألوان الغامقة (Shadows / Low-Key Zones)
|
|
@@ -10,7 +10,7 @@ Extracts 6 analytical visual layers into Layers/ directory:
|
|
|
10
10
|
6. 06_chroma_saturation.png - طبقة الألوان والتشبع والبكسلات (Chroma & Saturation Distribution)
|
|
11
11
|
|
|
12
12
|
Generates dynamic, on-demand Layer.md reports and physical generative prompts
|
|
13
|
-
specifically targeting
|
|
13
|
+
specifically targeting Universal Image Generator and Nano Banana without static boilerplate.
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
16
|
import os
|
|
@@ -110,14 +110,16 @@ def build_dynamic_diagnostics(
|
|
|
110
110
|
else:
|
|
111
111
|
findings.append(f"🔘 **لوحة لونية هادئة أو معتدلة**: متوسط التشبع `{round(mean_saturation, 3)}` يعكس تدرجات رصينة غير مبالغ بها.")
|
|
112
112
|
|
|
113
|
+
# Add custom intent option if provided
|
|
113
114
|
if user_intent:
|
|
114
115
|
tailored_options.insert(0, f"تطبيق طلبك المخصص فوراً: \"{user_intent}\" بتطابق فيزيائي دقيق مع بيانات الطبقات الست.")
|
|
115
116
|
else:
|
|
116
117
|
tailored_options.append("إعادة إضاءة بنمط هالة الحواف (Rim Light Halo +1.2 EV) لإبراز حدود المجسم وعزله عن الخلفية.")
|
|
117
118
|
tailored_options.append("دمج العنصر في خلفية جديدة مع مطابقة إحصائيات الألوان ودرجة الحرارة وظلال الارتكاز.")
|
|
118
119
|
|
|
120
|
+
# Dynamic Generative Prompts tailored to exact metrics
|
|
119
121
|
intent_clause = f", {user_intent}" if user_intent else ""
|
|
120
|
-
|
|
122
|
+
universal_prompt = (
|
|
121
123
|
f"A master-quality studio photograph{intent_clause}, calibrated optical lighting at {round(azimuth_deg)}° azimuth "
|
|
122
124
|
f"and {round(elevation_deg)}° elevation, authentic {round(cct_kelvin)}K color temperature balance, "
|
|
123
125
|
f"physically-grounded ambient occlusion contact shadows firmly anchoring the base plane, "
|
|
@@ -136,7 +138,7 @@ def build_dynamic_diagnostics(
|
|
|
136
138
|
"thermalDescription": thermal_desc,
|
|
137
139
|
"findings": findings,
|
|
138
140
|
"tailoredOptions": tailored_options,
|
|
139
|
-
"
|
|
141
|
+
"universalImagePrompt": universal_prompt,
|
|
140
142
|
"nanoBananaPrompt": nano_banana_prompt,
|
|
141
143
|
}
|
|
142
144
|
|
|
@@ -153,21 +155,25 @@ def extract_layers(image_path: str, output_dir: str = "Layers", user_intent: Opt
|
|
|
153
155
|
height, width, _ = rgb.shape
|
|
154
156
|
num_pixels = width * height
|
|
155
157
|
|
|
158
|
+
# Luminance channel Y
|
|
156
159
|
lum = 0.2126 * rgb[:, :, 0] + 0.7152 * rgb[:, :, 1] + 0.0722 * rgb[:, :, 2]
|
|
157
160
|
norm_lum = lum / 255.0
|
|
158
161
|
|
|
162
|
+
# 1. طبقة الألوان الفاتحة (Highlights / Specular Zones)
|
|
159
163
|
hl_mask = np.clip((lum - 170.0) / 75.0, 0.0, 1.0)
|
|
160
164
|
hl_layer = rgb * hl_mask[:, :, np.newaxis]
|
|
161
165
|
hl_coverage_pct = float((np.sum(lum > 170.0) / num_pixels) * 100.0)
|
|
162
166
|
hl_path = os.path.join(abs_output_dir, "01_highlights.png")
|
|
163
167
|
Image.fromarray(np.uint8(np.clip(hl_layer, 0, 255))).save(hl_path)
|
|
164
168
|
|
|
169
|
+
# 2. طبقة الألوان الغامقة (Shadows / Low-Key Zones)
|
|
165
170
|
shadow_mask = np.clip((95.0 - lum) / 80.0, 0.0, 1.0)
|
|
166
171
|
shadow_layer = rgb * shadow_mask[:, :, np.newaxis]
|
|
167
172
|
shadow_coverage_pct = float((np.sum(lum < 85.0) / num_pixels) * 100.0)
|
|
168
173
|
shadow_path = os.path.join(abs_output_dir, "02_shadows.png")
|
|
169
174
|
Image.fromarray(np.uint8(np.clip(shadow_layer, 0, 255))).save(shadow_path)
|
|
170
175
|
|
|
176
|
+
# 3. طبقة الظل العالي (Deep Ambient Occlusion & Contact Umbra)
|
|
171
177
|
ao_mask = np.clip((40.0 - lum) / 40.0, 0.0, 1.0)
|
|
172
178
|
ao_visual = np.zeros((height, width, 3), dtype=np.float32)
|
|
173
179
|
ao_visual[:, :, 0] = (1.0 - ao_mask) * 230.0
|
|
@@ -177,6 +183,7 @@ def extract_layers(image_path: str, output_dir: str = "Layers", user_intent: Opt
|
|
|
177
183
|
ao_path = os.path.join(abs_output_dir, "03_ambient_occlusion.png")
|
|
178
184
|
Image.fromarray(np.uint8(np.clip(ao_visual, 0, 255))).save(ao_path)
|
|
179
185
|
|
|
186
|
+
# 4. طبقة الحواف (Sobel Gradient Contours)
|
|
180
187
|
sobel_x = np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]], dtype=np.float32)
|
|
181
188
|
sobel_y = np.array([[-1, -2, -1], [0, 0, 0], [1, 2, 1]], dtype=np.float32)
|
|
182
189
|
padded_lum = np.pad(norm_lum, 1, mode="edge")
|
|
@@ -193,6 +200,7 @@ def extract_layers(image_path: str, output_dir: str = "Layers", user_intent: Opt
|
|
|
193
200
|
edge_path = os.path.join(abs_output_dir, "04_edges.png")
|
|
194
201
|
Image.fromarray(np.uint8(edge_vis)).save(edge_path)
|
|
195
202
|
|
|
203
|
+
# 5. طبقة العمق (Depth / 3D Normal Vector Field)
|
|
196
204
|
scale = 6.0
|
|
197
205
|
nx = -gx * scale
|
|
198
206
|
ny = -gy * scale
|
|
@@ -219,6 +227,7 @@ def extract_layers(image_path: str, output_dir: str = "Layers", user_intent: Opt
|
|
|
219
227
|
azimuth_deg = (np.degrees(np.arctan2(-avg_ly, avg_lx)) + 360.0) % 360.0
|
|
220
228
|
elevation_deg = np.clip(np.degrees(np.arcsin(np.clip(avg_lz, -1.0, 1.0))), 0.0, 90.0)
|
|
221
229
|
|
|
230
|
+
# 6. طبقة الألوان والتشبع (Chrominance / Saturation Distribution)
|
|
222
231
|
max_c = np.maximum(np.maximum(rgb[:, :, 0], rgb[:, :, 1]), rgb[:, :, 2])
|
|
223
232
|
min_c = np.minimum(np.minimum(rgb[:, :, 0], rgb[:, :, 1]), rgb[:, :, 2])
|
|
224
233
|
chroma = max_c - min_c
|
|
@@ -234,11 +243,13 @@ def extract_layers(image_path: str, output_dir: str = "Layers", user_intent: Opt
|
|
|
234
243
|
chroma_path = os.path.join(abs_output_dir, "06_chroma_saturation.png")
|
|
235
244
|
Image.fromarray(np.uint8(sat_vis)).save(chroma_path)
|
|
236
245
|
|
|
246
|
+
# Correlated Color Temperature
|
|
237
247
|
mean_r = float(np.mean(rgb[:, :, 0]))
|
|
238
248
|
mean_g = float(np.mean(rgb[:, :, 1]))
|
|
239
249
|
mean_b = float(np.mean(rgb[:, :, 2]))
|
|
240
250
|
cct_kelvin = calculate_cct(mean_r, mean_g, mean_b)
|
|
241
251
|
|
|
252
|
+
# Build Dynamic Diagnostics based purely on calculated data
|
|
242
253
|
diag = build_dynamic_diagnostics(
|
|
243
254
|
cct_kelvin=cct_kelvin,
|
|
244
255
|
azimuth_deg=azimuth_deg,
|
|
@@ -308,8 +319,10 @@ def extract_layers(image_path: str, output_dir: str = "Layers", user_intent: Opt
|
|
|
308
319
|
},
|
|
309
320
|
}
|
|
310
321
|
|
|
322
|
+
# Format findings and tailored suggestions dynamically
|
|
311
323
|
findings_rendered = "\n\n".join([f"{item}" for item in diag["findings"]])
|
|
312
324
|
options_rendered = "\n".join([f"- **خيار {idx + 1}**: {opt}" for idx, opt in enumerate(diag["tailoredOptions"])])
|
|
325
|
+
|
|
313
326
|
user_intent_header = f"\n**الهدف المخصص المطلوب**: `{user_intent}`\n" if user_intent else ""
|
|
314
327
|
|
|
315
328
|
layer_md_path = os.path.join(abs_output_dir, "Layer.md")
|
|
@@ -340,14 +353,16 @@ def extract_layers(image_path: str, output_dir: str = "Layers", user_intent: Opt
|
|
|
340
353
|
|
|
341
354
|
---
|
|
342
355
|
|
|
343
|
-
## 3. التوجيه التوليدي المخصص (Calibrated Prompts for
|
|
356
|
+
## 3. التوجيه التوليدي المخصص (Calibrated Prompts for Image Generators)
|
|
344
357
|
|
|
345
|
-
### أ.
|
|
346
|
-
> "{diag['
|
|
358
|
+
### أ. النمط الوصفي الاستوديوي (Any Image Generator Model):
|
|
359
|
+
> "{diag['universalImagePrompt']}"
|
|
347
360
|
|
|
348
|
-
### ب.
|
|
361
|
+
### ب. نمط الشيدر الضوئي المكثف (GEMINI Nano Banana - Antigravity):
|
|
349
362
|
> "{diag['nanoBananaPrompt']}"
|
|
350
363
|
|
|
364
|
+
> 💡 **ملاحظة**: هذا التوجيه متوافق مع **أي Image Generator Model**، ويُفضل ويُوصى بشدة باستخدامه داخل **Google Antigravity** لتطبيق التعديل المباشر عبر أداة `generate_image` ومحرك **GEMINI Nano Banana**!
|
|
365
|
+
|
|
351
366
|
---
|
|
352
367
|
|
|
353
368
|
## 4. الخطوة التفاعلية الموجهة بالبيانات (Dynamic Interactive Decision)
|
package/MASTER.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MASTER.md — MarwanDevSpace: Optical Decomposition & Prompting Architect
|
|
2
2
|
|
|
3
|
-
> **You are MarwanDevSpace**, Principal Protocol Architect, Systems Engineer, and Optical Intelligence Specialist. Your primary directive is to execute deterministic computer vision decomposition, extract physically-grounded optical layers, formulate hyper-calibrated generative prompts, and
|
|
3
|
+
> **You are MarwanDevSpace**, Principal Protocol Architect, Systems Engineer, and Optical Intelligence Specialist. Your primary directive is to execute deterministic computer vision decomposition, extract physically-grounded optical layers, formulate hyper-calibrated generative prompts, and execute high-fidelity image modification directly through AI Image Generators on demand.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -9,158 +9,132 @@
|
|
|
9
9
|
| السمة | السلوك التنفيذي الصارم |
|
|
10
10
|
|---|---|
|
|
11
11
|
| **المهندس المعماري الصارم** | التحدث بسلطة علمية وهندسية دقيقة وموجزة مبنية على الأدلة والفيزياء البصرية (CIE 1931, McCamy, Sobel Gradients, Reinhard Transfer). |
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
12
|
+
| **الفصل الصارم للأدوار (Python vs. Image Generator)** | **وظيفة بايثون حصراً هي التحليل والتفكيك الدقيق** للصورة إلى 6 طبقات صورية في `Layers/` واستخراج الأرقام الفيزيائية. بايثون لا ينشئ التعديل النهائي، بل يُترك التعديل كاملاً للـ **Image Generator** المباشر. |
|
|
13
|
+
| **التطبيق المباشر عبر Image Generator** | تطبيق التعديل النهائي للمستخدم يتم مباشرة وفوراً عبر محرك **Image Generator** (مثل `generate_image` المدعوم بنموذج **GEMINI Nano Banana** داخل Antigravity) بدقة عالية وفق ما تعلمه من صور مجلد `Layers/`. |
|
|
14
|
+
| **توافق عالمي مع أي Image Generator** | النظام مصمم للعمل والتوافق التام مع **أي Image Generator Model**، مع **توصية وملاحظة أساسية بأنه يُفضل استخدامه داخل بيئة Google Antigravity** لتكامل التوليد الصوري المدمج. |
|
|
15
|
+
| **منع القوالب الساكنة (Zero Static Boilerplate)** | يُمنع منعاً باتاً طباعة نصوص تقارير جاهزة أو قوالب أسئلة ثابتة. كل تشخيص وخيار تعديل وبرومبت يُستخرج ديناميكياً حسب الطلب بناءً على أرقام طبقات الصورة الحقيقية. |
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
19
|
## 2. بروتوكول التشغيل المقيد الصارم (The Strict Two-Phase Pipeline)
|
|
20
20
|
|
|
21
|
-
عند تقديم المستخدم لأي صورة أو طلب فحص وتعديل ضوئي، يلتزم الوكيل بالخطوات المقيدة الآتية بالترتيب دون تخطي:
|
|
22
|
-
|
|
23
21
|
```
|
|
24
22
|
[صورة المستخدم]
|
|
25
23
|
│
|
|
26
24
|
▼
|
|
27
|
-
|
|
28
|
-
│ المرحلة الأولى: تفكيك وتحليل الطبقات الست في مجلد Layers/
|
|
29
|
-
│
|
|
30
|
-
│
|
|
31
|
-
│
|
|
32
|
-
│
|
|
33
|
-
│
|
|
34
|
-
│
|
|
35
|
-
│
|
|
36
|
-
│
|
|
37
|
-
|
|
25
|
+
┌────────────────────────────────────────────────────────────────────────┐
|
|
26
|
+
│ المرحلة الأولى: تفكيك وتحليل الطبقات الست في مجلد Layers/ (بايثون حصراً) │
|
|
27
|
+
│ • مهمة بايثون: تحليل فيزيائي دقيق وتوليد 6 طبقات صورية: │
|
|
28
|
+
│ 1. 01_highlights.png - طبقة الألوان الفاتحة (Highlights) │
|
|
29
|
+
│ 2. 02_shadows.png - طبقة الألوان الغامقة (Shadows) │
|
|
30
|
+
│ 3. 03_ambient_occlusion.png - طبقة الظل العالي والارتكاز (AO) │
|
|
31
|
+
│ 4. 04_edges.png - طبقة الحواف والتفاصيل المجهرية │
|
|
32
|
+
│ 5. 05_depth_normals.png - طبقة العمق وتنسور المتجهات ثلاثية الأبعاد│
|
|
33
|
+
│ 6. 06_chroma_saturation.png - طبقة التشبع والنقاء اللوني للبكسلات │
|
|
34
|
+
│ │
|
|
35
|
+
│ ➔ فحص كل طبقة وتخزين معالمها وأرقامها في الذاكرة ومسار التفكير (CoT) │
|
|
36
|
+
└────────────────────────────────────────────────────────────────────────┘
|
|
38
37
|
│
|
|
39
38
|
▼
|
|
40
|
-
|
|
41
|
-
│ المرحلة الثانية: تقرير Layer.md
|
|
42
|
-
│ • صياغة Layer.md
|
|
43
|
-
│ • توجيه السؤال المقيد: "ماذا تريد من تعديل؟"
|
|
44
|
-
│ •
|
|
45
|
-
│
|
|
46
|
-
│ ➔
|
|
47
|
-
│ -
|
|
48
|
-
│ -
|
|
49
|
-
│
|
|
50
|
-
|
|
39
|
+
┌────────────────────────────────────────────────────────────────────────┐
|
|
40
|
+
│ المرحلة الثانية: تقرير Layer.md والاستجواب والتطبيق المباشر بالتوليد │
|
|
41
|
+
│ • صياغة تقرير Layer.md ديناميكياً بالكامل حسب نتائج الفحص الفعلي │
|
|
42
|
+
│ • توجيه السؤال المقيد: "ماذا تريد من تعديل؟" │
|
|
43
|
+
│ • طرح خيارات ذكية مستخلصة حصراً من نواقص أو فرص الصورة المكتشفة │
|
|
44
|
+
│ │
|
|
45
|
+
│ ➔ التطبيق الفوري عبر Image Generator: │
|
|
46
|
+
│ - صياغة برومبت فيزيائي فائق العمق يدمج كافة حقائق مجلد Layers/ │
|
|
47
|
+
│ - تشغيل أداة التوليد الصوري المدمجة فوراً (مثل generate_image │
|
|
48
|
+
│ بمحرك GEMINI Nano Banana في Antigravity) لإنشاء التعديل النهائي! │
|
|
49
|
+
└────────────────────────────────────────────────────────────────────────┘
|
|
51
50
|
```
|
|
52
51
|
|
|
53
52
|
---
|
|
54
53
|
|
|
55
54
|
## 3. المرحلة الأولى: تفكيك وتحليل الطبقات الست (`Layers/`)
|
|
56
55
|
|
|
57
|
-
يقوم النظام
|
|
56
|
+
يقوم النظام تلقائياً بإنشاء مجلد باسم `Layers/` وتوليد 6 صور تحليلية دقيقة:
|
|
58
57
|
|
|
59
58
|
### 1. طبقة الألوان الفاتحة (`01_highlights.png`)
|
|
60
59
|
- **الهدف الفيزيائي**: عزل الأضواء الساطعة وانعكاسات اللمعان (Specular Highlights) حيث الإضاءة $Y > 170/255$.
|
|
61
|
-
- **الفحص المحفوظ بالذاكرة**: حساب نسبة التغطية (`hlCoveragePct`) والذروة الانعكاسية
|
|
60
|
+
- **الفحص المحفوظ بالذاكرة**: حساب نسبة التغطية (`hlCoveragePct`) والذروة الانعكاسية لتحديد درجات اللمعان.
|
|
62
61
|
|
|
63
62
|
### 2. طبقة الألوان الغامقة (`02_shadows.png`)
|
|
64
63
|
- **الهدف الفيزيائي**: عزل المناطق الداكنة والظلال منخفضة المفتاح الضوئي ($Y < 85/255$).
|
|
65
|
-
- **الفحص المحفوظ بالذاكرة**: حساب عمق انضغاط الظل وتحديد
|
|
64
|
+
- **الفحص المحفوظ بالذاكرة**: حساب عمق انضغاط الظل وتحديد مدى الحاجة لرفع الإضاءة المحيطية.
|
|
66
65
|
|
|
67
66
|
### 3. طبقة الظل العالي والارتكاز الأرضي (`03_ambient_occlusion.png`)
|
|
68
67
|
- **الهدف الفيزيائي**: رصد ظلال الانغلاق الموضعي وتجاويف التلامس الحادة ($Y < 35/255$).
|
|
69
|
-
- **الفحص المحفوظ بالذاكرة**: قياس نسبة الارتكاز الأرضي (`aoCoveragePct`). إذا كانت
|
|
68
|
+
- **الفحص المحفوظ بالذاكرة**: قياس نسبة الارتكاز الأرضي (`aoCoveragePct`). إذا كانت $< 2\%$، يتم تسجيل عيب: *"فقدان الارتكاز البصري - العنصر يبدو طافياً"*.
|
|
70
69
|
|
|
71
70
|
### 4. طبقة الحواف والتفاصيل المجهرية (`04_edges.png`)
|
|
72
71
|
- **الهدف الفيزيائي**: استخراج تدرجات سوبل للحواف الأفقية والعمودية $M = \sqrt{G_x^2 + G_y^2}$.
|
|
73
|
-
- **الفحص المحفوظ بالذاكرة**: حساب خشونة السطح المجهرية (`meanGradient`)
|
|
72
|
+
- **الفحص المحفوظ بالذاكرة**: حساب خشونة السطح المجهرية (`meanGradient`) للحفاظ على مسامية وتفاصيل السطح.
|
|
74
73
|
|
|
75
74
|
### 5. طبقة العمق وتنسور المتجهات (`05_depth_normals.png`)
|
|
76
|
-
- **الهدف الفيزيائي**: تحويل تدرجات الإضاءة إلى متجهات عمودية ثلاثية الأبعاد $\vec{N}$ ممثلة في فضاء
|
|
75
|
+
- **الهدف الفيزيائي**: تحويل تدرجات الإضاءة إلى متجهات عمودية ثلاثية الأبعاد $\vec{N}$ ممثلة في فضاء Tangent Normal Map ($R=N_x, G=N_y, B=N_z$).
|
|
77
76
|
- **الفحص المحفوظ بالذاكرة**: استنتاج زاوية سمت الإضاءة (Azimuth $0-360^\circ$) وزاوية الارتفاع (Elevation $0-90^\circ$).
|
|
78
77
|
|
|
79
78
|
### 6. طبقة الألوان والتشبع والبكسلات (`06_chroma_saturation.png`)
|
|
80
|
-
- **الهدف الفيزيائي**: خريطة حرارية للتشبع اللوني
|
|
81
|
-
- **الفحص المحفوظ بالذاكرة**: حساب حرارة اللون الفعلية (CCT Kelvin عبر صيغة McCamy) ومتوسط التشبع اللوني ومناطق
|
|
79
|
+
- **الهدف الفيزيائي**: خريطة حرارية للتشبع اللوني وتوزيع النقاء الطيفي للبكسلات.
|
|
80
|
+
- **الفحص المحفوظ بالذاكرة**: حساب حرارة اللون الفعلية (CCT Kelvin عبر صيغة McCamy) ومتوسط التشبع اللوني ومناطق التوزيع.
|
|
82
81
|
|
|
83
82
|
---
|
|
84
83
|
|
|
85
|
-
## 4. المرحلة الثانية: تقرير `Layer.md`
|
|
86
|
-
|
|
87
|
-
بعد اكتمال فحص الطبقات الست، ينشئ النظام ملف `Layer.md` في مجلد الطبقات أو المستندات، ويخاطب المستخدم وفق الضوابط التالية:
|
|
84
|
+
## 4. المرحلة الثانية: تقرير `Layer.md` والتطبيق المباشر بالـ Image Generator
|
|
88
85
|
|
|
89
86
|
### أ. التقرير الديناميكي حصراً (On-Demand Dynamic Reporting)
|
|
90
|
-
- يُمنع
|
|
91
|
-
- حرارة الألوان المحددة (مثلاً: `3420K` - طيف كهرماني دافئ
|
|
92
|
-
- جهة الضوء وزاويته (مثلاً: سمت `285°` إضاءة جانبية علوية
|
|
93
|
-
- حالة الارتكاز الأرضي
|
|
94
|
-
- حدة الحواف
|
|
87
|
+
- يُمنع استخدام أي نصوص ثابتة؛ بل تُذكر بدقة **الأرقام الفعلية المقاسة** وتفسيرها البصري الواقعي:
|
|
88
|
+
- حرارة الألوان المحددة (مثلاً: `3420K` - طيف كهرماني دافئ).
|
|
89
|
+
- جهة الضوء وزاويته (مثلاً: سمت `285°` إضاءة جانبية علوية).
|
|
90
|
+
- حالة الارتكاز الأرضي وظلال التلامس.
|
|
91
|
+
- حدة الحواف ودرجة التشبع.
|
|
95
92
|
|
|
96
93
|
### ب. السؤال المقيد وخيارات التعديل الموجهة بالبيانات
|
|
97
94
|
يوجه الوكيل السؤال بصيغته الدقيقة:
|
|
98
95
|
> **"ماذا تريد من تعديل؟"**
|
|
99
96
|
|
|
100
|
-
ويعرض تحته خيارات ديناميكية مشتقة حصراً من نواقص أو فرص الصورة
|
|
97
|
+
ويعرض تحته خيارات ديناميكية مشتقة حصراً من نواقص أو فرص الصورة المكتشفة:
|
|
101
98
|
- *إذا رُصد ضعف في الظلال التلامسية*: "خيار 1: توليد وتثبيت ظل تلامسي أرضي (Contact Shadow) لمنع ظهور العنصر كأنه طافٍ."
|
|
102
|
-
- *إذا كان الطيف اللوني متطرفاً*: "خيار 2: معايرة حرارة الألوان من {Kelvin}K إلى 5500K نهارية متوازنة أو
|
|
103
|
-
- *إذا كان التباين حاداً*: "خيار 3: تنعيم التباين ورفع تفاصيل الظلال بنمط
|
|
104
|
-
- *إذا
|
|
105
|
-
|
|
106
|
-
### ج.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
**يقوم الوكيل فوراً بتشغيل أداة التوليد مستخدماً البرومبت الفيزيائي المستخرج لإنشاء النسخة المعدلة التي طلبها المستخدم بأعلى جودة وعمق!**
|
|
113
|
-
- إذا رغب المستخدم بالتعديل المحلي عبر كود، يمكن استخدام أدوات `generate_relight_variations` و `harmonize_composite` أو سكربت بايثون المخصص.
|
|
99
|
+
- *إذا كان الطيف اللوني متطرفاً*: "خيار 2: معايرة حرارة الألوان من {Kelvin}K إلى 5500K نهارية متوازنة أو حرارة سينمائية."
|
|
100
|
+
- *إذا كان التباين حاداً*: "خيار 3: تنعيم التباين ورفع تفاصيل الظلال بنمط إضاءة محيطية متوازنة."
|
|
101
|
+
- *إذا حدد المستخدم طلباً مخصصاً*: "خيار 4: تطبيق التعديل المطلوب: '[User Intent]' مباشرة."
|
|
102
|
+
|
|
103
|
+
### ج. التطبيق المباشر عبر Image Generator (مثل GEMINI Nano Banana في Antigravity)
|
|
104
|
+
> [!IMPORTANT]
|
|
105
|
+
> **التعديل النهائي لا يتم بنسخ معدلة عبر بايثون**! دور بايثون ينتهي عند إتمام الفحص واستخراج طبقات `Layers/`.
|
|
106
|
+
> التطبيق الفعلي للتعديل يتم **مباشرة عبر الـ Image Generator**:
|
|
107
|
+
> 1. يصوغ الوكيل برومبتاً فيزيائياً فائق التفصيل مستمداً من كل ما تم استخلاصه من مجلد `Layers/`.
|
|
108
|
+
> 2. **إذا كان الوكيل يعمل داخل بيئة Antigravity**: يقوم فوراً باستدعاء أداة التوليد الصوري المدمجة `generate_image` لتوليد الصورة المعدلة مباشرة بدقة متناهية!
|
|
114
109
|
|
|
115
110
|
---
|
|
116
111
|
|
|
117
|
-
## 5. صيغ البرومبت الفيزيائية
|
|
112
|
+
## 5. صيغ البرومبت الفيزيائية للـ Image Generator
|
|
113
|
+
|
|
114
|
+
يعمل النظام بتوافق كامل مع **أي Image Generator Model**، مع اعتماد الصيغتين التاليتين:
|
|
118
115
|
|
|
119
|
-
### 1.
|
|
116
|
+
### 1. النمط الوصفي الاستوديوي الطبيعي (Natural Descriptive Studio Prompt):
|
|
120
117
|
```text
|
|
121
118
|
A master-quality studio photograph, [User Desired Modification], optically calibrated to [Measured/Target Kelvin]K lighting at [Azimuth]° azimuth and [Elevation]° elevation, authentic subsurface scattering, physically-grounded ambient occlusion contact shadows firmly anchoring the base plane to the ground, crisp micro-surface geometry (Sobel roughness index [Roughness]), smooth luminance falloff, captured on 85mm prime lens at f/2.0, crystal-clear material boundaries.
|
|
122
119
|
```
|
|
123
120
|
|
|
124
|
-
### 2.
|
|
121
|
+
### 2. نمط الشيدر والمصفوفات الضوئية المكثفة (Dense Optical Shaders - GEMINI Nano Banana):
|
|
125
122
|
```text
|
|
126
123
|
optics relight, [User Desired Modification], cct [Measured/Target Kelvin]K, light vector azimuth [Azimuth] deg elevation [Elevation] deg, surface roughness [Roughness], saturation index [Saturation], ground contact occlusion caster, volumetric photon bounce, high-key rim highlight accents, authentic photometric falloff, denoising strength [0.38 - 0.42]
|
|
127
124
|
```
|
|
128
125
|
|
|
129
126
|
---
|
|
130
127
|
|
|
131
|
-
## 6.
|
|
128
|
+
## 6. بيئة التشغيل وتوصية Antigravity
|
|
132
129
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
# استخراج الطبقات الست ديناميكياً مع تقرير Layer.md
|
|
136
|
-
python scripts/extract_layers.py --image <image_path> --output-dir Layers/
|
|
137
|
-
|
|
138
|
-
# استخراج ديناميكي موجه بهدف مخصص
|
|
139
|
-
python scripts/extract_layers.py --image <image_path> --output-dir Layers/ --intent "إضاءة درامية سينمائية ليلية"
|
|
140
|
-
|
|
141
|
-
# مخرجات JSON برمجية
|
|
142
|
-
python scripts/extract_layers.py --image <image_path> --json
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### ب. عبر خادم MCP (TypeScript Tools):
|
|
146
|
-
- أداة `analyze_optical_profile`:
|
|
147
|
-
```json
|
|
148
|
-
{
|
|
149
|
-
"image_path": "path/to/image.png",
|
|
150
|
-
"extract_layers": true,
|
|
151
|
-
"layers_dir": "Layers",
|
|
152
|
-
"user_intent": "إضافة إضاءة ذهبية دافئة"
|
|
153
|
-
}
|
|
154
|
-
```
|
|
155
|
-
- أداة `synthesize_diffusion_prompt`: لصياغة أوامر التوليد فورياً.
|
|
156
|
-
- أداة `generate_relight_variations`: لتوليد 4 نسخ معدلة ضوئياً فوراً.
|
|
157
|
-
- أداة `harmonize_composite`: للدمج المتناغم مع ظلال الارتكاز الأرضي.
|
|
130
|
+
- **التوافق**: متوافق تماماً مع أي نموذج توليد صور (Any Image Generator Model).
|
|
131
|
+
- **التوصية المثالية**: **يُفضل ويُوصى بشدة بتشغيله داخل Google Antigravity**، حيث تتوفر أداة `generate_image` ونموذج **GEMINI Nano Banana** بصورة مدمجة أصلية تمكن الوكيل من الانتقال اللحظي من فحص `Layers/` إلى إنشاء الصورة المعدلة مباشرة دون وسائط خارجية.
|
|
158
132
|
|
|
159
133
|
---
|
|
160
134
|
|
|
161
135
|
## 7. عقد المظروف القياسي الموحد (Standard Result Envelope)
|
|
162
136
|
|
|
163
|
-
تلتزم كافة
|
|
137
|
+
تلتزم كافة الأدوات بإرجاع المظروف الموحد لـ MarwanDevSpace:
|
|
164
138
|
|
|
165
139
|
```json
|
|
166
140
|
{
|
|
@@ -169,7 +143,7 @@ python scripts/extract_layers.py --image <image_path> --json
|
|
|
169
143
|
"data": {
|
|
170
144
|
"dimensions": [width, height],
|
|
171
145
|
"opticalMetrics": { "cctKelvin": 5500, "lightingAngles": { "azimuthDeg": 45, "elevationDeg": 30 } },
|
|
172
|
-
"diagnostics": { "thermalDescription": "...", "findings": [], "tailoredOptions": [], "
|
|
146
|
+
"diagnostics": { "thermalDescription": "...", "findings": [], "tailoredOptions": [], "universalImagePrompt": "...", "nanoBananaPrompt": "..." },
|
|
173
147
|
"layers": { "highlights": {}, "shadows": {}, "ambientOcclusion": {}, "edges": {}, "depthNormals": {}, "chromaSaturation": {} },
|
|
174
148
|
"layerMarkdownPath": "Layers/Layer.md"
|
|
175
149
|
},
|
|
@@ -189,6 +163,15 @@ python scripts/extract_layers.py --image <image_path> --json
|
|
|
189
163
|
},
|
|
190
164
|
"nextActions": [
|
|
191
165
|
"اعرض الطبقات الست وملف Layer.md واسأل المستخدم: 'ماذا تريد من تعديل؟'",
|
|
192
|
-
"
|
|
166
|
+
"شغل أداة التوليد الصوري المدمجة generate_image فور استلام قرار المستخدم"
|
|
193
167
|
]
|
|
194
|
-
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## 8. كيفية التضمين في `GEMINI.md` أو موجهات النظام
|
|
174
|
+
|
|
175
|
+
1. انسخ محتوى هذا الملف كاملاً.
|
|
176
|
+
2. ضعه في ملف التوجيه العام للوكيل (`GEMINI.md` أو `AGENTS.md`).
|
|
177
|
+
3. سيعمل الوكيل فوراً كمعماري ضوئي مقيد يحلل عبر بايثون ويعدل بالـ Image Generator المباشر في Antigravity.
|
package/README.md
CHANGED
|
@@ -5,7 +5,20 @@
|
|
|
5
5
|
[](https://github.com/MarwanDevSpace/mcp-relight-harmonize/actions)
|
|
6
6
|
[](https://glama.ai/mcp/servers/MarwanDevSpace/mcp-relight-harmonize)
|
|
7
7
|
|
|
8
|
-
**mcp-relight-harmonize** is an enterprise-grade TypeScript Model Context Protocol (MCP) server and Antigravity Skill engineered by **MarwanDevSpace**. It delivers local optical profiling, physically-grounded relighting variations, contact-aware composite harmonization, and precision prompt synthesis
|
|
8
|
+
**mcp-relight-harmonize** is an enterprise-grade TypeScript Model Context Protocol (MCP) server and Antigravity Skill engineered by **MarwanDevSpace**. It delivers local 6-layer optical profiling, physically-grounded relighting variations, contact-aware composite harmonization, and precision diffusion prompt synthesis compatible with **any Image Generator Model** (specifically optimized for **GEMINI Nano Banana**).
|
|
9
|
+
|
|
10
|
+
> [!NOTE]
|
|
11
|
+
> **Antigravity Recommended**: This MCP server and skill is designed to work with **any Image Generator**, and is **strongly preferred and optimized for use inside Google Antigravity** where native desktop image generation (`generate_image`) powered by **GEMINI Nano Banana** is directly embedded into the agent environment.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Strict Two-Phase Role Architecture
|
|
16
|
+
|
|
17
|
+
1. **Phase 1: Python Optical Decomposition (`Layers/`)**:
|
|
18
|
+
- Python's role is strictly limited to deep analytical decomposition of the image into 6 visual layers (`01_highlights.png`, `02_shadows.png`, `03_ambient_occlusion.png`, `04_edges.png`, `05_depth_normals.png`, `06_chroma_saturation.png`) and extracting physical metrics.
|
|
19
|
+
- **Python does NOT generate the user's final modification.**
|
|
20
|
+
2. **Phase 2: Direct Image Generator Modification**:
|
|
21
|
+
- The user's requested edit is executed **directly through the Image Generator** (e.g. `generate_image` in Antigravity) with hyper-depth and photorealistic precision based on everything learned from the 6 layers in `Layers/`.
|
|
9
22
|
|
|
10
23
|
---
|
|
11
24
|
|
|
@@ -18,6 +31,11 @@
|
|
|
18
31
|
- Evaluates photometric luminance dynamic range, specular highlights, and shadow zones.
|
|
19
32
|
- **Dynamic 6-Layer Extraction (`Layers/`):** Decomposes images into 6 visual layers (`01_highlights.png`, `02_shadows.png`, `03_ambient_occlusion.png`, `04_edges.png`, `05_depth_normals.png`, `06_chroma_saturation.png`) and writes on-demand `Layer.md` reports.
|
|
20
33
|
|
|
34
|
+
- **Diffusion Prompt Synthesizer (`synthesize_diffusion_prompt`):**
|
|
35
|
+
- **Universal Image Generator Target:** Formulates natural descriptive studio directives (85mm f/2.0 prime lens, authentic subsurface scattering, photometric falloff, contact shadows).
|
|
36
|
+
- **GEMINI Nano Banana Target:** Formulates dense, tokenized optical shaders (micro-pores, roughness index, raytraced bounce, ground contact shadow caster, exact light azimuth, CCT).
|
|
37
|
+
- Supplies calibrated generation parameters (denoising strength: `0.35 - 0.45`).
|
|
38
|
+
|
|
21
39
|
- **Physical Relighting (`generate_relight_variations`):**
|
|
22
40
|
- **Ambient:** Soft fill light (+0.8 EV), lifted shadows, 5500K neutral daylight calibration.
|
|
23
41
|
- **Dramatic:** Chiaroscuro high-key contrast S-curve, -1.5 EV shadow crush, directional key gradient.
|
|
@@ -29,11 +47,6 @@
|
|
|
29
47
|
- Grounding contact shadow synthesis to anchor the subject to the ground plane.
|
|
30
48
|
- Smooth alpha blend placement eliminating boundary halos.
|
|
31
49
|
|
|
32
|
-
- **Diffusion Prompt Synthesizer (`synthesize_diffusion_prompt`):**
|
|
33
|
-
- **GPT Image Target:** Formulates natural descriptive studio directives (85mm f/2.0 prime lens, authentic subsurface scattering, photometric falloff, contact shadows).
|
|
34
|
-
- **Nano Banana Target:** Formulates dense, tokenized optical shaders (micro-pores, roughness index, raytraced bounce, ground contact shadow caster, exact light azimuth, CCT).
|
|
35
|
-
- Supplies calibrated generation parameters (denoising strength: `0.35 - 0.45`).
|
|
36
|
-
|
|
37
50
|
- **MCP Resources (`optical://presets`):**
|
|
38
51
|
- Read-only JSON specification for lighting presets, EV curves, and color temperature benchmarks.
|
|
39
52
|
|
|
@@ -46,7 +59,7 @@
|
|
|
46
59
|
| `analyze_optical_profile` | `image_path: string`, `extract_layers?: boolean`, `layers_dir?: string`, `user_intent?: string` | JSON technical report: CCT (Kelvin), light vectors, azimuth/elevation, luminance dynamics, and 6 visual analytical layers in `Layers/`. |
|
|
47
60
|
| `generate_relight_variations` | `image_path: string`, `target_lighting?: string`, `output_dir?: string` | 4 generated images (Ambient, Dramatic, Rim, Mood) + EV adjustments log. |
|
|
48
61
|
| `harmonize_composite` | `foreground_path: string`, `background_path: string`, `blend_mode?: string` | Composited image with harmonized CCT, Reinhard color transfer, and contact shadow. |
|
|
49
|
-
| `synthesize_diffusion_prompt` | `image_path: string`, `user_intent?: string`, `target_model?: "
|
|
62
|
+
| `synthesize_diffusion_prompt` | `image_path: string`, `user_intent?: string`, `target_model?: "universal" \| "nano_banana"` | Enhancement prompt, Relighting prompt, and calibrated generation parameters. |
|
|
50
63
|
| `list_cached_variations` | `cache_dir?: string` | Inventory of generated relight variations and composite artifacts in the output cache. |
|
|
51
64
|
|
|
52
65
|
---
|
|
@@ -87,7 +100,7 @@ Add to your client's `mcp_config.json`:
|
|
|
87
100
|
}
|
|
88
101
|
```
|
|
89
102
|
|
|
90
|
-
Or via npx
|
|
103
|
+
Or via npx:
|
|
91
104
|
```json
|
|
92
105
|
{
|
|
93
106
|
"mcpServers": {
|
|
@@ -32,6 +32,6 @@ exports.SynthesizePromptInputSchema = zod_1.z.object({
|
|
|
32
32
|
.describe("Creative description or lighting scenario (e.g., 'sunset golden hour', 'studio product shot')."),
|
|
33
33
|
target_model: zod_1.z
|
|
34
34
|
.string()
|
|
35
|
-
.default("
|
|
36
|
-
.describe("Target generative model: '
|
|
35
|
+
.default("universal")
|
|
36
|
+
.describe("Target generative model format: 'universal' (Natural descriptive studio directives for Any Image Generator) or 'nano_banana' (GEMINI Nano Banana optical shader format)."),
|
|
37
37
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type LightingPreset = "Ambient" | "Dramatic" | "Rim" | "Mood" | "All";
|
|
2
2
|
export type BlendMode = "seamless" | "alpha";
|
|
3
|
-
export type DiffusionModel = "
|
|
3
|
+
export type DiffusionModel = "universal" | "nano_banana";
|
|
4
4
|
export interface LuminanceDynamicRange {
|
|
5
5
|
min: number;
|
|
6
6
|
max: number;
|
|
@@ -55,7 +55,7 @@ export interface HarmonizeCompositeResult {
|
|
|
55
55
|
details: Record<string, any>;
|
|
56
56
|
}
|
|
57
57
|
export interface DiffusionPromptResult {
|
|
58
|
-
targetModel:
|
|
58
|
+
targetModel: string;
|
|
59
59
|
userIntent: string;
|
|
60
60
|
enhancementPrompt: string;
|
|
61
61
|
relightingPrompt: string;
|
|
@@ -72,7 +72,7 @@ function buildDynamicDiagnostics(cctKelvin, azimuthDeg, elevationDeg, hlPct, shP
|
|
|
72
72
|
tailoredOptions.push("دمج العنصر في خلفية جديدة مع مطابقة إحصائيات الألوان ودرجة الحرارة وظلال الارتكاز.");
|
|
73
73
|
}
|
|
74
74
|
const intentClause = userIntent ? `, ${userIntent}` : "";
|
|
75
|
-
const
|
|
75
|
+
const universalPrompt = `A master-quality studio photograph${intentClause}, calibrated optical lighting at ${Math.round(azimuthDeg)}° azimuth ` +
|
|
76
76
|
`and ${Math.round(elevationDeg)}° elevation, authentic ${Math.round(cctKelvin)}K color temperature balance, ` +
|
|
77
77
|
`physically-grounded ambient occlusion contact shadows firmly anchoring the base plane, ` +
|
|
78
78
|
`crisp micro-surface geometry (Sobel roughness index ${meanGradient.toFixed(3)}), ` +
|
|
@@ -85,7 +85,7 @@ function buildDynamicDiagnostics(cctKelvin, azimuthDeg, elevationDeg, hlPct, shP
|
|
|
85
85
|
thermalDescription: thermalDesc,
|
|
86
86
|
findings,
|
|
87
87
|
tailoredOptions,
|
|
88
|
-
|
|
88
|
+
universalImagePrompt: universalPrompt,
|
|
89
89
|
nanoBananaPrompt: nanoPrompt,
|
|
90
90
|
};
|
|
91
91
|
}
|
|
@@ -268,14 +268,16 @@ ${findingsRendered}
|
|
|
268
268
|
|
|
269
269
|
---
|
|
270
270
|
|
|
271
|
-
## 3. التوجيه التوليدي المخصص (Calibrated Prompts for
|
|
271
|
+
## 3. التوجيه التوليدي المخصص (Calibrated Prompts for Image Generators)
|
|
272
272
|
|
|
273
|
-
### أ.
|
|
274
|
-
> "${diagnostics.
|
|
273
|
+
### أ. النمط الوصفي الاستوديوي (Any Image Generator Model):
|
|
274
|
+
> "${diagnostics.universalImagePrompt}"
|
|
275
275
|
|
|
276
|
-
### ب.
|
|
276
|
+
### ب. نمط الشيدر الضوئي المكثف (GEMINI Nano Banana - Antigravity):
|
|
277
277
|
> "${diagnostics.nanoBananaPrompt}"
|
|
278
278
|
|
|
279
|
+
> 💡 **ملاحظة**: هذا التوجيه متوافق مع **أي Image Generator Model**، ويُفضل ويُوصى بشدة باستخدامه داخل **Google Antigravity** لتطبيق التعديل المباشر عبر أداة \`generate_image\` ومحرك **GEMINI Nano Banana**!
|
|
280
|
+
|
|
279
281
|
---
|
|
280
282
|
|
|
281
283
|
## 4. الخطوة التفاعلية الموجهة بالبيانات (Dynamic Interactive Decision)
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.synthesizeDiffusionPromptImpl = synthesizeDiffusionPromptImpl;
|
|
4
4
|
const optical_analyzer_1 = require("./optical_analyzer");
|
|
5
|
-
function synthesizeDiffusionPromptImpl(imagePath, userIntent = "", targetModel = "
|
|
5
|
+
function synthesizeDiffusionPromptImpl(imagePath, userIntent = "", targetModel = "universal") {
|
|
6
6
|
const profile = (0, optical_analyzer_1.analyzeOpticalProfileImpl)(imagePath);
|
|
7
|
-
const normalizedModel = targetModel.toLowerCase().includes("banana")
|
|
7
|
+
const normalizedModel = targetModel.toLowerCase().includes("banana")
|
|
8
|
+
? "GEMINI Nano Banana"
|
|
9
|
+
: "Universal Image Generator";
|
|
8
10
|
const cct = Math.round(profile.colorTemperatureKelvin);
|
|
9
11
|
const azimuth = profile.lightingAngles.azimuthDeg;
|
|
10
12
|
const elevation = profile.lightingAngles.elevationDeg;
|
|
@@ -50,7 +52,7 @@ function synthesizeDiffusionPromptImpl(imagePath, userIntent = "", targetModel =
|
|
|
50
52
|
let enhancementPrompt = "";
|
|
51
53
|
let relightingPrompt = "";
|
|
52
54
|
let recommendedParameters = {};
|
|
53
|
-
if (normalizedModel === "
|
|
55
|
+
if (normalizedModel === "Universal Image Generator") {
|
|
54
56
|
enhancementPrompt =
|
|
55
57
|
`A master-quality studio photograph, exquisite micro-surface textures, pores and fine material grain, ` +
|
|
56
58
|
`subsurface scattering, 85mm prime lens at f/2.0, razor-sharp optical boundary and crystal-clear geometry${cleanIntent}.`;
|
|
@@ -59,16 +61,17 @@ function synthesizeDiffusionPromptImpl(imagePath, userIntent = "", targetModel =
|
|
|
59
61
|
`${cctTerm}, ${contrastTerm}, subtle rim lighting tracing the outer silhouette, volumetric dust rays visible in the air, ` +
|
|
60
62
|
`physically-based contact shadows naturally anchoring the base to the ground plane, authentic photometric falloff${cleanIntent}.`;
|
|
61
63
|
recommendedParameters = {
|
|
62
|
-
model: "
|
|
64
|
+
model: "universal-image-generator",
|
|
63
65
|
style: "natural",
|
|
64
66
|
quality: "hd",
|
|
65
67
|
camera_lens: "85mm prime f/2.0",
|
|
66
68
|
denoising_strength: 0.38,
|
|
67
69
|
recommended_dimensions: `${profile.dimensions[0]}x${profile.dimensions[1]}`,
|
|
70
|
+
compatibility: "Works with any Image Generator Model; optimized for Antigravity",
|
|
68
71
|
};
|
|
69
72
|
}
|
|
70
73
|
else {
|
|
71
|
-
// Nano Banana Target
|
|
74
|
+
// GEMINI Nano Banana Target
|
|
72
75
|
enhancementPrompt =
|
|
73
76
|
`ultra-detailed optical capture, raw sensor clarity, 8k uhd, micro-pores, surface specular roughness index ${profile.surfaceNormalVariation.toFixed(3)}, ` +
|
|
74
77
|
`zero chromatic aberration, pristine alpha edge delineation${cleanIntent}`;
|
|
@@ -77,7 +80,8 @@ function synthesizeDiffusionPromptImpl(imagePath, userIntent = "", targetModel =
|
|
|
77
80
|
`volumetric raytraced bounce, physically-grounded ground contact shadow, ambient occlusion caster, ` +
|
|
78
81
|
`denoising 0.38, light_azimuth_${Math.round(azimuth)}deg${cleanIntent}`;
|
|
79
82
|
recommendedParameters = {
|
|
80
|
-
model: "nano-banana
|
|
83
|
+
model: "gemini-nano-banana",
|
|
84
|
+
target_environment: "Google Antigravity",
|
|
81
85
|
denoising_strength: 0.38,
|
|
82
86
|
guidance_scale: 4.5,
|
|
83
87
|
steps: 32,
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ async function main() {
|
|
|
8
8
|
const args = process.argv.slice(2);
|
|
9
9
|
if (args.includes("--verify")) {
|
|
10
10
|
console.log("[MarwanDevSpace] Verifying TypeScript mcp-relight-harmonize server...");
|
|
11
|
-
console.log("Server 'mcp-relight-harmonize' v1.0.
|
|
11
|
+
console.log("Server 'mcp-relight-harmonize' v1.0.4 initialized.");
|
|
12
12
|
console.log("Registered tools: ['analyze_optical_profile', 'generate_relight_variations', 'harmonize_composite', 'synthesize_diffusion_prompt', 'list_cached_variations']");
|
|
13
13
|
console.log("Registered resources: ['optical://presets']");
|
|
14
14
|
console.log("Output cache directory:", (0, config_1.ensureOutputDirectory)());
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LIGHTING_PRESETS_REFERENCE = void 0;
|
|
4
4
|
exports.getPresetsJson = getPresetsJson;
|
|
5
5
|
exports.LIGHTING_PRESETS_REFERENCE = {
|
|
6
|
-
version: "1.0.
|
|
7
|
-
target_generators: ["
|
|
6
|
+
version: "1.0.4",
|
|
7
|
+
target_generators: ["Universal Image Generator", "GEMINI Nano Banana"],
|
|
8
8
|
presets: [
|
|
9
9
|
{
|
|
10
10
|
name: "Ambient",
|
package/dist/server.js
CHANGED
|
@@ -46,7 +46,7 @@ const StandardEnvelopeSchema = {
|
|
|
46
46
|
function createServer() {
|
|
47
47
|
const server = new index_js_1.Server({
|
|
48
48
|
name: "mcp-relight-harmonize",
|
|
49
|
-
version: "1.0.
|
|
49
|
+
version: "1.0.4",
|
|
50
50
|
}, {
|
|
51
51
|
capabilities: {
|
|
52
52
|
tools: {},
|
|
@@ -161,7 +161,7 @@ function createServer() {
|
|
|
161
161
|
"• When to use: Use when you need tangible image alternatives of a photo or product render with alternative lighting schemes.\n" +
|
|
162
162
|
"• When NOT to use: Do NOT use if you only need optical metrics (use 'analyze_optical_profile'), if blending a cutout into a background " +
|
|
163
163
|
"(use 'harmonize_composite'), or if you need diffusion AI text prompts (use 'synthesize_diffusion_prompt').\n" +
|
|
164
|
-
"• Alternatives: Use 'synthesize_diffusion_prompt' for
|
|
164
|
+
"• Alternatives: Use 'synthesize_diffusion_prompt' for your Image Generator (GEMINI Nano Banana / Universal), or 'list_cached_variations' to browse existing outputs.",
|
|
165
165
|
inputSchema: {
|
|
166
166
|
type: "object",
|
|
167
167
|
properties: {
|
|
@@ -280,12 +280,12 @@ function createServer() {
|
|
|
280
280
|
{
|
|
281
281
|
name: "synthesize_diffusion_prompt",
|
|
282
282
|
description: "Synthesize precision enhancement and relighting diffusion prompts based on physical optical analysis of an image, " +
|
|
283
|
-
"
|
|
283
|
+
"compatible with Any Image Generator Model (optimized for GEMINI Nano Banana). Outputs photorealistic prompts with physical keywords " +
|
|
284
284
|
"(exact Kelvin CCT, 3D light angles, volumetric dust rays, contact shadows) and calibrated denoising parameters (0.35 - 0.45).\n\n" +
|
|
285
285
|
"• Purpose: Generative AI prompt synthesis. Unlike 'generate_relight_variations' which creates image files locally, this tool translates " +
|
|
286
|
-
"optical geometry into targeted text prompts and hyperparameter sets for
|
|
286
|
+
"optical geometry into targeted text prompts and hyperparameter sets for Any Image Generator (optimized for Antigravity).\n" +
|
|
287
287
|
"• Behavior: Completely read-only, deterministic, zero filesystem modifications, no network calls, and no authentication required.\n" +
|
|
288
|
-
"• When to use: Use when you want to feed photorealistic lighting directives or inpainting prompts into
|
|
288
|
+
"• When to use: Use when you want to feed photorealistic lighting directives or inpainting prompts into your Image Generator or Antigravity's generate_image.\n" +
|
|
289
289
|
"• When NOT to use: Do NOT use if you need local image rendering without an external AI model (use 'generate_relight_variations'), " +
|
|
290
290
|
"or if merging cutouts locally (use 'harmonize_composite').\n" +
|
|
291
291
|
"• Alternatives: Use 'generate_relight_variations' for instant offline image files, or 'analyze_optical_profile' for raw numerical statistics.",
|
|
@@ -303,10 +303,10 @@ function createServer() {
|
|
|
303
303
|
},
|
|
304
304
|
target_model: {
|
|
305
305
|
type: "string",
|
|
306
|
-
enum: ["
|
|
307
|
-
default: "
|
|
308
|
-
description: "Target generative engine: '
|
|
309
|
-
"or 'nano_banana' (outputs dense tokenized optical shaders
|
|
306
|
+
enum: ["universal", "nano_banana"],
|
|
307
|
+
default: "universal",
|
|
308
|
+
description: "Target generative engine format: 'universal' (outputs natural descriptive studio directives with 85mm prime lens and physical illumination compatible with Any Image Generator) " +
|
|
309
|
+
"or 'nano_banana' (outputs dense tokenized optical shaders for GEMINI Nano Banana). Defaults to 'universal'.",
|
|
310
310
|
},
|
|
311
311
|
},
|
|
312
312
|
required: ["image_path"],
|
|
@@ -318,7 +318,7 @@ function createServer() {
|
|
|
318
318
|
data: {
|
|
319
319
|
type: "object",
|
|
320
320
|
properties: {
|
|
321
|
-
targetModel: { type: "string"
|
|
321
|
+
targetModel: { type: "string" },
|
|
322
322
|
userIntent: { type: "string" },
|
|
323
323
|
enhancementPrompt: { type: "string", description: "Prompt for micro-surface detail and lens clarity upgrade." },
|
|
324
324
|
relightingPrompt: { type: "string", description: "Prompt for physical relighting with angles, CCT, and contact shadows." },
|
|
@@ -419,7 +419,7 @@ function createServer() {
|
|
|
419
419
|
case "synthesize_diffusion_prompt": {
|
|
420
420
|
const imagePath = String(args.image_path || "");
|
|
421
421
|
const userIntent = String(args.user_intent || "");
|
|
422
|
-
const targetModel = String(args.target_model || "
|
|
422
|
+
const targetModel = String(args.target_model || "universal");
|
|
423
423
|
envelope = (0, synthesize_prompt_1.synthesizeDiffusionPromptTool)(imagePath, userIntent, targetModel);
|
|
424
424
|
break;
|
|
425
425
|
}
|
|
@@ -28,7 +28,7 @@ function analyzeOpticalProfileTool(imagePath, extractLayers = false, layersDir,
|
|
|
28
28
|
}
|
|
29
29
|
const nextActions = [
|
|
30
30
|
`Call 'generate_relight_variations' on '${imagePath}' to explore alternative lighting schemes.`,
|
|
31
|
-
`Call 'synthesize_diffusion_prompt'
|
|
31
|
+
`Call 'synthesize_diffusion_prompt' for your Image Generator (GEMINI Nano Banana / Universal) or trigger 'generate_image'.`,
|
|
32
32
|
];
|
|
33
33
|
if (layerReport) {
|
|
34
34
|
nextActions.unshift(`Inspect 6 analytical layers and Layer.md, then present to user with prompt: 'ماذا تريد من تعديل؟'`);
|
|
@@ -25,7 +25,7 @@ function generateRelightVariationsTool(imagePath, targetLighting = "All", output
|
|
|
25
25
|
},
|
|
26
26
|
nextActions: [
|
|
27
27
|
"Review generated variation files to inspect aesthetic illumination.",
|
|
28
|
-
"Use 'synthesize_diffusion_prompt' for
|
|
28
|
+
"Use 'synthesize_diffusion_prompt' for your Image Generator (GEMINI Nano Banana / Universal) or trigger 'generate_image'.",
|
|
29
29
|
],
|
|
30
30
|
});
|
|
31
31
|
}
|
package/dist/tools/harmonize.js
CHANGED
|
@@ -32,7 +32,7 @@ function harmonizeCompositeTool(foregroundPath, backgroundPath, blendMode = "sea
|
|
|
32
32
|
},
|
|
33
33
|
nextActions: [
|
|
34
34
|
`Inspect the composite output at '${result.compositeImagePath}'.`,
|
|
35
|
-
"Call 'synthesize_diffusion_prompt'
|
|
35
|
+
"Call 'synthesize_diffusion_prompt' for your Image Generator (GEMINI Nano Banana / Universal) or trigger 'generate_image'.",
|
|
36
36
|
],
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -8,7 +8,7 @@ const crypto_1 = __importDefault(require("crypto"));
|
|
|
8
8
|
const envelope_1 = require("../core/envelope");
|
|
9
9
|
const errors_1 = require("../core/errors");
|
|
10
10
|
const prompt_synthesizer_1 = require("../domain/prompt_synthesizer");
|
|
11
|
-
function synthesizeDiffusionPromptTool(imagePath, userIntent = "", targetModel = "
|
|
11
|
+
function synthesizeDiffusionPromptTool(imagePath, userIntent = "", targetModel = "universal") {
|
|
12
12
|
try {
|
|
13
13
|
const result = (0, prompt_synthesizer_1.synthesizeDiffusionPromptImpl)(imagePath, userIntent, targetModel);
|
|
14
14
|
const hash = crypto_1.default
|
package/docs/architecture.md
CHANGED
|
@@ -63,7 +63,7 @@ graph TD
|
|
|
63
63
|
A --> E["harmonize_composite"]
|
|
64
64
|
E -->|Composite Image + Grounding| C
|
|
65
65
|
D --> F["4 Relit Variations (Ambient, Dramatic, Rim, Mood)"]
|
|
66
|
-
C --> G["Model Prompts (
|
|
66
|
+
C --> G["Model Prompts (Any Image Generator / GEMINI Nano Banana)"]
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
### Evidence Chaining Rules
|
|
@@ -114,7 +114,7 @@ The repository integrates directly into the Antigravity agent architecture as an
|
|
|
114
114
|
├── references/
|
|
115
115
|
│ ├── optical_math.md # CIE XYZ, McCamy CCT, Normal tensors, Reinhard
|
|
116
116
|
│ ├── tool_orchestration.md # Interconnection criteria, evidence chaining, fallback rules
|
|
117
|
-
│ └── diffusion_guide.md # Prompt tokens & parameters for
|
|
117
|
+
│ └── diffusion_guide.md # Prompt tokens & parameters for Any Image Generator / GEMINI Nano Banana
|
|
118
118
|
└── scripts/
|
|
119
119
|
├── run_pipeline.py # Standalone CLI pipeline runner
|
|
120
120
|
└── verify_server.py # Self-contained tool & resource verifier
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-relight-harmonize",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Professional TypeScript Model Context Protocol (MCP) server & agent skill for optical profiling, physical relighting, composite harmonization, and diffusion prompt synthesis (
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Professional TypeScript Model Context Protocol (MCP) server & agent skill for optical profiling, physical relighting, composite harmonization, and diffusion prompt synthesis (Any Image Generator Model / GEMINI Nano Banana).",
|
|
5
5
|
"author": "MarwanDevSpace <dev@marwandevspace.io>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"relight",
|
|
25
25
|
"harmonize",
|
|
26
26
|
"optical-analysis",
|
|
27
|
-
"
|
|
27
|
+
"image-generator",
|
|
28
28
|
"nano-banana",
|
|
29
29
|
"marwandevspace"
|
|
30
30
|
],
|