feat: Terraform resource reference from provider schema, provider alias fixes, and timestamps

- Add gen_tf_reference.py to generate OCI Terraform provider resource catalog (~937 resources) from `terraform providers schema -json`
- Auto-inject categorized resource reference into Terraform Agent system prompt to prevent invalid resource type names
- Build-time reference generation in Dockerfile, refreshable via POST /api/terraform/refresh-reference
- Provider alias detection with brace-matching parser for multi-region deployments
- Clean old .tf files before writing new ones on Re-plan
- Message timestamps in terraform chat and history
- Partial DOM rendering to eliminate screen flickering
- Layout overflow fix (no scroll beyond viewport)
This commit is contained in:
nogueiraguh
2026-03-08 01:00:47 -03:00
parent 8bccf9367e
commit 19e481275d
5 changed files with 327 additions and 28 deletions

View File

@@ -60,6 +60,7 @@ The platform combines security compliance scanning, AI-powered chat with **RAG (
- **Chat history**: ChatGPT-style session history with rename/delete, shared between Chat Agent and Terraform Agent
- **Resizable split view**: chat on top (50%), files/plan/resources + terminal on bottom (50%) with drag-to-resize
- Terraform CLI installed in container (v1.7.5)
- **Terraform Resource Reference (RAG-lite)**: auto-generated OCI provider resource catalog (~937 resources) injected into system prompt to prevent invalid resource type names — built from `terraform providers schema -json` at container build time, refreshable via API endpoint
- Dedicated system prompt optimized for OCI Terraform provider best practices
### ⚡ OCI Resource Actions
@@ -356,13 +357,14 @@ Allow group <group-name> to read buckets in compartment <compartment-name>
```
oci-cis-agent/
├── backend/
│ ├── app.py # FastAPI application (~4000 lines)
│ ├── app.py # FastAPI application (~4200 lines)
│ ├── cis_reports.py # Oracle CIS Benchmark checker (6660 lines, report engine)
│ ├── mcp_cis_server.py # MCP server with 12 granular CIS tools (~700 lines)
│ ├── gen_tf_reference.py # OCI Terraform provider resource catalog generator
│ ├── Dockerfile # Python 3.12 + OCI CLI + Terraform CLI
│ └── requirements.txt # Dependencies
├── frontend/
│ └── index.html # SPA with Oracle Cloud theme (~1950 lines)
│ └── index.html # SPA with Oracle Cloud theme (~1980 lines)
├── nginx/
│ └── default.conf # Reverse proxy config
├── docker-compose.yml # Orchestration
@@ -514,6 +516,8 @@ oci-cis-agent/
| GET | `/api/terraform/workspaces/{wid}/download` | Download workspace `.tf` files |
| POST | `/api/terraform/workspaces/{wid}/cancel` | Cancel running Terraform operation |
| DELETE | `/api/terraform/workspaces/{wid}` | Delete workspace |
| POST | `/api/terraform/refresh-reference` | Regenerate OCI Terraform resource reference |
| GET | `/api/terraform/reference-status` | Check resource reference availability |
### Chat & Reports
@@ -622,7 +626,7 @@ All models include OCID mapping for `us-ashburn-1`. For other regions, use the "
| Version | Date | Changes |
|---------|------|---------|
| **v2.1** | 2026-03 | Terraform Agent (AI-powered IaC generation with plan/apply/destroy lifecycle, workspace management, Terraform CLI in container, inline file editor, split-panel terminal, multi-file generation via `// filename:` markers), ChatGPT-style chat history for both Chat Agent and Terraform Agent (rename/delete sessions), OCI Resource Actions (start/stop instances and Autonomous DBs from Resources panel), OCI Explorer expanded to 40+ resource types across 8 categories with tree-view navigation and resizable panels, compartment filtering for MCP CIS scans, chat sidebar with model parameters, chat audit logs, collection error tracking in MCP server, tool timeout increased to 30min with auto-retry, memory compaction tuned (6K threshold, 20 recent messages), model catalog trimmed from 69 to 15 curated models, improved GenAI response extraction with fallback for empty responses, fixed layout overflow (no page scroll) |
| **v2.1** | 2026-03 | Terraform Agent (AI-powered IaC generation with plan/apply/destroy lifecycle, workspace management, Terraform CLI in container, inline file editor, split-panel terminal, multi-file generation via `// filename:` markers), **Terraform Resource Reference** (auto-generated OCI provider resource catalog from `terraform providers schema -json`, injected into system prompt to prevent invalid resource types, refreshable via API), ChatGPT-style chat history for both Chat Agent and Terraform Agent (rename/delete sessions), OCI Resource Actions (start/stop instances and Autonomous DBs from Resources panel), OCI Explorer expanded to 40+ resource types across 8 categories with tree-view navigation and resizable panels, compartment filtering for MCP CIS scans, chat sidebar with model parameters, chat audit logs, collection error tracking in MCP server, tool timeout increased to 30min with auto-retry, memory compaction tuned (6K threshold, 20 recent messages), model catalog trimmed from 69 to 15 curated models, improved GenAI response extraction with fallback for empty responses, fixed layout overflow (no page scroll), provider alias detection with brace-matching parser, multi-region Terraform support |
| **v2.0** | 2026-03 | Async background chat processing (no more 504 timeouts), frontend polling with timestamps, 8 uvicorn workers + 16-thread chat executor for ~12 simultaneous chats, parallelized MCP data collection (5-thread base + 8-thread regional), 2-hour MCP session cache, 5-min tool timeout, full dead code cleanup across backend/frontend/MCP |
| **v1.9** | 2026-03 | Multimodal chat (image/PDF/text file upload with OCI GenAI ImageContent/DocumentContent), region-specific MCP scanning (`regions` param on all scan tools), orphaned report auto-detection on progress poll, nginx timeout increased to 15min, improved API error handling for non-JSON responses |
| **v1.8** | 2026-03 | CIS Engine auto-update from Oracle GitHub with automatic patch reapplication, version check UI card (admin), new `/api/cis-engine/*` endpoints, report file listing and individual download endpoints, reorganized Reports tab (execution history + status) and Downloads tab (file browser only with expandable cards per report), CIS Level description tooltip, persistent log expand during report generation |