# Agent4

Agent4 is a rebuilt learning and assessment platform for SolidWorks modeling and ANSYS simulation education.

It separates the product into these roles:

- Knowledge standards: standard answers, extracted skillflows, teaching scripts, and assessment rules.
- Learning controller: teaching and testing sessions.
- C# backend: learning/testing API, SolidWorks extraction orchestration, and method-sensitive grading.
- Extractors: SolidWorks part and assembly feature extraction tools.
- Grader: compares student extracted operations with standard answers.
- Web workbench: teaching/testing UI.

## Current Scope

This first rebuild focuses on SolidWorks feature-process learning:

1. Search standard answers from the reducer knowledge framework and local skillflow JSON files.
2. Start a teaching session from a standard answer.
3. Generate step voice text from the expected SolidWorks feature operation.
4. Accept observed student steps or extract a submitted `.SLDPRT`.
5. Compare feature method and core parameters.
6. Start a testing session and produce a grade report.

## Prerequisites

- Windows with SolidWorks installed for CAD integration.
- .NET SDK 10.0.
- Python 3.13 or a compatible Python 3 version.
- Node.js 24 and npm, or a compatible current LTS release.

## First-Time Setup

Create the local machine-path configuration:

```powershell
Copy-Item project_paths.example.json project_paths.json
```

Set `solidworks_exe` in `project_paths.json` to the local `SLDWORKS.exe`.
For this workstation the value is:

```text
C:\Programs\SOLIDWORKS Corp\SOLIDWORKS\SLDWORKS.exe
```

`project_paths.json` remains local and is ignored by Git. The shared AI
service configuration is stored in the tracked
`backend-csharp/Agent4.Api/appsettings.Local.json` file.

## Run Backend

```powershell
cd <repository-root>
.\run_backend.ps1
```

Backend URL:

```text
http://127.0.0.1:7200
```

Start the frontend in a second PowerShell window:

```powershell
.\run_frontend.ps1
```

Large CAD and knowledge-base assets are distributed separately and are not
required to build or start the base application.

The default backend is now the C# API:

```text
backend-csharp/Agent4.Api
```

The earlier Python FastAPI backend remains as a fallback/reference and can be started with:

```powershell
.\run_backend_python.ps1
```

## Important APIs

```text
GET  /health
GET  /api/standards?query=齿轮
GET  /api/standards/{standard_id}
POST /api/teaching/sessions
POST /api/teaching/sessions/{session_id}/observations
POST /api/teaching/sessions/{session_id}/audit-part
POST /api/testing/sessions
POST /api/testing/sessions/{session_id}/submit
```

## Extractor Tools

The rebuilt project copies the existing extraction tools into:

```text
tools/modeling-process/PartFeatureAudit
tools/modeling-process/AssemblyKnowledgeAudit
```

`PartFeatureAudit` is the core for method-sensitive judgment. It can distinguish feature methods such as boss extrude, cut extrude, shell, loft, sweep, hole wizard, mirror, fillet, chamfer, linear pattern, and circular pattern.

## Import Standard Records

Extracted records such as `*_modeling_plan.json`, `*_skill_flow.json`, and
`*_skill_flow_validation.json` should be imported as standard-answer assets:

```powershell
cd <repository-root>
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r requirements.txt
.\.venv\Scripts\python.exe scripts\import_standard_records.py --source "<extracted-records-directory>" --target "$(Get-Location)\data\standards"
```

The importer copies records into categorized folders and writes:

```text
data/standards/manifest.json
```

The manifest is the main lookup index for teaching and testing. The raw JSON
files remain the authority for executable and comparable feature traces.

## Architecture Direction

Agent4 should judge student work from extracted SolidWorks feature traces, not from UI button clicks.

```text
standard answer skillflow
  -> expected feature trace
student model or operation
  -> extracted feature trace
grader
  -> teaching feedback or test score
```

Final geometry comparison is secondary. Feature method correctness is primary for teaching.

