Updated code

This commit is contained in:
2026-03-05 20:27:35 -05:00
parent 13753359b3
commit 8b57eeb108
3 changed files with 225 additions and 30 deletions

View File

@@ -0,0 +1,168 @@
import json
import os
import sys
import base64
import subprocess
# Dependency Check
try:
import requests
except ImportError:
print("❌ Error: requests library not found.")
print("👉 Please run: pip install requests pillow")
sys.exit(1)
try:
from PIL import Image
except ImportError:
print("❌ Error: Pillow library not found.")
print("👉 Please run: pip install requests pillow")
sys.exit(1)
# ============================================================
# CONFIGURATION — Set your Gemini API key here
# ============================================================
GEMINI_API_KEY = "YOUR_GEMINI_API_KEY_HERE"
# ============================================================
# Paths
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
BASE_DIR = os.path.dirname(SCRIPT_DIR)
PROMPTS_FILE = os.path.join(SCRIPT_DIR, "image_generation_prompts.json")
RAW_ASSETS_DIR = os.path.join(BASE_DIR, "Raw_Assets")
RESIZE_SCRIPT = os.path.join(SCRIPT_DIR, "resize_assets.py")
# Gemini Imagen API endpoint
IMAGEN_MODEL = "imagen-3.0-generate-001"
IMAGEN_URL = (
f"https://generativelanguage.googleapis.com/v1beta/models/"
f"{IMAGEN_MODEL}:predict?key={GEMINI_API_KEY}"
)
def load_prompts():
"""Load image prompts from the JSON config file."""
if not os.path.exists(PROMPTS_FILE):
print(f"❌ Error: Prompts file not found: {PROMPTS_FILE}")
sys.exit(1)
with open(PROMPTS_FILE, "r", encoding="utf-8") as f:
data = json.load(f)
return data.get("images", [])
def generate_image(name, prompt):
"""Call the Gemini Imagen API and return raw PNG bytes, or None on failure."""
payload = {
"instances": [{"prompt": prompt}],
"parameters": {"sampleCount": 1},
}
try:
response = requests.post(IMAGEN_URL, json=payload, timeout=120)
response.raise_for_status()
except requests.exceptions.HTTPError as e:
print(f" ❌ HTTP error for '{name}': {e}")
print(f" Response: {response.text[:300]}")
return None
except requests.exceptions.RequestException as e:
print(f" ❌ Request failed for '{name}': {e}")
return None
result = response.json()
predictions = result.get("predictions", [])
if not predictions:
print(f" ❌ No predictions returned for '{name}'.")
return None
b64_data = predictions[0].get("bytesBase64Encoded")
if not b64_data:
print(f" ❌ No image data in response for '{name}'.")
return None
return base64.b64decode(b64_data)
def save_image(name, image_bytes):
"""Save raw bytes as a PNG file in Raw_Assets/."""
output_path = os.path.join(RAW_ASSETS_DIR, f"{name}.png")
with open(output_path, "wb") as f:
f.write(image_bytes)
return output_path
def run_resize_script():
"""Run resize_assets.py as a subprocess."""
print("\n🔧 Running resize_assets.py...")
try:
result = subprocess.run(
[sys.executable, RESIZE_SCRIPT],
check=True,
capture_output=True,
text=True,
)
print(result.stdout)
if result.stderr:
print(result.stderr)
except subprocess.CalledProcessError as e:
print(f"❌ resize_assets.py failed: {e}")
if e.stdout:
print(e.stdout)
if e.stderr:
print(e.stderr)
def main():
print("🚀 IYmtg Image Generation Pipeline")
print("=" * 40)
if GEMINI_API_KEY == "YOUR_GEMINI_API_KEY_HERE":
print("❌ Error: Gemini API key not set.")
print("👉 Open this script and set GEMINI_API_KEY at the top.")
sys.exit(1)
# Ensure Raw_Assets directory exists
os.makedirs(RAW_ASSETS_DIR, exist_ok=True)
print(f"📂 Output directory: {RAW_ASSETS_DIR}\n")
prompts = load_prompts()
print(f"📋 Loaded {len(prompts)} image prompt(s) from {os.path.basename(PROMPTS_FILE)}\n")
generated = 0
failed = 0
for item in prompts:
name = item.get("name")
prompt = item.get("prompt")
if not name or not prompt:
print(f"⚠️ Skipping entry with missing 'name' or 'prompt': {item}")
continue
print(f"🎨 Generating: {name}")
print(f" Prompt: {prompt[:80]}{'...' if len(prompt) > 80 else ''}")
image_bytes = generate_image(name, prompt)
if image_bytes is None:
failed += 1
continue
try:
path = save_image(name, image_bytes)
print(f" ✅ Saved: {os.path.basename(path)}")
generated += 1
except OSError as e:
print(f" ❌ Failed to save '{name}': {e}")
failed += 1
print(f"\n{'=' * 40}")
print(f"✅ Generated: {generated} | ❌ Failed: {failed}")
if generated > 0:
run_resize_script()
else:
print("\n⚠️ No images were generated. Skipping resize step.")
print("\n✅ Done.")
if __name__ == "__main__":
main()

View File

