Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
3675ab8
bar chart completed
IAMkecheng Feb 27, 2026
8d1ee82
complete bar, line, boxplot, heatmap, area, ranged-dot
IAMkecheng Feb 28, 2026
97c39c7
complete echarts
IAMkecheng Mar 1, 2026
98b6916
Merge remote-tracking branch 'upstream/dev' into dev
IAMkecheng Mar 2, 2026
b31af43
add .vscode/settings.json
Chenglong-MS Mar 4, 2026
acaaa02
Merge remote-tracking branch 'refs/remotes/origin/dev' into dev
Chenglong-MS Mar 4, 2026
148f28f
Bump immutable from 5.1.4 to 5.1.5
dependabot[bot] Mar 4, 2026
f469e06
update dataloader dependency
Chenglong-MS Mar 5, 2026
bede19f
add color suggestion, update echarts
IAMkecheng Mar 6, 2026
927efcb
Merge pull request #249 from IAMkecheng/dev
Chenglong-MS Mar 10, 2026
e193b82
Merge pull request #248 from microsoft/dependabot/npm_and_yarn/immuta…
Chenglong-MS Mar 10, 2026
70f848f
Bump tornado from 6.5.4 to 6.5.5
dependabot[bot] Mar 12, 2026
d34ae91
Configure pipeline: copilot instructions, CI, and static analysis
WolffM Mar 13, 2026
2350dca
Switch copilot-setup-steps to github-hosted runners (firewall enforce…
WolffM Mar 13, 2026
15ac57e
Bump pyjwt from 2.11.0 to 2.12.0
dependabot[bot] Mar 14, 2026
e35bbe1
library update
Chenglong-MS Mar 14, 2026
e1a890e
Add Docker support
WolffM Mar 14, 2026
5ffacfa
fix requirement for deployment
Chenglong-MS Mar 14, 2026
9d72dda
fix color problem of echarts
IAMkecheng Mar 16, 2026
8d35834
fix color of chart.js
IAMkecheng Mar 16, 2026
16717cd
Merge pull request #255 from IAMkecheng/dev
Chenglong-MS Mar 16, 2026
3080868
Potential fix for pull request finding
Chenglong-MS Mar 16, 2026
9b5b8ee
Potential fix for pull request finding
Chenglong-MS Mar 16, 2026
dc0bd46
Potential fix for pull request finding
Chenglong-MS Mar 16, 2026
3aac5ad
fix the color decision function of echarts and chartjs
IAMkecheng Mar 17, 2026
ba7bd02
Update pie.ts
IAMkecheng Mar 17, 2026
7dda34f
fix: docker volume permissions and sandbox user mismatch
Mar 17, 2026
76c7114
Merge pull request #256 from IAMkecheng/dev
Chenglong-MS Mar 17, 2026
f5e46fe
Bump pyasn1 from 0.6.2 to 0.6.3
dependabot[bot] Mar 17, 2026
aacd947
my effort improving stuff
Chenglong-MS Mar 17, 2026
aafa73d
Potential fix for pull request finding
Chenglong-MS Mar 18, 2026
37e406a
security fixes
Chenglong-MS Mar 18, 2026
0bd37dd
Merge pull request #253 from WolffM/fix/85-add-docker-support
Chenglong-MS Mar 18, 2026
1d72a8b
Merge pull request #257 from microsoft/dependabot/uv/pyasn1-0.6.3
Chenglong-MS Mar 18, 2026
c823961
Merge pull request #252 from microsoft/dependabot/uv/pyjwt-2.12.0
Chenglong-MS Mar 18, 2026
180f52f
Merge pull request #251 from microsoft/dependabot/uv/tornado-6.5.5
Chenglong-MS Mar 18, 2026
32ae2c6
move file
Chenglong-MS Mar 18, 2026
2e95ddc
Merge remote-tracking branch 'refs/remotes/origin/dev' into dev
Chenglong-MS Mar 18, 2026
bcf3899
docker update for users
Chenglong-MS Mar 18, 2026
a15ac05
update readme
Chenglong-MS Mar 19, 2026
509c703
template update
Chenglong-MS Mar 19, 2026
cf1cd3a
add *.egg-info/ to .gitignore
zhb-y-agent Mar 19, 2026
48a2b11
Add temporary documentation directory to .gitignore
zhb-y-agent Mar 19, 2026
ec2bb3f
feat(i18n): Add multi-language support, including Chinese and English…
zhb-y-agent Mar 19, 2026
d235e0c
feat(i18n): Add default prompt texts and enhance internationalization…
zhb-y-agent Mar 19, 2026
e727bc1
feat(i18n): Add language switch component to support Chinese and Engl…
zhb-y-agent Mar 19, 2026
395b96c
feat(test): Add test framework and basic test cases for Chinese table…
zhb-y-agent Mar 19, 2026
1c895f3
feat(test): Add Excel file parsing and Chinese table name support
zhb-y-agent Mar 19, 2026
a69f10f
feat(file parsing): Add backend file parsing API and improve table na…
zhb-y-agent Mar 19, 2026
ca761d1
feat(tables): Enhance table list functionality after XLS file upload
zhb-y-agent Mar 19, 2026
7d9b619
feat(file upload): Add drag-and-drop upload functionality and optimiz…
zhb-y-agent Mar 19, 2026
c9da745
feat(fix style issues): Add message type icons and optimize button st…
zhb-y-agent Mar 19, 2026
243ecee
style(SelectableDataGrid): Fix bottom toolbar right spacing
zhb-y-agent Mar 19, 2026
98ad4a0
feat(i18n): Add field tooltips and channel label translations
zhb-y-agent Mar 20, 2026
59ef25d
style(view components): Adjust width styles for encoding shelf and re…
zhb-y-agent Mar 20, 2026
91eb36c
feat(multi-language support): Add multi-language prompt support for a…
zhb-y-agent Mar 20, 2026
e1a9ce8
refactor(i18n): Remove field tooltip text and add channel tooltip text
zhb-y-agent Mar 20, 2026
fa2ffbe
style: Adjust widths of multiple components to improve layout
zhb-y-agent Mar 20, 2026
fa10f52
docs(i18n): Update tooltip strategy description in translation guide
zhb-y-agent Mar 20, 2026
8ae15a4
feat(i18n): Update chart type translations and add category tooltips
zhb-y-agent Mar 20, 2026
6251e32
docs(i18n): Update tooltip strategy section in translation guide
zhb-y-agent Mar 20, 2026
8c8851b
feat(UI): Improve session menu styling and add local file options
zhb-y-agent Mar 20, 2026
e97566c
Here's the English translation:
zhb-y-agent Mar 20, 2026
ab251ed
fix(useFormulateData): Add error handling callback and improve error …
zhb-y-agent Mar 20, 2026
55f658f
fix(layout): Adjust card layout calculation and margin styles
zhb-y-agent Mar 20, 2026
f157152
fix(VisualizationView): Optimize scroll behavior during collapse anim…
zhb-y-agent Mar 20, 2026
d9fbdc4
fix(DataView): Adjust row number column styles and width
zhb-y-agent Mar 20, 2026
fb6639f
style(ReportView): Adjust spacing and font styles in report view
zhb-y-agent Mar 20, 2026
507917e
feat(test): Add frontend unit testing infrastructure and test cases
zhb-y-agent Mar 21, 2026
6630412
fix(rendering): Fix object values being rendered directly in React co…
zhb-y-agent Mar 21, 2026
130b53c
fix: Add ensure_ascii=False parameter to all json.dumps calls to pres…
zhb-y-agent Mar 21, 2026
b9d8f1e
fix(multimodal support): Add image input detection and automatic fall…
zhb-y-agent Mar 21, 2026
3bb3b0e
fix(agent_routes): Enhance error handling in derive_data and refine_d…
zhb-y-agent Mar 21, 2026
c291d79
test(backend): Add unit tests and integration tests
zhb-y-agent Mar 21, 2026
078ed41
feat(model management): Implement server-side global model configuration
zhb-y-agent Mar 21, 2026
ee0fa25
test(backend): Add unit tests for global model API endpoints, securit…
zhb-y-agent Mar 21, 2026
d5f0cba
docs(env): Update comments in environment variable template
zhb-y-agent Mar 21, 2026
af4b92e
feat(App): Refactor App component to include TopNavButton and AppShel…
zhb-y-agent Mar 21, 2026
36d5cb4
feat(agent): Enhance data agents with model information and improved …
zhb-y-agent Mar 22, 2026
c12fc17
feat(agent): Modify system prompt handling for language instructions
zhb-y-agent Mar 22, 2026
874ff2f
feat(App): Update ResetDialog functionality and i18n strings for sess…
zhb-y-agent Mar 22, 2026
ff98e19
refactor(ReportView): Simplify model selection logic in ReportView co…
zhb-y-agent Mar 22, 2026
687188d
fix(report view): fix chart ID replacement logic and optimize i18n fi…
zhb-y-agent Mar 22, 2026
6c0da55
refactor(client): remove unused image block processing functionality
zhb-y-agent Mar 22, 2026
9b73ce4
fix: improve file parsing error logging
zhb-y-agent Mar 22, 2026
07fe32f
docs(tests): update test documentation to reflect current test struct…
zhb-y-agent Mar 22, 2026
47c81a2
feat(agent_utils): add functionality to supplement missing code block…
zhb-y-agent Mar 22, 2026
803acb7
build: add openpyxl dependency for Excel file support
zhb-y-agent Mar 22, 2026
ce3d88f
feat(config): add toggle for auto-generating chart insights
zhb-y-agent Mar 22, 2026
6853e6a
feat(datalake): support Unicode filenames and add path traversal checks
zhb-y-agent Mar 22, 2026
96cf69f
feat(filename handling): Add safe filename processing function and re…
zhb-y-agent Mar 22, 2026
4d4134e
fix(datalake): Add atomic metadata update to prevent lost updates in …
zhb-y-agent Mar 22, 2026
d92822b
fix(sandbox): Adjust library preload and audit hook order to support …
zhb-y-agent Mar 22, 2026
b9e87fb
feat(data management): Add delete tables by source file feature
zhb-y-agent Mar 22, 2026
8172abd
test: Add regression test cases covering Unicode filenames, concurren…
zhb-y-agent Mar 22, 2026
be433b2
feat(file encoding): Add file reading functionality with UTF-8 and GB…
zhb-y-agent Mar 22, 2026
5df6c40
feat(file encoding): Improve text file encoding detection and convers…
zhb-y-agent Mar 22, 2026
ac459a2
test(backend/contract): Add tests for uploading files with same name …
zhb-y-agent Mar 22, 2026
4ddd212
build: Update openpyxl dependency to 3.1.0 or higher
zhb-y-agent Mar 22, 2026
ae494ce
feat(data source): Add original table name support and unify table na…
zhb-y-agent Mar 22, 2026
d870e8d
refactor(VisualizationView): Replace static SVG rendering with vega-e…
zhb-y-agent Mar 22, 2026
959e892
feat(agents): Introduce unified diagnostic information builder
zhb-y-agent Mar 23, 2026
bf24cf7
refactor(agent_data_load): Change system_prompt to instance variable …
zhb-y-agent Mar 23, 2026
f1f3de6
feat(agents): Enhance output variable handling in DataRecAgent and Da…
zhb-y-agent Mar 23, 2026
7e75793
feat(agents): Improve handling of missing output blocks and enhance o…
zhb-y-agent Mar 23, 2026
5878be1
feat: finalize 0.7 improvements for data workflows, i18n, model manag…
zhb-ai Mar 24, 2026
c5d3b72
feat(i18n): Add max exploration steps message and optimize data agent…
zhb-y-agent Mar 24, 2026
4c1ca48
feat(i18n): Add more language options and corresponding additional rules
zhb-y-agent Mar 24, 2026
69418fd
fix: Only fetch chart insights when auto chart insights is enabled
zhb-y-agent Mar 24, 2026
fca161b
fix(ReportView): Fix issue where charts sometimes require browser ref…
zhb-y-agent Mar 24, 2026
bf1c8ee
minor
Chenglong-MS Mar 24, 2026
d4f333c
Merge pull request #263 from microsoft/feature/i18n-react-i18next
zhb-ai Mar 25, 2026
0d6a334
feat(security): Add error message sanitization and unify error handling
zhb-y-agent Mar 25, 2026
ae9a24f
chore(deps): migrate from npm to yarn and update lockfile
zhb-y-agent Mar 25, 2026
f2b433a
chore: add package-lock.json to .gitignore
zhb-y-agent Mar 25, 2026
66dc27b
Merge pull request #264 from microsoft/feature/i18n-react-i18next
zhb-ai Mar 25, 2026
74e7ed0
build: add openpyxl and xlrd dependencies for Excel file processing
zhb-y-agent Mar 25, 2026
acc39d2
build: update i18next dependency to pinned version 25.8.19
zhb-y-agent Mar 25, 2026
7c3ce25
build: update i18next dependency to pinned version 25.8.19
zhb-ai Mar 25, 2026
ed706bc
fix(agent_routes): change model test error log level from warning to …
zhb-y-agent Mar 27, 2026
7f617f7
Merge pull request #269 from microsoft/feature/i18n-react-i18next
zhb-ai Mar 27, 2026
32138af
docs: add plugin architecture design documents
zhb-y-agent Mar 27, 2026
0e14c19
minor fixes
Chenglong-MS Mar 28, 2026
2f601e0
new canvas design
Chenglong-MS Mar 28, 2026
69f8d8f
some redesign
Chenglong-MS Mar 28, 2026
c1f98a7
Bump cryptography from 46.0.4 to 46.0.6
dependabot[bot] Mar 29, 2026
4247401
docs(sso-plugin-architecture): update protocol selection section and …
zhb-y-agent Mar 29, 2026
20680c5
Merge pull request #273 from microsoft/dev
zhb-ai Mar 29, 2026
7b71294
Merge branch 'feature/plugin-architecture' of https://github.com/micr…
zhb-y-agent Mar 29, 2026
a3d415a
Bump pygments from 2.19.2 to 2.20.0
dependabot[bot] Mar 30, 2026
b94ba45
Bump aiohttp from 3.13.3 to 3.13.4
dependabot[bot] Apr 1, 2026
dc0c36b
clean up some formatting stuff
Chenglong-MS Apr 2, 2026
a71903d
Bump litellm from 1.81.6 to 1.83.0
dependabot[bot] Apr 3, 2026
fcf92a1
Bump tornado from 6.5.4 to 6.5.5
dependabot[bot] Apr 4, 2026
06c3744
add test infra
Chenglong-MS Apr 6, 2026
026f8ae
Merge pull request #272 from microsoft/dependabot/uv/cryptography-46.0.6
Chenglong-MS Apr 6, 2026
07dea4d
Merge pull request #274 from microsoft/dependabot/uv/pygments-2.20.0
Chenglong-MS Apr 6, 2026
ca71f43
Merge pull request #275 from microsoft/dependabot/uv/aiohttp-3.13.4
Chenglong-MS Apr 6, 2026
0ab9c78
Merge pull request #276 from microsoft/dependabot/uv/litellm-1.83.0
Chenglong-MS Apr 6, 2026
ad2823f
Merge pull request #277 from microsoft/dependabot/uv/tornado-6.5.5
Chenglong-MS Apr 6, 2026
6a5f2d2
workflow refactor
Chenglong-MS Apr 7, 2026
4d5cbc1
hybrid thread
Chenglong-MS Apr 7, 2026
7d26881
Merge pull request #279 from microsoft/dev
zhb-ai Apr 7, 2026
5074a5d
Refactor SSO plugin architecture documentation to clarify the AuthPro…
zhb-y-agent Apr 7, 2026
15401cc
docs(design-docs): 更新数据加载器架构文档并拆分外部加载器演进方案
zhb-y-agent Apr 7, 2026
bc395c4
report unified to threads
Chenglong-MS Apr 7, 2026
ff1e252
reports update
Chenglong-MS Apr 8, 2026
59a6bd7
fixes and improvements
Chenglong-MS Apr 8, 2026
e0597f4
fix issues from zhb
Chenglong-MS Apr 8, 2026
f47ada0
Merge pull request #281 from microsoft/dev
zhb-ai Apr 8, 2026
346643a
minor
Chenglong-MS Apr 8, 2026
ee274db
Merge pull request #282 from microsoft/dev
zhb-ai Apr 8, 2026
c4ae334
docs: 添加SSO与数据源插件开发路线图文档
zhb-y-agent Apr 8, 2026
503a531
docs(设计文档): 更新开发路线图文档内容
zhb-y-agent Apr 8, 2026
2606282
docs(design-docs): 添加数据溯源描述的设计实现细节
zhb-y-agent Apr 8, 2026
5fcf0df
new workspace design
Chenglong-MS Apr 9, 2026
ca6412d
improvement of workspace
Chenglong-MS Apr 9, 2026
acbd871
style fix
Chenglong-MS Apr 9, 2026
01ca011
Merge pull request #284 from microsoft/dev
zhb-ai Apr 9, 2026
415fdf1
docs: 统一数据源插件环境变量前缀为PLG_
zhb-y-agent Apr 9, 2026
3c0fddc
docs(design-docs): 更新数据源插件架构文档并添加多语言注入分析
zhb-y-agent Apr 9, 2026
5ee5374
docs(语言注入): 更新多语言提示词注入分析文档
zhb-y-agent Apr 9, 2026
e5e0e5f
new workspace model
Chenglong-MS Apr 10, 2026
fc7ba5d
Merge pull request #287 from microsoft/dev
zhb-ai Apr 10, 2026
fedd5d3
workspace redesign complete
Chenglong-MS Apr 10, 2026
80afd88
fix a chart rendering bug
Chenglong-MS Apr 10, 2026
88dc4ca
Merge pull request #288 from microsoft/dev
zhb-ai Apr 10, 2026
ef4f57d
docs: 更新数据源插件架构文档以反映工作区存储模型
zhb-y-agent Apr 10, 2026
3b053b0
eat(security): Implement pluggable authentication system and add Azur…
zhb-y-agent Apr 10, 2026
7afef5b
feat(plugin integration): Add plugin table loading functionality and …
zhb-y-agent Apr 10, 2026
78bf391
feat: Add Superset plugin support and OIDC authentication integration
zhb-y-agent Apr 10, 2026
c040b8b
feat(plugins): Add plugin localization support and refactor Superset …
zhb-y-agent Apr 10, 2026
6d6e61b
feat(plugins): Add plugin localization support and refactor Superset …
zhb-y-agent Apr 10, 2026
935b548
docs(设计文档): 添加插件i18n自包含方案
zhb-y-agent Apr 10, 2026
9028faf
docs(i18n): Update translation guide to include plugin translation in…
zhb-y-agent Apr 10, 2026
eae255d
feat(auth): Add OAuth2 alias and update authentication documentation
zhb-y-agent Apr 10, 2026
eb4ebd5
docs(oidc): 补充OIDC/OAuth2 Provider对接的详细要求
zhb-y-agent Apr 10, 2026
f4d9e40
feat(plugin): Add password visibility toggle and description text for…
zhb-y-agent Apr 10, 2026
9b7c24c
feat(auth): Support manual OIDC/OAuth2 endpoint configuration and add…
zhb-y-agent Apr 10, 2026
98c83f7
feat(身份迁移): 实现匿名用户到认证用户的身份迁移功能
zhb-y-agent Apr 10, 2026
37017cc
feat(migration): Add anonymous workspace data migration functionality
zhb-y-agent Apr 10, 2026
b3bde64
fix(AuthButton): Improve logout logic to handle missing end_session_e…
zhb-y-agent Apr 10, 2026
72e2ae5
fix(identity migration): Prevent duplicate triggering of anonymous to…
zhb-y-agent Apr 10, 2026
82e916e
feat(authentication): Improve identity migration flow and local stora…
zhb-y-agent Apr 10, 2026
a122e77
feat(workspace): Improve robustness of anonymous workspace migration …
zhb-y-agent Apr 10, 2026
7b98382
feat(login): Add support for IdP-initiated SSO flow
zhb-y-agent Apr 10, 2026
de3559a
Merge pull request #289 from microsoft/feature/plugin-architecture
zhb-ai Apr 10, 2026
5142bc2
feat(auth): Add silent token refresh functionality and enhance securi…
zhb-y-agent Apr 11, 2026
c5f2ad4
fix(bug): Fix abnormal display status when canceling import
zhb-y-agent Apr 11, 2026
e2c9532
fix(IdentityMigrationDialog): Fix issue with preserving workspace dat…
zhb-y-agent Apr 11, 2026
28a526c
docs: 添加数据源插件开发指南文档
zhb-y-agent Apr 11, 2026
eac6515
eat(tables_routes): Add export table to CSV/TSV functionality
zhb-y-agent Apr 11, 2026
ec86904
feat(credential vault): Add credential vault feature to support remem…
zhb-y-agent Apr 11, 2026
67b31ff
Merge pull request #290 from microsoft/feature/plugin-architecture
zhb-ai Apr 11, 2026
a4782b1
feat(security): 新增 ConfinedDir 路径安全原语及修复漏洞
zhb-y-agent Apr 11, 2026
0768156
feat(security): Add error message sanitization and unified error resp…
zhb-y-agent Apr 11, 2026
5374ef5
Merge pull request #291 from microsoft/feature/plugin-architecture
zhb-ai Apr 11, 2026
ef48ebb
fix: Improve error handling logic to provide more user-friendly error…
zhb-y-agent Apr 11, 2026
3ee96c5
Merge pull request #292 from microsoft/feature/plugin-architecture
zhb-ai Apr 11, 2026
4f65c4f
fix(security): Improve error message handling to enhance security
zhb-y-agent Apr 11, 2026
e9ae67f
Merge pull request #293 from microsoft/feature/plugin-architecture
zhb-ai Apr 11, 2026
da60eeb
fix(security): Unify error message handling to prevent sensitive info…
zhb-y-agent Apr 11, 2026
c1f9378
Merge pull request #294 from microsoft/feature/plugin-architecture
zhb-ai Apr 11, 2026
0cb48cc
feat(security): Add LLM error classification functionality and update…
zhb-y-agent Apr 11, 2026
4cb08c6
Merge pull request #295 from microsoft/feature/plugin-architecture
zhb-ai Apr 11, 2026
20b9f40
docs: Add and update multiple documentation files and skills
zhb-y-agent Apr 11, 2026
28088e4
Merge pull request #296 from microsoft/feature/plugin-architecture
zhb-ai Apr 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
63 changes: 63 additions & 0 deletions .cursor/rules/backend-test-conventions.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
description: Backend Python test conventions (pytest)
globs: tests/backend/**/*.py
alwaysApply: false
---

# Backend Test Conventions

## File Location & Naming

- Place tests under `tests/backend/unit/`, `tests/backend/integration/`, or `tests/backend/contract/`.
- Name files `test_<feature_or_module>.py` with descriptive snake_case names.
- Shared test data goes in `tests/backend/fixtures/`.

## File Structure

```python
"""One-paragraph summary of what is being tested and why.

Background
----------
Brief context about the feature or bug fix these tests validate.
"""
from __future__ import annotations

import pytest

pytestmark = [pytest.mark.backend]
```

## Conventions

- Always add `pytestmark = [pytest.mark.backend]` at module level.
- Group related tests in classes prefixed with `Test` (e.g. `TestStripImageBlocks`).
- Use `pytest.mark.parametrize` for data-driven tests instead of writing repetitive cases.
- Use `pytest.fixture()` for shared setup; keep fixtures close to where they are used.
- Unit tests must **not** depend on Flask, network, or external services.
- Mock external calls with `unittest.mock.patch` / `MagicMock`; never make real API calls.
- Each test function should verify **one** behavior and have a clear name: `test_<what>_<condition>`.

## Running Tests

- When running pytest, use `-q` (quiet mode) instead of `-v` (verbose mode) for cleaner output.
- **Preferred:** `python -m pytest tests/backend/ -q`
- **Avoid:** `python -m pytest tests/backend/ -v 2>&1`

## Example

```python
# ❌ BAD – vague name, no parametrize, no marker
def test_it_works():
assert sanitize("hello world") == "hello_world"

# ✅ GOOD
pytestmark = [pytest.mark.backend]

@pytest.mark.parametrize("raw,expected", [
("hello world", "hello_world"),
("订单明细", "订单明细"),
])
def test_sanitize_preserves_unicode(raw: str, expected: str) -> None:
assert sanitize(raw) == expected
```
61 changes: 61 additions & 0 deletions .cursor/rules/error-response-safety.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
description: Prevent information exposure through exception messages in HTTP responses
globs: py-src/**/*.py
alwaysApply: false
---

# Error Response Safety

Never return raw exception text (`str(e)`, `f"...{e}"`) directly in HTTP responses.
Python exceptions may contain stack traces, file paths, database connection strings,
API keys, or internal IP addresses — all of which are security risks (CWE-209).

## Rules

1. **5xx errors** — return a fixed generic message; never expose exception details.
2. **502 errors** — return `"Upstream service unavailable"`; never include upstream error body.
3. **4xx errors** — run `sanitize_error_message(str(e))` so business-validation messages
stay useful while secrets are stripped.
4. **Logging** — always log the full exception server-side (`logger.warning` / `logger.error`
with `exc_info=True` when needed). The client never needs the stack trace.

## How To

For Flask route `except` blocks, use `safe_error_response`:

```python
from data_formulator.security.sanitize import safe_error_response

except HTTPError as e:
return safe_error_response(e, 502, log_message="Upstream call failed")
except ValueError as e:
return safe_error_response(e, 400, log_message="Invalid input")
except Exception as e:
return safe_error_response(e, 500, log_message="Unexpected error")
```

For non-route contexts (generators, background tasks) where a Flask response
cannot be returned, use `sanitize_error_message` directly:

```python
from data_formulator.security.sanitize import sanitize_error_message

except Exception as exc:
logger.error("Task failed: %s", exc, exc_info=True)
payload = {"status": "error", "message": sanitize_error_message(str(exc))}
```

## Common Mistakes

```python
# ❌ BAD — raw exception leaks internal details
return jsonify({"message": str(e)}), 500
return jsonify({"message": f"Failed: {e}"}), 502

# ❌ BAD — manual traceback in response
import traceback
return jsonify({"message": traceback.format_exc()}), 500

# ✅ GOOD
return safe_error_response(e, 500, log_message="Operation failed")
```
64 changes: 64 additions & 0 deletions .cursor/rules/frontend-test-conventions.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
description: Frontend TypeScript test conventions (Vitest)
globs: tests/frontend/**/*.test.{ts,tsx}
alwaysApply: false
---

# Frontend Test Conventions

## File Location & Naming

- Place tests under `tests/frontend/unit/` mirroring the `src/` structure:
- `tests/frontend/unit/data/` → tests for `src/data/`
- `tests/frontend/unit/app/` → tests for `src/app/`
- `tests/frontend/unit/views/` → tests for `src/views/`
- Name files `<functionOrFeature>.test.ts` (or `.test.tsx` for React rendering tests).

## File Structure

```typescript
import { describe, it, expect } from 'vitest';
// For React rendering tests:
// import { render } from '@testing-library/react';

import { myFunction } from '../../../../src/<path>';

describe('myFunction', () => {
it('should handle <specific case>', () => {
expect(myFunction(input)).toBe(expected);
});
});
```

## Conventions

- Import `describe`, `it`, `expect` explicitly from `vitest` (globals are enabled but explicit imports improve readability).
- Use `@testing-library/react` and `@testing-library/jest-dom` for component rendering tests.
- Prefer testing **exported pure functions** over testing internal component state.
- When component logic is complex, extract it into an exported helper and test that directly.
- Group tests with `describe` blocks; use section comments (`// --- Null cases ---`) for clarity.
- One assertion per `it` block when possible; name tests as `should <expected behavior>`.
- Do **not** import from `node_modules` internals; only use public API.
- Keep tests independent — no shared mutable state between `it` blocks.

## Example

```typescript
// ❌ BAD – no describe, vague test name
import { expect, test } from 'vitest';
test('works', () => { expect(fn(1)).toBe(2); });

// ✅ GOOD
import { describe, it, expect } from 'vitest';
import { checkIsLikelyTextOnlyModel } from '../../../../src/views/DataLoadingThread';

describe('checkIsLikelyTextOnlyModel', () => {
it('returns true for deepseek-chat', () => {
expect(checkIsLikelyTextOnlyModel('deepseek-chat')).toBe(true);
});

it('returns false for undefined', () => {
expect(checkIsLikelyTextOnlyModel(undefined)).toBe(false);
});
});
```
40 changes: 40 additions & 0 deletions .cursor/rules/i18n-no-hardcoded-strings.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
description: No hardcoded UI strings — use i18n translation keys
globs: src/**/*.{ts,tsx}
alwaysApply: false
---

# i18n: No Hardcoded UI Strings

All user-visible text in the frontend MUST go through the i18n system. Never hardcode Chinese, English, or any other language string directly in components.

## How to Use

```tsx
import { useTranslation } from 'react-i18next';

const { t } = useTranslation();

// ✅ GOOD
<Button>{t('common.save')}</Button>
<Tooltip content={t('chart.noData')} />

// ❌ BAD
<Button>保存</Button>
<Button>Save</Button>
<Tooltip content="No data available" />
```

## Translation Files

- English: `src/i18n/locales/en/<namespace>.json`
- Chinese: `src/i18n/locales/zh/<namespace>.json`
- Namespaces: `common`, `upload`, `chart`, `model`, `encoding`, `messages`, `navigation`

When adding a new key, add it to **both** `en` and `zh` locale files. Pick the namespace that fits; create a new namespace only if none applies.

## What Counts as User-Visible

Must use `t()`: button labels, tooltips, placeholders, error messages, dialog titles, tab names, toast notifications, table headers, empty-state text.

May stay hardcoded: log messages (`console.log`), error messages thrown but never displayed, internal constants, CSS class names, test IDs.
21 changes: 21 additions & 0 deletions .cursor/rules/language-injection-conventions.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
description: Language injection conventions for LLM Agent prompts
globs: py-src/data_formulator/agents/**/*.py,py-src/data_formulator/agent_routes.py
alwaysApply: false
---

# Language Injection Conventions

Language flows per-request: `Frontend i18n → Accept-Language header → get_language_instruction() → system prompt`.

## Rules

1. **User-facing LLM output** MUST inject language via `get_language_instruction(mode=...)` in the route handler.
2. **Mode selection:** `"full"` for text-heavy agents, `"compact"` for code-generation agents and short-text endpoints.
3. **Inject into system prompt only** — append or insert before a marker, never into user messages.
4. **Do NOT inject** for non-user-facing calls (health checks, internal tool calls).
5. **Do NOT duplicate** — if upstream messages already contain language instruction, skip.
6. **Do NOT** use env vars, global interceptors, or hardcoded language strings (e.g. `"回答请使用中文"`) — always use `build_language_instruction()`.
7. **New language?** Add to `LANGUAGE_DISPLAY_NAMES` in `agents/agent_language.py` and add locale files in `src/i18n/locales/<lang>/`.

For detailed architecture, code examples, and anti-pattern explanations, see the language-injection skill.
12 changes: 12 additions & 0 deletions .cursor/rules/package-manager-conventions.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
description: Use Yarn only, never npm/pnpm
globs: package.json, yarn.lock
alwaysApply: true
---

# Package Manager Rules

- Use Yarn v1.22.22 only - never use npm or pnpm
- Never manually edit yarn.lock
- Keep yarn.lock changes minimal when adding deps
- Registry must be https://registry.yarnpkg.com
72 changes: 72 additions & 0 deletions .cursor/skills/language-injection/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Language Injection for Agent Prompts

Detailed guide for the language injection system. The short version lives in `.cursor/rules/language-injection-conventions.mdc`.

## Architecture

```
Frontend i18n.language → Accept-Language header → get_language_instruction()
build_language_instruction()
(agents/agent_language.py)
┌────────────┴────────────┐
▼ ▼
mode="full" mode="compact"
(text-heavy agents) (code-gen agents)
```

### Core Modules

| Module | Role |
|--------|------|
| `agents/agent_language.py` | `build_language_instruction(lang, mode)` — generates prompt fragments; supports 20 languages; returns `""` for English |
| `agent_routes.py` → `get_language_instruction()` | Reads `Accept-Language` header, delegates to `build_language_instruction` |
| `src/app/utils.tsx` → `fetchWithIdentity()` | Sets `Accept-Language` header on every API request from `i18n.language` |

## Code Examples

### Route handler — inject language

```python
# In a Flask route handler:
lang_instruction = get_language_instruction(mode="compact")
lang_suffix = f"\n\n{lang_instruction}" if lang_instruction else ""

messages = [
{"role": "system", "content": "You are a helpful assistant." + lang_suffix},
{"role": "user", "content": user_input},
]
```

### Agent constructor — marker-based insertion

```python
if language_instruction:
marker = "**About the execution environment:**"
idx = self.system_prompt.find(marker)
if idx > 0:
self.system_prompt = (
self.system_prompt[:idx]
+ language_instruction + "\n\n"
+ self.system_prompt[idx:]
)
else:
self.system_prompt += "\n\n" + language_instruction
```

## Anti-Patterns (with explanations)

| Pattern | Why it's wrong |
|---------|---------------|
| `os.environ.get("DF_DEFAULT_LANGUAGE")` | Process-level — all users get same language; breaks multi-user |
| Global LLM client interceptor | Hidden behavior; can't distinguish full/compact mode; fragile string detection |
| New `MessageBuilder` class | Duplicates `agent_language.py`; creates parallel conflicting abstractions |
| Hardcoded `"回答请使用中文"` in prompts | Not configurable; skips the mode system; breaks for other languages |

## Adding a New Language

1. Add language code + display name to `LANGUAGE_DISPLAY_NAMES` in `agents/agent_language.py`.
2. Optionally add extra rules to `LANGUAGE_EXTRA_RULES` (e.g. simplified vs traditional Chinese).
3. Add frontend translations in `src/i18n/locales/<lang>/` — copy an existing locale folder as template.
4. No Agent code changes needed — the existing flow picks up new languages automatically.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.git
.gitignore
node_modules
__pycache__
*.pyc
.env
.env.*
*.egg-info
dist
build
.pytest_cache
.mypy_cache
Loading
Loading