Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
def8fac
Save current work: restart project and AI/MCP integration updates
zhangtianqides Jul 1, 2026
97447b1
Add evaluation harness and unit tests for scene validation
zhangtianqides Jul 2, 2026
0627aa2
优化测试集,人工标注反馈流程确定,bug fix
zhangtianqides Jul 3, 2026
e35c246
添加家具检查脚本
zhangtianqides Jul 3, 2026
bddecd3
更新模型库
zhangtianqides Jul 3, 2026
d1e15c5
更新case案例,新增家具
zhangtianqides Jul 6, 2026
2d3c4c8
更新更多的家具
zhangtianqides Jul 7, 2026
03e9195
更新ai agent 流程,
zhangtianqides Jul 9, 2026
fcb6c39
更新家具,修复多语言请求可能存在的隐患问题。
zhangtianqides Jul 9, 2026
180844c
修改多语言交互的回复问题
zhangtianqides Jul 9, 2026
1edd43d
修复因多语言,导致ai agent后续更新编辑更新可能存在的问题。
zhangtianqides Jul 9, 2026
6eda867
添加户型生成策略,提高生成户型的成功率
zhangtianqides Jul 10, 2026
0473177
删除无效文件
zhangtianqides Jul 10, 2026
383a7bc
更新文档文件,删除部分垃圾文件。
zhangtianqides Jul 10, 2026
e089eef
修改流程重设计:设计文档(已确认)+ M0 批次(ModifyOp schema/解析/纯函数应用)
zhangtianqides Jul 13, 2026
83c79eb
M1:家具修改确定性三件套(增/删/换)+ agent 快速路径 + eval case-16/17/18
zhangtianqides Jul 13, 2026
ea60f63
M2:修改稳定性(footprint 锁 + 偏离惩罚)+ 结构类 ModifyOp 全管线(重分区→重建→快照刷新)
zhangtianqides Jul 13, 2026
3f3e00d
M3 离线部分:手动编辑漂移检测 + 确认握手 + PASCAL_MODIFY_LEGACY 对照开关
zhangtianqides Jul 13, 2026
2686248
更新修改户型流程
zhangtianqides Jul 13, 2026
822ca77
修复 case-18 衣柜误删:检索候选过词表 matcher 过滤 + eval itemChanges 只匹配身份字段
zhangtianqides Jul 13, 2026
64da215
修改流程重设计收官:case-14/18 线上验证通过,文档改"已落地"(legacy 保留为旧场景回退)
zhangtianqides Jul 13, 2026
9d92919
收尾对齐审计:delete 意图接入 plan-first + gates 用 intent 真相 + 手动家具重放 + 版本号/旧场景注…
zhangtianqides Jul 13, 2026
08bbb64
局部删除吸收:remove_room 并入邻室零重排(§8-2 修订)+ preserveRoomPolygons 断言 + case-20
zhangtianqides Jul 14, 2026
8946026
bug 修复
zhangtianqides Jul 14, 2026
9f7ff3a
bug 修复
zhangtianqides Jul 14, 2026
ff0628b
全量复盘修复:词表分类(衣帽间/客餐厨)+ §4 面积夹紧 + 结构化地块尺寸 + gates brief/intent 边界 + 衣帽间…
zhangtianqides Jul 14, 2026
10882b5
修复增删改的问题
zhangtianqides Jul 14, 2026
ff040f2
修改agent 检测规则
zhangtianqides Jul 14, 2026
2ad2f64
户型参照库底座:templates/ 格式 + 体检脚本(validator/scorer 裁决 + 同房型生成对比 + SVG)+ 首批…
zhangtianqides Jul 15, 2026
9d59bf3
更新家具库,设计模版户型库方便后续追加模版
zhangtianqides Jul 15, 2026
3d3affa
参照库首个真实间取り图转换(2DK 44.16㎡)+ 体检新发现:DK 被 LDK 档误卡
zhangtianqides Jul 15, 2026
8bb00bc
修参照体检 #1/#2:几何长度厘米取整(0.9m 浮点边界)+ 1K 廊下型厨房动线豁免(三份拷贝共用判定)
zhangtianqides Jul 15, 2026
02a405a
stuck 状态守卫:重启/异常后 in-flight phase 自动降级为可重试状态并向用户说明(启动扫描 + getSession …
zhangtianqides Jul 15, 2026
9c71765
新增无关问题防护栏
zhangtianqides Jul 15, 2026
f239c3e
添加家具模版
zhangtianqides Jul 15, 2026
02f8436
提交户型模版
zhangtianqides Jul 15, 2026
4ec87aa
修复基本户型模版存在的问题
zhangtianqides Jul 16, 2026
e63336e
更新户型模版,并修复部分问题
zhangtianqides Jul 17, 2026
ee36f4d
更新项目文档
zhangtianqides Jul 17, 2026
874f4ad
阶段0架构任务:AI CI、模板体检进CI、部署边界收口、优雅退出
zhangtianqides Jul 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,27 @@

# Dev server port (default: 3000)
# PORT=3000

# AI floor-plan assistant. The service still starts without a key and reports
# its unconfigured state through /api/ai/health.
# AI_PROVIDER=azure-openai
# AZURE_OPENAI_ENDPOINT=https://your-resource.cognitiveservices.azure.com
# AZURE_OPENAI_API_KEY=your_azure_openai_api_key
# AZURE_OPENAI_DEPLOYMENT=your_deployment_name
# AZURE_OPENAI_API_VERSION=2024-10-21

# OpenRouter is also supported when AI_PROVIDER is omitted.
# OPENROUTER_API_KEY=your_openrouter_api_key
# OPENROUTER_MODEL=your_tool_calling_model
# OPENROUTER_FALLBACK_API_KEY=optional_fallback_key
# OPENROUTER_FALLBACK_MODEL=optional_fallback_model

# The editor proxies /api/ai to this internal service URL.
# AI_AGENT_URL=http://127.0.0.1:8788

# Market/norm profile used by planning and template matching. The bundled
# reference floor-plan templates currently use the Japanese profile.
# PASCAL_NORM_PROFILE=jp

# Use the same data path for the editor and the AI-spawned Pascal MCP process.
# PASCAL_DATA_DIR=/absolute/path/to/pascal-data
39 changes: 39 additions & 0 deletions .github/workflows/ai-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: ai-ci

on:
push:
# This fork's remote default branch is develop; keep main for upstream.
branches: [main, develop]
paths:
- 'pascal-ai-mcp/**'
- 'bun.lock'
- '.github/workflows/ai-ci.yml'
pull_request:
paths:
- 'pascal-ai-mcp/**'
- 'bun.lock'
- '.github/workflows/ai-ci.yml'

jobs:
ci:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.0

- name: Install
run: bun install --frozen-lockfile

- name: Type check
run: bun run --cwd pascal-ai-mcp check-types

- name: Test
run: bun test --cwd pascal-ai-mcp

- name: Template health check
run: bun run --cwd pascal-ai-mcp templates:check --no-artifacts
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ apps/editor/env.download
.claude/launch.json
.claude/settings.local.json
.vscode/launch.json

# Claude worktrees (session-local, never commit)
.claude/worktrees/
**/.claude/worktrees/
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,23 +352,25 @@ Clears dirty flag

### Development

Run the development server from the **root directory** to enable hot reload for all packages:
The current local application uses three runtime layers: the editor on port 3002, the AI service (which starts MCP as a child) on port 8788, and the browser-facing reverse proxy on port 8000.

For the daily fast path, use three terminals:

```bash
# Install dependencies
bun install
# Terminal 1, repository root
bun run dev --filter=editor

# Run development server (builds packages + starts editor with watch mode)
bun dev
# Terminal 2
cd pascal-ai-mcp
bun run dev

# This will:
# 1. Build @pascal-app/core and @pascal-app/viewer
# 2. Start watching both packages for changes
# 3. Start the Next.js editor dev server
# Open http://localhost:3000
# Terminal 3, repository root
dotnet run --project pascal-reverse-proxy --no-restore
```

**Important:** Always run `bun dev` from the root directory to ensure the package watchers are running. This enables hot reload when you edit files in `packages/core/src/` or `packages/viewer/src/`.
Open http://localhost:8000. Use root `bun dev` only when editing shared packages or the optional IFC converter; it starts every workspace watcher and is intentionally slower. It does not start the .NET reverse proxy.

See [SETUP.md](./SETUP.md) for prerequisites, first-time setup, health checks, warm-start shortcuts, and troubleshooting.

### Building for Production

Expand Down Expand Up @@ -417,4 +419,3 @@ npm publish --workspace=@pascal-app/viewer --access public
---

<a href="https://trendshift.io/repositories/23831" target="_blank"><img src="https://trendshift.io/api/badge/repositories/23831" alt="pascalorg/editor | Trendshift" width="250" height="55"/></a>

182 changes: 153 additions & 29 deletions SETUP.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,179 @@
# Pascal Editor — Setup
# Pascal Editor — Local Setup

## Runtime topology

The current local application has three runtime layers:

| Layer | Default URL | Purpose |
|---|---|---|
| Pascal editor | `http://localhost:3002` | Next.js editor, scene APIs, and SSE |
| Pascal AI service | `http://localhost:8788` | AI chat API; starts Pascal MCP as a stdio child automatically |
| Reverse proxy | `http://localhost:8000` | Browser-facing home page and proxy to the editor |

Open **http://localhost:8000** for normal use. `pascal-reverse-front` is static content served by the reverse proxy and does not need a fourth process. The IFC converter on port 3003 is an optional standalone tool and is not part of this three-layer startup.

## Prerequisites

- [Bun](https://bun.sh/) 1.3+ (or Node.js 18+)
- [Bun](https://bun.sh/) 1.3+
- [.NET SDK](https://dotnet.microsoft.com/download) 10+

Node.js alone is not a complete replacement for Bun in this repository: the AI service and its MCP child use Bun runtime APIs.

## Quick Start
Verify both commands before the first startup:

```bash
bun install
bun dev
bun --version
dotnet --version
```

The editor will be running at **http://localhost:3000**.
On macOS, if the runtimes are installed under the user home directory but the commands are not found, add them to the shell path (for example in `~/.zshrc`):

## Environment Variables (optional)
```bash
export PATH="$HOME/.bun/bin:$HOME/.dotnet:$PATH"
```

Copy `.env.example` to `.env` if you need:
Do not use a temporary `npx bun` download for daily startup. It adds cold-start latency, and the AI service's MCP child expects `bun` to remain available on `PATH`.

## First-time setup

Run these once from the repository root:

```bash
bun install
dotnet restore pascal-reverse-proxy/pascal-reverse-proxy.csproj
```

Copy environment settings only when local overrides are needed:

```bash
cp .env.example .env
```

| Variable | Required | Description |
|----------|----------|-------------|
| `NEXT_PUBLIC_GOOGLE_MAPS_API_KEY` | No | Enables address search in the editor |
| `PORT` | No | Dev server port (default: 3000) |
The editor and proxy can start without an AI key. The AI health endpoint then reports `configured: false`, and chat requests remain unavailable until a provider is configured. See [`pascal-ai-mcp/README.md`](./pascal-ai-mcp/README.md) for provider variables.

## Daily fast startup

The editor works fully without any environment variables.
Use three terminals. This avoids starting the optional IFC app and every package watcher on each run.

## Monorepo Structure
### Terminal 1 — editor

From the repository root:

```bash
bun run dev --filter=editor
```
├── apps/
│ └── editor/ # Next.js editor application
├── packages/
│ ├── core/ # @pascal-app/core — Scene schema, state, systems
│ ├── viewer/ # @pascal-app/viewer — 3D rendering
│ └── ui/ # Shared UI components
└── tooling/ # Build & release tooling

This uses Turbo's cached dependency builds and starts the editor on port 3002.

### Terminal 2 — AI service and MCP child

```bash
cd pascal-ai-mcp
bun run dev
```

## Scripts
The AI service starts on port 8788 and launches Pascal MCP over stdio. Do not start a separate MCP process for the default configuration.

### Terminal 3 — reverse proxy and home page

From the repository root:

```bash
dotnet run --project pascal-reverse-proxy --no-restore
```

The reverse proxy starts on port 8000 and serves `pascal-reverse-front` itself.

### Verify all three layers

```bash
curl -I http://127.0.0.1:3002/
curl http://127.0.0.1:8788/health
curl http://127.0.0.1:8000/proxy/health
```

Expected results: editor HTTP 200, AI `"ok": true`, and proxy `"status": "ok"`.

## Faster warm-start options

Use these only when the stated code has not changed:

- Editor-only UI work, with no changes under `packages/`:

```bash
cd apps/editor
bun run dev
```

- Proxy unchanged since its last successful build:

```bash
dotnet run --project pascal-reverse-proxy --no-build
```

The normal `--no-restore` proxy command is safer after source changes because it still performs an incremental build.

## When to use full monorepo development

Use the root command when actively editing shared packages or the optional IFC converter:

```bash
bun dev
```

This starts all workspace `dev` tasks, including package watchers, the editor, the IFC converter, and the AI service. It is intentionally slower and still does **not** start the .NET reverse proxy. Start the proxy separately if the browser-facing entry point is needed.

Do not run the daily three-terminal commands and `bun dev` together; they compete for ports 3002 and 8788.

## Common startup problems

### Port already in use

```bash
lsof -nP -iTCP:3002 -iTCP:8788 -iTCP:8000 -sTCP:LISTEN
```

Stop the old terminal process with `Ctrl+C` before starting another copy. An `EADDRINUSE` error means another process already owns that port.

### AI starts but chat fails

Check:

```bash
curl http://127.0.0.1:8788/health
```

- `configured: false` means the model provider variables are missing.
- If the AI log does not contain `[pascal-mcp] stdio server running`, check that Bun is installed and available on `PATH`.

### Proxy starts but the editor is unavailable

The proxy targets `http://127.0.0.1:3002/`. Start the editor first and verify port 3002 directly.

## Main commands

| Command | Description |
|---------|-------------|
| `bun dev` | Start the development server |
| `bun build` | Build all packages |
| `bun check` | Lint and format check (Biome) |
| `bun check:fix` | Auto-fix lint and format issues |
| `bun check-types` | TypeScript type checking |
|---|---|
| `bun run dev --filter=editor` | Fast editor startup with cached dependency builds |
| `cd pascal-ai-mcp && bun run dev` | Start AI plus its MCP stdio child |
| `dotnet run --project pascal-reverse-proxy --no-restore` | Start the browser-facing proxy |
| `bun dev` | Start every workspace development task; slower |
| `bun build` | Build all workspace packages |
| `bun check` | Run Biome checks |
| `bun check-types` | Run TypeScript checks |

## Repository structure

```text
├── apps/
│ ├── editor/ # Next.js editor, port 3002
│ └── ifc-converter/ # Optional standalone app, port 3003
├── packages/ # Shared core/viewer/editor/nodes/MCP packages
├── pascal-ai-mcp/ # AI HTTP service; starts MCP child, port 8788
├── pascal-reverse-front/ # Static home page served by the proxy
└── pascal-reverse-proxy/ # .NET/YARP browser entry, port 8000
```

## Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on submitting PRs and reporting issues.
See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for contribution guidelines.
40 changes: 40 additions & 0 deletions apps/editor/app/api/ai/[...path]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { type NextRequest, NextResponse } from 'next/server'

const AI_AGENT_URL = (process.env.AI_AGENT_URL ?? 'http://127.0.0.1:8788').replace(/\/+$/, '')

async function proxy(request: NextRequest, context: { params: Promise<{ path: string[] }> }) {
const { path } = await context.params
const target = `${AI_AGENT_URL}/${path.map(encodeURIComponent).join('/')}`
try {
const response = await fetch(target, {
method: request.method,
headers:
request.method === 'GET' || request.method === 'DELETE'
? undefined
: { 'Content-Type': request.headers.get('content-type') ?? 'application/json' },
body:
request.method === 'GET' || request.method === 'DELETE' ? undefined : await request.text(),
cache: 'no-store',
})
// Buffer the full upstream body before responding. Streaming
// `response.body` through for a multi-minute /chat generation risked the
// client receiving a truncated/empty body (then failing `response.json()`
// with "Unexpected end of JSON input") even though the agent finished and
// saved the session. Reading it fully here avoids that truncation.
const bodyText = await response.text()
return new NextResponse(bodyText, {
status: response.status,
headers: { 'Content-Type': response.headers.get('content-type') ?? 'application/json' },
})
} catch (error) {
console.error('[ai-proxy] agent unavailable:', error)
return NextResponse.json(
{ error: 'AI agent is unavailable. Start pascal-ai-mcp and try again.' },
{ status: 503 },
)
}
}

export const GET = proxy
export const POST = proxy
export const DELETE = proxy
2 changes: 1 addition & 1 deletion apps/editor/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function EditorItemsPanel() {

const SIDEBAR_TABS = [
{
id: 'ai-assistant',
id: 'ai',
label: 'AI',
component: AiAssistantPanel,
mobileDefaultSnap: 0.8,
Expand Down
Loading
Loading