@@ -1,41 +1,45 @@
# AI Blueprint
# AI Blueprint: Full Project Readiness Audit
This document outlines the architecture and plan for development tasks. It is intended to be used by the development team to guide implementation.
## Goal
## Instructions for the Architect AI
To perform a comprehensive audit of the `IYmtg_App_iOS` project to ensure it can be compiled without errors and to identify any missing or incomplete features before handing it off to a human developer.
1. **Understand the Goal:** Your primary role is to understand the user's request and create a detailed, step-by-step plan for another AI (Claude) to execute. You do not write code.
2. **Analyze the codebase:** Use the available tools to explore the existing files and understand the current state of the project.
3. **Create a Plan:** Based on the user's request and your analysis, create a comprehensive plan. This plan should be broken down into clear, actionable steps. Each step should include:
* A description of the task.
* The specific files to be modified.
* The high-level changes required.
4. **Update this Blueprint:** Overwrite this `ai_blueprint.md` file with the generated plan.
5. **Include README and Commit Steps:** The plan must always include steps for:
* Updating the `README.md` if the changes affect the project's description, setup, or usage.
* Creating a Git commit with a descriptive message to save the changes.
6. **Delegate Implementation:** After creating the plan, your job is complete. Another AI will take over to implement the plan.
## Audit Steps for Claude
## Development Plan
1. **Dependency Verification:**
* Review the project's dependencies. Since this is a Swift project, check for any package manager configurations (like Swift Package Manager, CocoaPods, or Carthage). If any are found, ensure all required dependencies are listed and correctly configured.
* Verify that all required versions of dependencies are compatible with the project's Swift version.
> **Note to the Architect AI:** Replace this section with the actual plan for the user's request.
2. **File and Resource Integrity Check:**
* Scan the project for any missing files or broken links. Pay close attention to assets, storyboards, and any other resources referenced in the code.
* Ensure all necessary `.swift` files are included in the build targets.
### 1. Analyze Existing Code
3. **Static Code Analysis:**
* Perform a static analysis of the entire Swift codebase in `IYmtg_App_iOS/`.
* Look for common compilation issues such as:
* Syntax errors.
* Type mismatches.
* Unresolved identifiers (e.g., variables or functions that are used but not defined).
* Incorrect use of optionals.
* API deprecation warnings.
- **File:** `[Path to relevant file]`
- **Description:** Briefly describe the purpose of the file and the area to be modified.
4. **Feature Completeness Review:**
* Examine the code for any features that are stubbed out, marked with `// TODO:`, `// FIXME:`, or are otherwise incomplete.
* Pay special attention to the `Features` directory (`IYmtg_App_iOS/Features/`) to assess the state of each feature (CardDetail, Collection, Help, Scanner).
* Check for any disabled or commented-out code that might indicate an incomplete feature.
### 2. Implement Changes
5. **Audit Summary Report:**
* Create a summary of all findings in a new file named `claude_review_summary.md`.
* For each issue, provide a description, the file path, and the relevant line number(s).
* Categorize the issues by severity (e.g., Blocker, Critical, Major, Minor).
- **File:** `[Path to file to be created or modified]`
- **Description:** Detail the changes to be made. For new files, describe the file's purpose and structure.
6. **Update README.md:**
* Add a new section to the `README.md` file titled "Project Audit".
* Under this section, add a brief summary of the audit's outcome and a link to the `claude_review_summary.md` file.
### 3. Update Documentation
7. **Create Git Commit:**
* Stage all the changes (the new `claude_review_summary.md` and the updated `README.md`).
* Create a Git commit with the message: "feat: Complete project readiness audit".
- **File:** [`README.md`](README.md)
- **Description:** Update the README to reflect the new changes, features, or bug fixes.
### 4. Commit Changes
- **Action:** Create a Git commit.
- **Commit Message:** `feat: [A brief, descriptive message of the changes]`
8. **Increment Project Version:**
* If the audit reveals significant issues that require code changes, increment the project's build number. If no significant issues are found, this step can be skipped. The location of the version number is likely in the project's settings or an `Info.plist` file.

23
architect_instructions.md Normal file
View File

@@ -0,0 +1,23 @@
# Architect AI Instructions
This document contains the instructions for the Architect AI (Roo).
## My Role
My primary role is to act as a technical planner and architect. I do not write implementation code. My goal is to understand the user's request, analyze the existing codebase, and produce a clear, step-by-step plan for another AI (Claude) to execute.
## My Process
1. **Information Gathering:** I will use the available tools to explore the codebase and gather context relevant to the user's request. This includes reading files, searching for code, and listing files.
2. **Clarification:** If the user's request is ambiguous, I will ask clarifying questions to ensure I have all the necessary details before creating a plan.
3. **Planning:** I will create a detailed, step-by-step plan. This plan will be written to the `ai_blueprint.md` file, and will overwrite the file if it already exists.
4. **Plan Contents:** Each plan I create in `ai_blueprint.md` must include:
* A high-level overview of the goal.
* A sequential list of tasks for the implementation AI.
* Specific file paths that need to be created or modified.
* High-level descriptions of the changes required.
* A mandatory step to update the `README.md` if necessary.
* A mandatory step to create a Git commit with a descriptive message.
* A mandatory step to increment the project version number.
5. **No Coding:** I will not write or modify any code files (e.g., `.swift`, `.py`, `.js`). My modifications are restricted to markdown files (`.md`). Providing code snippets within markdown files is acceptable for planning purposes, but I will not directly execute or create code files.
6. **Handoff:** Once the plan is written to `ai_blueprint.md`, my task is complete. I will inform the user that the plan is ready for the implementation phase.