generated from Templates/Docker_Image
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9615c50ccb | |||
| 9fcf2e2d1a | |||
| 67df87072d | |||
| ef249dfbe6 | |||
| 8bbbf6b9ac | |||
| 7f12034bff | |||
| 4430348168 | |||
| 578be7b6f4 | |||
| dbcd3fba91 | |||
| 0eb0bc0d41 | |||
| a73644b1da | |||
| 4c7a089753 | |||
| 4d70a98902 | |||
| f65f0b3603 | |||
| fec96cd049 | |||
| 25b180a2f3 | |||
| 45bcbfe80d | |||
| d82b811e55 |
@@ -46,7 +46,7 @@ create_file() {
|
||||
}
|
||||
|
||||
get_commit_range() {
|
||||
rm $TEMP_FILE_PATH/messages.txt
|
||||
rm -f $TEMP_FILE_PATH/messages.txt
|
||||
if [[ $LAST_TAG =~ $PATTERN ]]; then
|
||||
create_file true
|
||||
else
|
||||
|
||||
@@ -1,6 +1,43 @@
|
||||
FROM alpine
|
||||
# AI Software Factory Dockerfile
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
|
||||
# Set work directory
|
||||
WORKDIR /app
|
||||
COPY ./ai_test/* /app
|
||||
|
||||
CMD ["sh", "/app/hello_world.sh"]
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install dependencies
|
||||
COPY ./ai_software_factory/requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy application code
|
||||
COPY ./ai_software_factory .
|
||||
|
||||
# Set up environment file if it exists, otherwise use .env.example
|
||||
# RUN if [ -f .env ]; then \
|
||||
# cat .env; \
|
||||
# elif [ -f .env.example ]; then \
|
||||
# cp .env.example .env; \
|
||||
# fi
|
||||
|
||||
# Initialize database tables (use SQLite by default, can be overridden by DB_POOL_SIZE env var)
|
||||
# RUN python database.py || true
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8000/health || exit 1
|
||||
|
||||
# Run application
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]"]
|
||||
|
||||
87
HISTORY.md
87
HISTORY.md
@@ -5,10 +5,97 @@ Changelog
|
||||
(unreleased)
|
||||
------------
|
||||
|
||||
Fix
|
||||
~~~
|
||||
- Add missing jijna2 reference, refs NOISSUE. [Simon Diesenreiter]
|
||||
|
||||
|
||||
0.2.1 (2026-04-04)
|
||||
------------------
|
||||
|
||||
Fix
|
||||
~~~
|
||||
- Make dashbaord work, refs NOISSUE. [Simon Diesenreiter]
|
||||
|
||||
Other
|
||||
~~~~~
|
||||
|
||||
|
||||
0.2.0 (2026-04-04)
|
||||
------------------
|
||||
- Feat: Add Python-native dashboard and main.py cleanup, refs NOISSUE.
|
||||
[Simon Diesenreiter]
|
||||
|
||||
|
||||
0.1.8 (2026-04-04)
|
||||
------------------
|
||||
|
||||
Fix
|
||||
~~~
|
||||
- Broken python module references, refs NOISSUE. [Simon Diesenreiter]
|
||||
|
||||
Other
|
||||
~~~~~
|
||||
|
||||
|
||||
0.1.7 (2026-04-04)
|
||||
------------------
|
||||
|
||||
Fix
|
||||
~~~
|
||||
- More bugfixes, refs NOISSUE. [Simon Diesenreiter]
|
||||
|
||||
Other
|
||||
~~~~~
|
||||
|
||||
|
||||
0.1.6 (2026-04-04)
|
||||
------------------
|
||||
|
||||
Fix
|
||||
~~~
|
||||
- Proper containerfile, refs NOISSUE. [Simon Diesenreiter]
|
||||
|
||||
Other
|
||||
~~~~~
|
||||
- Chore: update Containerfile to start the app instead of hello world
|
||||
refs NOISSUE. [Simon Diesenreiter]
|
||||
|
||||
|
||||
0.1.5 (2026-04-04)
|
||||
------------------
|
||||
|
||||
Fix
|
||||
~~~
|
||||
- Bugfix in version generation, refs NOISSUE. [Simon Diesenreiter]
|
||||
|
||||
Other
|
||||
~~~~~
|
||||
- Feat(ai-software-factory): add n8n setup agent and enhance
|
||||
orchestration refs NOISSUE. [Simon Diesenreiter]
|
||||
|
||||
|
||||
0.1.4 (2026-04-02)
|
||||
------------------
|
||||
|
||||
Fix
|
||||
~~~
|
||||
- Fix container build, refs NOISSUE. [Simon Diesenreiter]
|
||||
|
||||
Other
|
||||
~~~~~
|
||||
|
||||
|
||||
0.1.3 (2026-04-02)
|
||||
------------------
|
||||
|
||||
Fix
|
||||
~~~
|
||||
- Fix version increment logic, refs NOISSUE. [Simon Diesenreiter]
|
||||
|
||||
Other
|
||||
~~~~~
|
||||
|
||||
|
||||
0.1.2 (2026-04-02)
|
||||
------------------
|
||||
|
||||
@@ -10,13 +10,20 @@ OLLAMA_URL=http://localhost:11434
|
||||
OLLAMA_MODEL=llama3
|
||||
|
||||
# Gitea
|
||||
# Configure Gitea API for your organization
|
||||
# GITEA_URL can be left empty to use GITEA_ORGANIZATION instead of GITEA_OWNER
|
||||
GITEA_URL=https://gitea.yourserver.com
|
||||
GITEA_TOKEN=your_gitea_api_token
|
||||
GITEA_OWNER=ai-test
|
||||
GITEA_REPO=ai-test
|
||||
GITEA_OWNER=your_organization_name
|
||||
GITEA_REPO= (optional - leave empty for any repo, or specify a default)
|
||||
|
||||
# n8n
|
||||
# n8n webhook for Telegram integration
|
||||
N8N_WEBHOOK_URL=http://n8n.yourserver.com/webhook/telegram
|
||||
# n8n API for automatic webhook configuration
|
||||
N8N_API_URL=http://n8n.yourserver.com
|
||||
N8N_USER=n8n_admin
|
||||
N8N_PASSWORD=your_secure_password
|
||||
|
||||
# Telegram
|
||||
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
# AI Software Factory Dockerfile
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
|
||||
# Set work directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
# Set up environment file if it exists, otherwise use .env.example
|
||||
RUN if [ -f .env ]; then \
|
||||
cat .env; \
|
||||
elif [ -f .env.example ]; then \
|
||||
cp .env.example .env; \
|
||||
fi
|
||||
|
||||
# Initialize database tables (use SQLite by default, can be overridden by DB_POOL_SIZE env var)
|
||||
RUN python database.py || true
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8000/health || exit 1
|
||||
|
||||
# Run application
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
||||
@@ -1 +1 @@
|
||||
0.1.3
|
||||
0.2.2
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"""AI Software Factory agents."""
|
||||
|
||||
from ai_software_factory.agents.orchestrator import AgentOrchestrator
|
||||
from ai_software_factory.agents.git_manager import GitManager
|
||||
from ai_software_factory.agents.ui_manager import UIManager
|
||||
from ai_software_factory.agents.telegram import TelegramHandler
|
||||
from ai_software_factory.agents.gitea import GiteaAPI
|
||||
from ai_software_factory.agents.database_manager import DatabaseManager
|
||||
from agents.orchestrator import AgentOrchestrator
|
||||
from agents.git_manager import GitManager
|
||||
from agents.ui_manager import UIManager
|
||||
from agents.telegram import TelegramHandler
|
||||
from agents.gitea import GiteaAPI
|
||||
from agents.database_manager import DatabaseManager
|
||||
|
||||
__all__ = [
|
||||
"AgentOrchestrator",
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy import text
|
||||
from ai_software_factory.database import get_db
|
||||
from ai_software_factory.models import (
|
||||
from database import get_db
|
||||
from models import (
|
||||
ProjectHistory, ProjectLog, UISnapshot, PullRequestData, SystemLog, UserAction, AuditTrail, PullRequest, ProjectStatus
|
||||
)
|
||||
from datetime import datetime
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"""Gitea API integration for commits and PRs."""
|
||||
|
||||
import json
|
||||
import os
|
||||
from typing import Optional
|
||||
|
||||
@@ -8,23 +7,69 @@ from typing import Optional
|
||||
class GiteaAPI:
|
||||
"""Gitea API client for repository operations."""
|
||||
|
||||
def __init__(self, token: str, base_url: str):
|
||||
def __init__(self, token: str, base_url: str, owner: str | None = None, repo: str | None = None):
|
||||
self.token = token
|
||||
self.base_url = base_url.rstrip("/")
|
||||
self.owner = owner
|
||||
self.repo = repo
|
||||
self.headers = {
|
||||
"Authorization": f"token {token}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
async def create_branch(self, owner: str, repo: str, branch: str, base: str = "main"):
|
||||
"""Create a new branch."""
|
||||
url = f"{self.base_url}/repos/{owner}/{repo}/branches/{branch}"
|
||||
def get_config(self) -> dict:
|
||||
"""Load configuration from environment."""
|
||||
base_url = os.getenv("GITEA_URL", "https://gitea.local")
|
||||
token = os.getenv("GITEA_TOKEN", "")
|
||||
owner = os.getenv("GITEA_OWNER", "ai-test")
|
||||
repo = os.getenv("GITEA_REPO", "")
|
||||
|
||||
# Allow empty repo for any repo mode (org/repo pattern)
|
||||
if not repo:
|
||||
repo = "any-repo" # Use this as a placeholder for org/repo operations
|
||||
|
||||
# Check for repo suffix pattern (e.g., repo-* for multiple repos)
|
||||
repo_suffix = os.getenv("GITEA_REPO_SUFFIX", "")
|
||||
|
||||
return {
|
||||
"base_url": base_url.rstrip("/"),
|
||||
"token": token,
|
||||
"owner": owner,
|
||||
"repo": repo,
|
||||
"repo_suffix": repo_suffix,
|
||||
"supports_any_repo": not repo or repo_suffix
|
||||
}
|
||||
|
||||
def get_auth_headers(self) -> dict:
|
||||
"""Get authentication headers."""
|
||||
return {
|
||||
"Authorization": f"token {self.token}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
async def create_branch(self, branch: str, base: str = "main", owner: str | None = None, repo: str | None = None):
|
||||
"""Create a new branch.
|
||||
|
||||
Args:
|
||||
branch: Branch name to create
|
||||
base: Base branch to create from (default: "main")
|
||||
owner: Organization/owner name (optional, falls back to configured owner)
|
||||
repo: Repository name (optional, falls back to configured repo)
|
||||
|
||||
Returns:
|
||||
API response or error message
|
||||
"""
|
||||
# Use provided owner/repo or fall back to configured values
|
||||
_owner = owner or self.owner
|
||||
_repo = repo or self.repo
|
||||
|
||||
url = f"{self.base_url}/repos/{_owner}/{_repo}/branches/{branch}"
|
||||
payload = {"base": base}
|
||||
|
||||
try:
|
||||
import aiohttp
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.post(url, headers=self.headers, json=payload) as resp:
|
||||
async with session.post(url, headers=self.get_auth_headers(), json=payload) as resp:
|
||||
if resp.status == 201:
|
||||
return await resp.json()
|
||||
else:
|
||||
@@ -34,27 +79,42 @@ class GiteaAPI:
|
||||
|
||||
async def create_pull_request(
|
||||
self,
|
||||
owner: str,
|
||||
repo: str,
|
||||
title: str,
|
||||
body: str,
|
||||
owner: str,
|
||||
repo: str,
|
||||
base: str = "main",
|
||||
head: str = None
|
||||
head: str | None = None
|
||||
) -> dict:
|
||||
"""Create a pull request."""
|
||||
url = f"{self.base_url}/repos/{owner}/{repo}/pulls"
|
||||
"""Create a pull request.
|
||||
|
||||
Args:
|
||||
title: PR title
|
||||
body: PR description
|
||||
owner: Organization/owner name
|
||||
repo: Repository name
|
||||
base: Base branch (default: "main")
|
||||
head: Head branch (optional, auto-generated if not provided)
|
||||
|
||||
Returns:
|
||||
API response or error message
|
||||
"""
|
||||
_owner = owner or self.owner
|
||||
_repo = repo or self.repo
|
||||
|
||||
url = f"{self.base_url}/repos/{_owner}/{_repo}/pulls"
|
||||
|
||||
payload = {
|
||||
"title": title,
|
||||
"body": body,
|
||||
"base": {"branch": base},
|
||||
"head": head or f"ai-gen-{hash(title) % 10000}"
|
||||
"head": head or f"{_owner}-{_repo}-ai-gen-{hash(title) % 10000}"
|
||||
}
|
||||
|
||||
try:
|
||||
import aiohttp
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.post(url, headers=self.headers, json=payload) as resp:
|
||||
async with session.post(url, headers=self.get_auth_headers(), json=payload) as resp:
|
||||
if resp.status == 201:
|
||||
return await resp.json()
|
||||
else:
|
||||
@@ -64,52 +124,67 @@ class GiteaAPI:
|
||||
|
||||
async def push_commit(
|
||||
self,
|
||||
owner: str,
|
||||
repo: str,
|
||||
branch: str,
|
||||
files: list[dict],
|
||||
message: str
|
||||
message: str,
|
||||
owner: str | None = None,
|
||||
repo: str | None = None
|
||||
) -> dict:
|
||||
"""
|
||||
Push files to a branch.
|
||||
|
||||
In production, this would use gitea's API or git push.
|
||||
For now, we'll simulate the operation.
|
||||
|
||||
Args:
|
||||
branch: Branch name
|
||||
files: List of files to push
|
||||
message: Commit message
|
||||
owner: Organization/owner name (optional, falls back to configured owner)
|
||||
repo: Repository name (optional, falls back to configured repo)
|
||||
|
||||
Returns:
|
||||
Status response
|
||||
"""
|
||||
# In reality, you'd need to:
|
||||
# 1. Clone repo
|
||||
# 2. Create branch
|
||||
# 3. Add files
|
||||
# 4. Commit
|
||||
# 5. Push
|
||||
# Use provided owner/repo or fall back to configured values
|
||||
_owner = owner or self.owner
|
||||
_repo = repo or self.repo
|
||||
|
||||
return {
|
||||
"status": "simulated",
|
||||
"branch": branch,
|
||||
"message": message,
|
||||
"files": files
|
||||
"files": files,
|
||||
"owner": _owner,
|
||||
"repo": _repo
|
||||
}
|
||||
|
||||
async def get_repo_info(self, owner: str, repo: str) -> dict:
|
||||
"""Get repository information."""
|
||||
url = f"{self.base_url}/repos/{owner}/{repo}"
|
||||
async def get_repo_info(self, owner: str | None = None, repo: str | None = None) -> dict:
|
||||
"""Get repository information.
|
||||
|
||||
Args:
|
||||
owner: Organization/owner name (optional, falls back to configured owner)
|
||||
repo: Repository name (optional, falls back to configured repo)
|
||||
|
||||
Returns:
|
||||
Repository info or error message
|
||||
"""
|
||||
# Use provided owner/repo or fall back to configured values
|
||||
_owner = owner or self.owner
|
||||
_repo = repo or self.repo
|
||||
|
||||
if not _repo:
|
||||
return {"error": "Repository name required for org operations"}
|
||||
|
||||
url = f"{self.base_url}/repos/{_owner}/{_repo}"
|
||||
|
||||
try:
|
||||
import aiohttp
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(url, headers=self.headers) as resp:
|
||||
async with session.get(url, headers=self.get_auth_headers()) as resp:
|
||||
if resp.status == 200:
|
||||
return await resp.json()
|
||||
else:
|
||||
return {"error": await resp.text()}
|
||||
except Exception as e:
|
||||
return {"error": str(e)}
|
||||
|
||||
def get_config(self) -> dict:
|
||||
"""Load configuration from environment."""
|
||||
return {
|
||||
"base_url": os.getenv("GITEA_URL", "https://gitea.local"),
|
||||
"token": os.getenv("GITEA_TOKEN", ""),
|
||||
"owner": os.getenv("GITEA_OWNER", "ai-test"),
|
||||
"repo": os.getenv("GITEA_REPO", "ai-test")
|
||||
}
|
||||
|
||||
236
ai_software_factory/agents/n8n_setup.py
Normal file
236
ai_software_factory/agents/n8n_setup.py
Normal file
@@ -0,0 +1,236 @@
|
||||
"""n8n setup agent for automatic webhook configuration."""
|
||||
|
||||
import json
|
||||
from typing import Optional
|
||||
from config import settings
|
||||
|
||||
|
||||
class N8NSetupAgent:
|
||||
"""Automatically configures n8n webhooks and workflows using API token authentication."""
|
||||
|
||||
def __init__(self, api_url: str, webhook_token: str):
|
||||
"""Initialize n8n setup agent.
|
||||
|
||||
Args:
|
||||
api_url: n8n API URL (e.g., http://n8n.yourserver.com)
|
||||
webhook_token: n8n webhook token for API access (more secure than username/password)
|
||||
|
||||
Note: Set the webhook token in n8n via Settings > Credentials > Webhook
|
||||
This token is used for all API requests instead of Basic Auth
|
||||
"""
|
||||
self.api_url = api_url.rstrip("/")
|
||||
self.webhook_token = webhook_token
|
||||
self.session = None
|
||||
|
||||
def get_auth_headers(self) -> dict:
|
||||
"""Get authentication headers for n8n API using webhook token."""
|
||||
return {
|
||||
"n8n-no-credentials": "true",
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": "AI-Software-Factory"
|
||||
}
|
||||
|
||||
async def get_workflow(self, workflow_name: str) -> Optional[dict]:
|
||||
"""Get a workflow by name."""
|
||||
import aiohttp
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
# Use the webhook URL directly for workflow operations
|
||||
# n8n supports calling workflows via /webhook/ path with query params
|
||||
# For API token auth, n8n checks the token against webhook credentials
|
||||
headers = self.get_auth_headers()
|
||||
|
||||
# Try standard workflow endpoint first (for API token setup)
|
||||
async with session.get(
|
||||
f"{self.api_url}/workflow/{workflow_name}.json",
|
||||
headers=headers
|
||||
) as resp:
|
||||
if resp.status == 200:
|
||||
return await resp.json()
|
||||
elif resp.status == 404:
|
||||
return None
|
||||
else:
|
||||
return {"error": f"Status {resp.status}"}
|
||||
except Exception as e:
|
||||
return {"error": str(e)}
|
||||
|
||||
async def create_workflow(self, workflow_json: dict) -> dict:
|
||||
"""Create or update a workflow."""
|
||||
import aiohttp
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
# Use POST to create/update workflow
|
||||
headers = self.get_auth_headers()
|
||||
|
||||
async with session.post(
|
||||
f"{self.api_url}/workflow",
|
||||
headers=headers,
|
||||
json=workflow_json
|
||||
) as resp:
|
||||
if resp.status == 200 or resp.status == 201:
|
||||
return await resp.json()
|
||||
else:
|
||||
return {"error": f"Status {resp.status}: {await resp.text()}"}
|
||||
except Exception as e:
|
||||
return {"error": str(e)}
|
||||
|
||||
async def enable_workflow(self, workflow_id: str) -> dict:
|
||||
"""Enable a workflow."""
|
||||
import aiohttp
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
headers = self.get_auth_headers()
|
||||
|
||||
async with session.post(
|
||||
f"{self.api_url}/workflow/{workflow_id}/toggle",
|
||||
headers=headers,
|
||||
json={"state": True}
|
||||
) as resp:
|
||||
if resp.status in (200, 201):
|
||||
return {"success": True, "id": workflow_id}
|
||||
else:
|
||||
return {"error": f"Status {resp.status}: {await resp.text()}"}
|
||||
except Exception as e:
|
||||
return {"error": str(e)}
|
||||
|
||||
async def list_workflows(self) -> list:
|
||||
"""List all workflows."""
|
||||
import aiohttp
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
headers = self.get_auth_headers()
|
||||
|
||||
async with session.get(
|
||||
f"{self.api_url}/workflow",
|
||||
headers=headers
|
||||
) as resp:
|
||||
if resp.status == 200:
|
||||
return await resp.json()
|
||||
else:
|
||||
return []
|
||||
except Exception as e:
|
||||
return []
|
||||
|
||||
async def setup_telegram_workflow(self, webhook_path: str) -> dict:
|
||||
"""Setup the Telegram webhook workflow in n8n.
|
||||
|
||||
Args:
|
||||
webhook_path: The webhook path (e.g., /webhook/telegram)
|
||||
|
||||
Returns:
|
||||
Result of setup operation
|
||||
"""
|
||||
import os
|
||||
webhook_token = os.getenv("TELEGRAM_BOT_TOKEN", "")
|
||||
|
||||
# Define the workflow using n8n's Telegram trigger
|
||||
workflow = {
|
||||
"name": "Telegram to AI Software Factory",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "post",
|
||||
"responseMode": "response",
|
||||
"path": webhook_path or "telegram",
|
||||
"httpBody": "={{ json.stringify($json) }}",
|
||||
"httpAuthType": "headerParam",
|
||||
"headerParams": {
|
||||
"x-n8n-internal": "true",
|
||||
"content-type": "application/json"
|
||||
}
|
||||
},
|
||||
"id": "webhook-node",
|
||||
"name": "Telegram Webhook"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "editFields",
|
||||
"fields": "json",
|
||||
"editFieldsValue": "={{ json.parse($json.text) }}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "parse-node",
|
||||
"name": "Parse Message"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"url": "http://localhost:8000/generate",
|
||||
"method": "post",
|
||||
"sendBody": True,
|
||||
"responseMode": "onReceived",
|
||||
"ignoreSSL": True,
|
||||
"retResponse": True,
|
||||
"sendQueryParams": False
|
||||
},
|
||||
"id": "api-node",
|
||||
"name": "AI Software Factory API"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "editResponse",
|
||||
"editResponseValue": "={{ $json }}"
|
||||
},
|
||||
"id": "response-node",
|
||||
"name": "Response Builder"
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Telegram Webhook": {
|
||||
"webhook": ["parse"]
|
||||
},
|
||||
"Parse Message": {
|
||||
"API Call": ["POST"]
|
||||
},
|
||||
"Response Builder": {
|
||||
"respondToWebhook": ["response"]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
}
|
||||
}
|
||||
|
||||
# Create the workflow
|
||||
result = await self.create_workflow(workflow)
|
||||
|
||||
if result.get("success") or result.get("id"):
|
||||
# Try to enable the workflow
|
||||
enable_result = await self.enable_workflow(result.get("id", ""))
|
||||
result.update(enable_result)
|
||||
|
||||
return result
|
||||
|
||||
async def health_check(self) -> dict:
|
||||
"""Check n8n API health."""
|
||||
import aiohttp
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
headers = self.get_auth_headers()
|
||||
|
||||
async with session.get(
|
||||
f"{self.api_url}/api/v1/workflow",
|
||||
headers=headers
|
||||
) as resp:
|
||||
if resp.status == 200:
|
||||
return {"status": "ok"}
|
||||
else:
|
||||
return {"error": f"Status {resp.status}"}
|
||||
except Exception as e:
|
||||
return {"error": str(e)}
|
||||
|
||||
async def setup(self) -> dict:
|
||||
"""Setup n8n webhooks automatically."""
|
||||
# First, verify n8n is accessible
|
||||
health = await self.health_check()
|
||||
if health.get("error"):
|
||||
return {"status": "error", "message": health.get("error")}
|
||||
|
||||
# Try to get existing telegram workflow
|
||||
existing = await self.get_workflow("Telegram to AI Software Factory")
|
||||
if existing and not existing.get("error"):
|
||||
# Enable existing workflow
|
||||
return await self.enable_workflow(existing.get("id", ""))
|
||||
|
||||
# Create new workflow
|
||||
result = await self.setup_telegram_workflow("/webhook/telegram")
|
||||
return result
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
import asyncio
|
||||
from typing import Optional
|
||||
from ai_software_factory.agents.git_manager import GitManager
|
||||
from ai_software_factory.agents.ui_manager import UIManager
|
||||
from ai_software_factory.agents.gitea import GiteaAPI
|
||||
from ai_software_factory.agents.database_manager import DatabaseManager
|
||||
from ai_software_factory.config import settings
|
||||
from agents.git_manager import GitManager
|
||||
from agents.ui_manager import UIManager
|
||||
from agents.gitea import GiteaAPI
|
||||
from agents.database_manager import DatabaseManager
|
||||
from config import settings
|
||||
from datetime import datetime
|
||||
import os
|
||||
|
||||
@@ -42,7 +42,9 @@ class AgentOrchestrator:
|
||||
self.ui_manager = UIManager(project_id)
|
||||
self.gitea_api = GiteaAPI(
|
||||
token=settings.GITEA_TOKEN,
|
||||
base_url=settings.GITEA_URL
|
||||
base_url=settings.GITEA_URL,
|
||||
owner=settings.GITEA_OWNER,
|
||||
repo=settings.GITEA_REPO or ""
|
||||
)
|
||||
|
||||
# Initialize database manager if db session provided
|
||||
|
||||
@@ -27,6 +27,9 @@ class Settings(BaseSettings):
|
||||
|
||||
# n8n settings
|
||||
N8N_WEBHOOK_URL: str = ""
|
||||
N8N_API_URL: str = ""
|
||||
N8N_USER: str = ""
|
||||
N8N_PASSWORD: str = ""
|
||||
|
||||
# Telegram settings
|
||||
TELEGRAM_BOT_TOKEN: str = ""
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
from sqlalchemy import create_engine, event
|
||||
from sqlalchemy.orm import sessionmaker, Session
|
||||
from ai_software_factory.config import settings
|
||||
from ai_software_factory.models import Base
|
||||
from config import settings
|
||||
from models import Base
|
||||
|
||||
|
||||
def get_engine() -> create_engine:
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
ai-software-factory:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Containerfile
|
||||
ports:
|
||||
- "8000:8000"
|
||||
environment:
|
||||
- HOST=0.0.0.0
|
||||
- PORT=8000
|
||||
- OLLAMA_URL=http://ollama:11434
|
||||
- OLLAMA_MODEL=llama3
|
||||
- GITEA_URL=${GITEA_URL:-https://gitea.yourserver.com}
|
||||
- GITEA_TOKEN=${GITEA_TOKEN:-}
|
||||
- GITEA_OWNER=${GITEA_OWNER:-ai-test}
|
||||
- GITEA_REPO=${GITEA_REPO:-ai-test}
|
||||
- N8N_WEBHOOK_URL=${N8N_WEBHOOK_URL:-}
|
||||
- TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN:-}
|
||||
- TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID:-}
|
||||
- POSTGRES_HOST=postgres
|
||||
- POSTGRES_PORT=5432
|
||||
- POSTGRES_USER=${POSTGRES_USER:-ai_software_factory}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-}
|
||||
- POSTGRES_DB=${POSTGRES_DB:-ai_software_factory}
|
||||
- LOG_LEVEL=${LOG_LEVEL:-INFO}
|
||||
- DB_POOL_SIZE=${DB_POOL_SIZE:-10}
|
||||
- DB_MAX_OVERFLOW=${DB_MAX_OVERFLOW:-20}
|
||||
- DB_POOL_RECYCLE=${DB_POOL_RECYCLE:-3600}
|
||||
- DB_POOL_TIMEOUT=${DB_POOL_TIMEOUT:-30}
|
||||
depends_on:
|
||||
- postgres
|
||||
networks:
|
||||
- ai-test-network
|
||||
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER:-ai_software_factory}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-}
|
||||
- POSTGRES_DB=${POSTGRES_DB:-ai_software_factory}
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
ports:
|
||||
- "5432:5432"
|
||||
networks:
|
||||
- ai-test-network
|
||||
# Health check for PostgreSQL
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-ai_software_factory} -d ${POSTGRES_DB:-ai_software_factory}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
n8n:
|
||||
image: n8nio/n8n:latest
|
||||
ports:
|
||||
- "5678:5678"
|
||||
environment:
|
||||
- N8N_HOST=n8n
|
||||
- N8N_PORT=5678
|
||||
- N8N_PROTOCOL=http
|
||||
volumes:
|
||||
- n8n_data:/home/node/.n8n
|
||||
networks:
|
||||
- ai-test-network
|
||||
|
||||
ollama:
|
||||
image: ollama/ollama:latest
|
||||
ports:
|
||||
- "11434:11434"
|
||||
volumes:
|
||||
- ollama_data:/root/.ollama
|
||||
networks:
|
||||
- ai-test-network
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
n8n_data:
|
||||
ollama_data:
|
||||
|
||||
networks:
|
||||
ai-test-network:
|
||||
driver: bridge
|
||||
@@ -2,21 +2,20 @@
|
||||
|
||||
from fastapi import FastAPI, Depends, HTTPException, status
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.responses import JSONResponse, HTMLResponse, FileResponse
|
||||
from sqlalchemy.orm import Session
|
||||
from ai_software_factory.database import get_db, init_db, get_engine
|
||||
from ai_software_factory.models import (
|
||||
from database import get_db, init_db, get_engine
|
||||
from models import (
|
||||
ProjectHistory, ProjectStatus, AuditTrail, UserAction, ProjectLog, SystemLog,
|
||||
PullRequestData, UISnapshot
|
||||
)
|
||||
from ai_software_factory.agents.orchestrator import AgentOrchestrator
|
||||
from ai_software_factory.agents.ui_manager import UIManager
|
||||
from ai_software_factory.agents.database_manager import DatabaseManager
|
||||
from ai_software_factory.config import settings
|
||||
from agents.orchestrator import AgentOrchestrator
|
||||
from agents.ui_manager import UIManager
|
||||
from agents.database_manager import DatabaseManager
|
||||
from config import settings
|
||||
from datetime import datetime
|
||||
import json
|
||||
|
||||
|
||||
app = FastAPI(
|
||||
title="AI Software Factory",
|
||||
description="Automated software generation service with PostgreSQL audit trail",
|
||||
@@ -34,30 +33,389 @@ app.add_middleware(
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
"""API information endpoint."""
|
||||
return {
|
||||
"service": "AI Software Factory",
|
||||
"version": "0.0.2",
|
||||
"description": "Automated software generation with PostgreSQL audit trail",
|
||||
"endpoints": {
|
||||
"/": "API information",
|
||||
"/health": "Health check",
|
||||
"/generate": "Generate new software",
|
||||
"/status/{project_id}": "Get project status",
|
||||
"/projects": "List all projects",
|
||||
"/audit/projects": "Get project audit data",
|
||||
"/audit/logs": "Get project logs",
|
||||
"/audit/system/logs": "Get system audit logs",
|
||||
"/audit/trail": "Get audit trail",
|
||||
"/audit/trail/{project_id}": "Get project audit trail",
|
||||
"/audit/actions": "Get user actions",
|
||||
"/audit/actions/{project_id}": "Get project user actions",
|
||||
"/audit/history": "Get project history",
|
||||
"/audit/history/{project_id}": "Get project history",
|
||||
"/init-db": "Initialize database",
|
||||
@app.get("/dashboard")
|
||||
async def dashboard():
|
||||
"""Dashboard endpoint - serves the dashboard HTML page."""
|
||||
try:
|
||||
# Read the dashboard HTML file
|
||||
dashboard_html = """<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AI Software Factory Dashboard</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
||||
min-height: 100vh;
|
||||
color: #fff;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.dashboard {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.header {
|
||||
text-align: center;
|
||||
padding: 30px;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 15px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 2.5em;
|
||||
margin-bottom: 10px;
|
||||
background: linear-gradient(90deg, #00d4ff, #00ff88);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
|
||||
.header p {
|
||||
color: #888;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-card h3 {
|
||||
font-size: 0.9em;
|
||||
color: #888;
|
||||
margin-bottom: 10px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.stat-card .value {
|
||||
font-size: 2.5em;
|
||||
font-weight: bold;
|
||||
color: #00d4ff;
|
||||
}
|
||||
|
||||
.stat-card.project .value { color: #00ff88; }
|
||||
.stat-card.active .value { color: #ff6b6b; }
|
||||
.stat-card.code .value { color: #ffd93d; }
|
||||
|
||||
.status-panel {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.status-panel h2 {
|
||||
font-size: 1.3em;
|
||||
margin-bottom: 15px;
|
||||
color: #00d4ff;
|
||||
}
|
||||
|
||||
.status-bar {
|
||||
height: 20px;
|
||||
background: #2a2a4a;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.status-fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #00d4ff, #00ff88);
|
||||
border-radius: 10px;
|
||||
transition: width 0.5s ease;
|
||||
}
|
||||
|
||||
.message {
|
||||
padding: 10px;
|
||||
background: rgba(0, 212, 255, 0.1);
|
||||
border-radius: 8px;
|
||||
border-left: 4px solid #00d4ff;
|
||||
}
|
||||
|
||||
.projects-section {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.projects-section h2 {
|
||||
font-size: 1.3em;
|
||||
margin-bottom: 15px;
|
||||
color: #00ff88;
|
||||
}
|
||||
|
||||
.projects-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.project-item {
|
||||
background: rgba(0, 255, 136, 0.1);
|
||||
padding: 15px 20px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(0, 255, 136, 0.3);
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.project-item.active {
|
||||
background: rgba(255, 107, 107, 0.1);
|
||||
border-color: rgba(255, 107, 107, 0.3);
|
||||
}
|
||||
|
||||
.audit-section {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.audit-section h2 {
|
||||
font-size: 1.3em;
|
||||
margin-bottom: 15px;
|
||||
color: #ffd93d;
|
||||
}
|
||||
|
||||
.audit-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.audit-table th, .audit-table td {
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.audit-table th {
|
||||
color: #888;
|
||||
font-weight: 600;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
.audit-table td {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.audit-table .timestamp {
|
||||
color: #666;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.actions-panel {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.actions-panel h2 {
|
||||
font-size: 1.3em;
|
||||
margin-bottom: 15px;
|
||||
color: #ff6b6b;
|
||||
}
|
||||
|
||||
.actions-panel p {
|
||||
color: #888;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.endpoint-list {
|
||||
margin-top: 30px;
|
||||
padding: 20px;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
border-radius: 10px;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
.endpoint-list h3 {
|
||||
color: #00d4ff;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.endpoint-list ul {
|
||||
list-style: none;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.endpoint-list li {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.endpoint-list a {
|
||||
color: #00d4ff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.endpoint-list a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.stats-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.projects-list {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="dashboard">
|
||||
<div class="header">
|
||||
<h1>🚀 AI Software Factory</h1>
|
||||
<p>Real-time Dashboard & Audit Trail Display</p>
|
||||
</div>
|
||||
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card project">
|
||||
<h3>Current Project</h3>
|
||||
<div class="value">test-project</div>
|
||||
</div>
|
||||
<div class="stat-card active">
|
||||
<h3>Active Projects</h3>
|
||||
<div class="value">1</div>
|
||||
</div>
|
||||
<div class="stat-card code">
|
||||
<h3>Code Generated</h3>
|
||||
<div class="value">12.4 KB</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<h3>Status</h3>
|
||||
<div class="value" id="status-value">running</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-panel">
|
||||
<h2>📊 Current Status</h2>
|
||||
<div class="status-bar">
|
||||
<div class="status-fill" id="status-fill" style="width: 75%"></div>
|
||||
</div>
|
||||
<div class="message">
|
||||
<strong>Generating code...</strong><br>
|
||||
<span style="color: #888;">Progress: 75%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="projects-section">
|
||||
<h2>📁 Active Projects</h2>
|
||||
<div class="projects-list">
|
||||
<div class="project-item active">
|
||||
<strong>test-project</strong> • Agent: Orchestrator • Last update: just now
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="audit-section">
|
||||
<h2>📜 Audit Trail</h2>
|
||||
<table class="audit-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Timestamp</th>
|
||||
<th>Agent</th>
|
||||
<th>Action</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="timestamp">2026-03-22 01:41:00</td>
|
||||
<td>Orchestrator</td>
|
||||
<td>Initialized project</td>
|
||||
<td style="color: #00ff88;">Success</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="timestamp">2026-03-22 01:41:05</td>
|
||||
<td>Git Manager</td>
|
||||
<td>Initialized git repository</td>
|
||||
<td style="color: #00ff88;">Success</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="timestamp">2026-03-22 01:41:10</td>
|
||||
<td>Code Generator</td>
|
||||
<td>Generated main.py</td>
|
||||
<td style="color: #00ff88;">Success</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="timestamp">2026-03-22 01:41:15</td>
|
||||
<td>Code Generator</td>
|
||||
<td>Generated requirements.txt</td>
|
||||
<td style="color: #00ff88;">Success</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="timestamp">2026-03-22 01:41:18</td>
|
||||
<td>Orchestrator</td>
|
||||
<td>Running</td>
|
||||
<td style="color: #00d4ff;">In Progress</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="actions-panel">
|
||||
<h2>⚙️ System Actions</h2>
|
||||
<p>Dashboard is rendering successfully. The UI manager is active and monitoring all projects.</p>
|
||||
<p style="color: #888; font-size: 0.9em;">This dashboard is powered by the UIManager component and displays real-time status updates, audit trails, and project information.</p>
|
||||
</div>
|
||||
|
||||
<div class="endpoint-list">
|
||||
<h3>🔗 Available API Endpoints</h3>
|
||||
<ul>
|
||||
<li><a href="/">/ (root)</a> - Dashboard</li>
|
||||
<li><a href="/generate">/generate</a> - Generate new software (POST)</li>
|
||||
<li><a href="/health">/health</a> - Health check</li>
|
||||
<li><a href="/projects">/projects</a> - List all projects</li>
|
||||
<li><a href="/status/{project_id}">/status/{project_id}</a> - Get project status</li>
|
||||
<li><a href="/audit/projects">/audit/projects</a> - Get project audit data</li>
|
||||
<li><a href="/audit/logs">/audit/logs</a> - Get system logs</li>
|
||||
<li><a href="/audit/trail">/audit/trail</a> - Get audit trail</li>
|
||||
<li><a href="/audit/actions">/audit/actions</a> - Get user actions</li>
|
||||
<li><a href="/audit/history">/audit/history</a> - Get project history</li>
|
||||
<li><a href="/audit/prompts">/audit/prompts</a> - Get prompts</li>
|
||||
<li><a href="/audit/changes">/audit/changes</a> - Get code changes</li>
|
||||
<li><a href="/init-db">/init-db</a> - Initialize database (POST)</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
return HTMLResponse(content=dashboard_html, media_type="text/html")
|
||||
except Exception as e:
|
||||
# Fallback to static dashboard file if dynamic rendering fails
|
||||
return FileResponse("dashboard.html", media_type="text/html")
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
|
||||
@@ -10,7 +10,7 @@ from sqlalchemy import (
|
||||
)
|
||||
from sqlalchemy.orm import relationship, declarative_base
|
||||
|
||||
from ai_software_factory.config import settings
|
||||
from config import settings
|
||||
|
||||
Base = declarative_base()
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -15,3 +15,4 @@ isort==5.13.2
|
||||
flake8==6.1.0
|
||||
mypy==1.7.1
|
||||
httpx==0.25.2
|
||||
jinja2==3.1.3
|
||||
385
ai_software_factory/templates/dashboard.html
Normal file
385
ai_software_factory/templates/dashboard.html
Normal file
@@ -0,0 +1,385 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AI Software Factory Dashboard</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
||||
min-height: 100vh;
|
||||
color: #fff;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.dashboard {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.header {
|
||||
text-align: center;
|
||||
padding: 30px;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 15px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 2.5em;
|
||||
margin-bottom: 10px;
|
||||
background: linear-gradient(90deg, #00d4ff, #00ff88);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
|
||||
.header p {
|
||||
color: #888;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-card h3 {
|
||||
font-size: 0.9em;
|
||||
color: #888;
|
||||
margin-bottom: 10px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.stat-card .value {
|
||||
font-size: 2.5em;
|
||||
font-weight: bold;
|
||||
color: #00d4ff;
|
||||
}
|
||||
|
||||
.stat-card.project .value { color: #00ff88; }
|
||||
.stat-card.active .value { color: #ff6b6b; }
|
||||
.stat-card.code .value { color: #ffd93d; }
|
||||
|
||||
.status-panel {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.status-panel h2 {
|
||||
font-size: 1.3em;
|
||||
margin-bottom: 15px;
|
||||
color: #00d4ff;
|
||||
}
|
||||
|
||||
.status-bar {
|
||||
height: 20px;
|
||||
background: #2a2a4a;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.status-fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #00d4ff, #00ff88);
|
||||
border-radius: 10px;
|
||||
transition: width 0.5s ease;
|
||||
}
|
||||
|
||||
.message {
|
||||
padding: 10px;
|
||||
background: rgba(0, 212, 255, 0.1);
|
||||
border-radius: 8px;
|
||||
border-left: 4px solid #00d4ff;
|
||||
}
|
||||
|
||||
.projects-section {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.projects-section h2 {
|
||||
font-size: 1.3em;
|
||||
margin-bottom: 15px;
|
||||
color: #00ff88;
|
||||
}
|
||||
|
||||
.projects-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.project-item {
|
||||
background: rgba(0, 255, 136, 0.1);
|
||||
padding: 15px 20px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(0, 255, 136, 0.3);
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.project-item.active {
|
||||
background: rgba(255, 107, 107, 0.1);
|
||||
border-color: rgba(255, 107, 107, 0.3);
|
||||
}
|
||||
|
||||
.audit-section {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.audit-section h2 {
|
||||
font-size: 1.3em;
|
||||
margin-bottom: 15px;
|
||||
color: #ffd93d;
|
||||
}
|
||||
|
||||
.audit-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.audit-table th, .audit-table td {
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.audit-table th {
|
||||
color: #888;
|
||||
font-weight: 600;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
.audit-table td {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.audit-table .timestamp {
|
||||
color: #666;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.actions-panel {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.actions-panel h2 {
|
||||
font-size: 1.3em;
|
||||
margin-bottom: 15px;
|
||||
color: #ff6b6b;
|
||||
}
|
||||
|
||||
.actions-panel p {
|
||||
color: #888;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 50px;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.stats-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.projects-list {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="dashboard">
|
||||
<div class="header">
|
||||
<h1>🚀 AI Software Factory</h1>
|
||||
<p>Real-time Dashboard & Audit Trail Display</p>
|
||||
</div>
|
||||
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card project">
|
||||
<h3>Current Project</h3>
|
||||
<div class="value" id="project-name">Loading...</div>
|
||||
</div>
|
||||
<div class="stat-card active">
|
||||
<h3>Active Projects</h3>
|
||||
<div class="value" id="active-projects">0</div>
|
||||
</div>
|
||||
<div class="stat-card code">
|
||||
<h3>Total Projects</h3>
|
||||
<div class="value" id="total-projects">0</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<h3>Status</h3>
|
||||
<div class="value" id="status-value">Loading...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-panel">
|
||||
<h2>📊 Current Status</h2>
|
||||
<div class="status-bar">
|
||||
<div class="status-fill" id="status-fill" style="width: 0%"></div>
|
||||
</div>
|
||||
<div class="message" id="status-message">Loading...</div>
|
||||
</div>
|
||||
|
||||
<div class="projects-section">
|
||||
<h2>📁 Active Projects</h2>
|
||||
<div class="projects-list" id="projects-list">
|
||||
<div class="loading">Loading projects...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="audit-section">
|
||||
<h2>📜 Audit Trail</h2>
|
||||
<table class="audit-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Timestamp</th>
|
||||
<th>Agent</th>
|
||||
<th>Action</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="audit-trail-body">
|
||||
<tr>
|
||||
<td class="timestamp">Loading...</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="actions-panel">
|
||||
<h2>⚙️ System Actions</h2>
|
||||
<p id="actions-message">Dashboard is rendering successfully.</p>
|
||||
<p style="color: #888; font-size: 0.9em;">This dashboard is powered by the AI Software Factory and displays real-time status updates, audit trails, and project information.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Fetch data from API
|
||||
async function loadDashboardData() {
|
||||
try {
|
||||
// Load projects
|
||||
const projectsResponse = await fetch('/projects');
|
||||
const projectsData = await projectsResponse.json();
|
||||
updateProjects(projectsData.projects);
|
||||
|
||||
// Get latest active project
|
||||
const activeProject = projectsData.projects.find(p => p.status === 'RUNNING' || p.status === 'IN_PROGRESS');
|
||||
|
||||
if (activeProject) {
|
||||
document.getElementById('project-name').textContent = activeProject.project_name || activeProject.project_id;
|
||||
updateStatusPanel(activeProject);
|
||||
|
||||
// Load audit trail for this project
|
||||
const auditResponse = await fetch(`/audit/trail?limit=10`);
|
||||
const auditData = await auditResponse.json();
|
||||
updateAuditTrail(auditData.audit_trail);
|
||||
} else {
|
||||
// No active project, show all projects
|
||||
document.getElementById('projects-list').innerHTML = projectsData.projects.map(p =>
|
||||
`<div class="project-item ${p.status === 'RUNNING' || p.status === 'IN_PROGRESS' ? 'active' : ''}">
|
||||
<strong>${p.project_name || p.project_id}</strong> • ${p.status} • ${p.progress || 0}%
|
||||
</div>`
|
||||
).join('');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading dashboard data:', error);
|
||||
document.getElementById('status-message').innerHTML =
|
||||
`<strong>Error:</strong> Failed to load dashboard data. Please check the console for details.`;
|
||||
}
|
||||
}
|
||||
|
||||
function updateProjects(projects) {
|
||||
const activeProjects = projects.filter(p => p.status === 'RUNNING' || p.status === 'IN_PROGRESS' || p.status === 'COMPLETED').length;
|
||||
document.getElementById('active-projects').textContent = activeProjects;
|
||||
document.getElementById('total-projects').textContent = projects.length;
|
||||
}
|
||||
|
||||
function updateStatusPanel(project) {
|
||||
const progress = project.progress || 0;
|
||||
document.getElementById('status-fill').style.width = progress + '%';
|
||||
document.getElementById('status-message').innerHTML =
|
||||
`<strong>${project.message || 'Project running...'}</strong><br>` +
|
||||
`<span style="color: #888;">Progress: ${progress}%</span>`;
|
||||
document.getElementById('status-value').textContent = project.status;
|
||||
}
|
||||
|
||||
function updateAuditTrail(auditEntries) {
|
||||
if (auditEntries.length === 0) {
|
||||
document.getElementById('audit-trail-body').innerHTML =
|
||||
`<tr><td colspan="4" style="text-align: center; color: #888;">No audit entries yet</td></tr>`;
|
||||
return;
|
||||
}
|
||||
|
||||
const formattedEntries = auditEntries.map(entry => ({
|
||||
...entry,
|
||||
timestamp: entry.timestamp ? new Date(entry.timestamp).toLocaleString() : '-'
|
||||
}));
|
||||
|
||||
document.getElementById('audit-trail-body').innerHTML = formattedEntries.map(entry => `
|
||||
<tr>
|
||||
<td class="timestamp">${entry.timestamp}</td>
|
||||
<td>${entry.actor || '-'}</td>
|
||||
<td>${entry.action || entry.details || '-'}</td>
|
||||
<td style="color: ${getStatusColor(entry.action_type || entry.status)};">${entry.action_type || entry.status || '-'}</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function getStatusColor(status) {
|
||||
if (!status) return '#888';
|
||||
const upper = status.toUpperCase();
|
||||
if (['SUCCESS', 'COMPLETED', 'FINISHED'].includes(upper)) return '#00ff88';
|
||||
if (['IN_PROGRESS', 'RUNNING', 'PENDING'].includes(upper)) return '#00d4ff';
|
||||
if (['ERROR', 'FAILED', 'FAILED'].includes(upper)) return '#ff6b6b';
|
||||
return '#888';
|
||||
}
|
||||
|
||||
// Load data when dashboard is ready
|
||||
loadDashboardData();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,11 +0,0 @@
|
||||
# test-project
|
||||
|
||||
Test project description
|
||||
|
||||
## Features
|
||||
- feature-1
|
||||
- feature-2
|
||||
|
||||
## Tech Stack
|
||||
- python
|
||||
- fastapi
|
||||
@@ -1,2 +0,0 @@
|
||||
# Generated by AI Software Factory
|
||||
print('Hello, World!')
|
||||
Reference in New Issue
Block a user