diff --git a/navi/core/context_builder.py b/navi/core/context_builder.py index 5253000..4494e36 100644 --- a/navi/core/context_builder.py +++ b/navi/core/context_builder.py @@ -128,10 +128,16 @@ extra_system: list[Message] | None = None, session_id: str | None = None, ) -> list[Message]: - system_msg = Message( - role="system", - content=self.build_system_prompt(profile), - ) + system_prompt = self.build_system_prompt(profile) + if session_id: + system_prompt += ( + f"\n\n---\n\n" + f"[Session context]\n" + f"Session ID: {session_id}\n" + f"Session files directory: {_config.settings.session_files_dir}/{session_id}/\n" + f"When writing files the user should see, always use the session directory path above." + ) + system_msg = Message(role="system", content=system_prompt) conv = [m for m in session_context if m.role != "system"] result: list[Message] = [system_msg] if mem: @@ -156,16 +162,4 @@ content=f"[Iteration {iteration + 1}/{max_iterations} — {remaining} remaining.{urgency}]", )) - # Inject session identity so the model knows its own session_id for file paths - if session_id: - result.insert(1, Message( - role="system", - content=( - f"[Session context]\n" - f"Session ID: {session_id}\n" - f"Session files directory: {_config.settings.session_files_dir}/{session_id}/\n" - f"When writing files the user should see, always use the session directory path above." - ), - )) - return result diff --git a/navi/main.py b/navi/main.py index 091571d..8921aa7 100644 --- a/navi/main.py +++ b/navi/main.py @@ -7,6 +7,7 @@ import structlog from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import FileResponse from fastapi.staticfiles import StaticFiles @@ -27,6 +28,14 @@ version="0.1.0", ) +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=False, + allow_methods=["*"], + allow_headers=["*"], +) + # Keep reference to background cleanup task so unhandled exceptions are not lost _cleanup_task = None diff --git a/navi/profiles/modeler_3d/system_prompt.txt b/navi/profiles/modeler_3d/system_prompt.txt index 4fe47a4..4b960bc 100644 --- a/navi/profiles/modeler_3d/system_prompt.txt +++ b/navi/profiles/modeler_3d/system_prompt.txt @@ -7,8 +7,8 @@ 1. **`filesystem write`** — write the OpenSCAD script (`.scad`) to the session directory. 2. **`model_3d`** — compile the `.scad` into a binary `.stl`. 3. **`content_publish`** — show the user the STL in an interactive 3D viewer. -4. **`render_3d`** — generate PNG previews from different angles so both you and the user can inspect the model. -5. **`content_publish`** again — publish each PNG so the user sees the renders. +4. **`render_3d`** — generate PNG previews from different angles for your own inspection. +5. **`image_view`** — inspect each PNG so YOU can verify geometry. Do NOT publish PNGs to the user. ## Workflow @@ -17,8 +17,8 @@ 3. **Write OpenSCAD** — use `filesystem write` to save the `.scad` script to the session directory. 4. **Compile STL** — call `model_3d(scad_path=..., output_path=...)`. 5. **Publish STL** — call `content_publish(filename="...stl")` so the user sees the 3D viewer. -6. **Render previews** — call `render_3d(source="...stl", views=["iso","front","top"])` to generate PNGs. -7. **Publish previews** — call `content_publish` on each PNG (e.g., `bracket.iso.png`). +6. **Render previews** — call `render_3d(source="...stl", views=["iso","front","top"])` to generate PNGs for your own inspection. +7. **Inspect previews** — call `image_view` on each PNG to verify geometry. Do NOT publish PNGs to the user. 8. **Validate** — if you need programmatic checks (watertight, manifold, dimensions), use `code_exec` with `trimesh` on the STL. ## OpenSCAD is your primary engine diff --git a/persona.txt b/persona.txt index 275f66d..a201bcb 100644 --- a/persona.txt +++ b/persona.txt @@ -30,7 +30,7 @@ 1. Persistent workspace: `workspace/` (relative to the project root). Use it for long-term private working files: scripts, notes, datasets, configs, research results, intermediate code, and artifacts that should survive beyond one chat session. Do NOT write working files to the project root. -2. Session files directory: `session_files/{session_id}/` by default; the exact root is configured by `SESSION_FILES_DIR`. +2. Session files directory: a per-session directory whose exact path is injected into every turn context. This is the per-session file area used for user uploads and files the user should view or download in the chat. Decision rule: