Skip to content

Commit 833301a

Browse files
lxfu1hustcc逍为Copilotgemini-code-assist[bot]
authored
feat: add g2 skills with best engineering practices (#36)
* chore: 新增 g2 skills * chore: add performance part * fix: test * fix: Ai CR * chore: user invocable * chore: AI SDK 优化 * chore: add harness * fix: path error * chore: 补充参考文档 * chore: 新增 grep 兜底检索 * chore: eval 自检更新 * chore: 删除无效scripts * chore: skill 优化 * chore: add worktree * chore: add kimi model * chore: override env * fix: 修复 data 格式错误 * chore: 目录结构调整 * chore: 补充评测数据 * chore: 删除 common 模块 * chore: 优化 scale skill * chore: skill tool 移动到 cli 下 * chore: add playground * refactor: skill cli (#37) Co-authored-by: 逍为 <xiaowei.wzw@antgroup.com> Co-authored-by: Joel Alan <31396322+lxfu1@users.noreply.github.com> * test: fix ci workflow (#38) Co-authored-by: 逍为 <xiaowei.wzw@antgroup.com> * docs: add readme for cli usage (#39) * docs: add readme for cli usage * docs: fix skill typo * docs: update * test: fix ci --------- Co-authored-by: 逍为 <xiaowei.wzw@antgroup.com> * refactor: playground for cli and skill (#40) * chore: 补全 playground libs * fix: ts * fix: resolve conversation * chore: 代码优化 * fix: 修复由于 nextjs 加载源码导致 __dirname 异常 (#44) * chore: 添加 claude plugin (#43) * refactor: eval logic (#42) * chore: 优化 harness 逻辑 (#48) * chore: 优化 harness 逻辑 * chore: 优化 harness 流程 * fix: result count * feat: 新增 retrieveWithContent (#49) * feat: 新增 retrieveWithContent * fix: test * chore: loadSkillContent 目录约束 * fix: 修复 work tree 模式下 __dirname 不一致导致的优化异常 * chore: 新增 harness 优化 skill 后的基线对比逻辑 (#51) * chore: cli 重命名 (#52) * chore: cli 重命名 * fix: tests * refactor: antv cli (#53) * 精简索引构建输出并优化检索链路(移除 indexDir、使用 gray-matter 解析元数据、简化 includeContent,并统一 index 到 src/index→dist/index) (#56) * Refactor playground AI flow to Vercel AI SDK with Skill/CLI mode tool assembly and token usage visibility (#54) * Initial plan * refactor(playground): migrate chat flow to vercel ai sdk Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/60eb740b-946b-4dbc-8065-b2143da12fa4 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * fix(playground): harden skill path handling and restore temperature Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/60eb740b-946b-4dbc-8065-b2143da12fa4 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * refactor(playground): split skill tools into separate modules Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/bcdb3e77-18a5-4b73-8c9d-4ae97f87510a Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * feat(playground): redesign dual-mode ai tools workflow Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/dd7b7fe2-54a4-4e8c-ac4d-531df443ff31 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * fix(playground): normalize library naming in prompts Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/dd7b7fe2-54a4-4e8c-ac4d-531df443ff31 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * fix(playground): tighten tool input limits and constants Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/dd7b7fe2-54a4-4e8c-ac4d-531df443ff31 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * fix(playground): simplify read-file validation fallback naming Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/dd7b7fe2-54a4-4e8c-ac4d-531df443ff31 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * refactor(playground): use explicit step constants and schemas Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/dd7b7fe2-54a4-4e8c-ac4d-531df443ff31 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * refactor(playground): rename modes to skill/cli and unify tools directory Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/69d26ddf-26a6-43dd-bdca-32bb851ea746 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * fix(playground): harden tools path handling and naming Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/69d26ddf-26a6-43dd-bdca-32bb851ea746 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * fix(playground): tighten tool path validation guards Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/69d26ddf-26a6-43dd-bdca-32bb851ea746 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * refactor(playground): move mode entry files above tools directory Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/e4438102-2cd2-42ac-b772-a29fa11c5a20 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * fix(playground): adapt retrieve tool to updated retrieve api Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/8d505619-d6d9-48dd-85a5-af7c42bc73b7 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * refactor(playground): remove retrieve content fallback path Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/c8187137-e11b-480a-9abf-ed20f30bb6f7 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * refactor(playground): use gray-matter in list references tool Agent-Logs-Url: https://github.com/antvis/chart-visualization-skills/sessions/23696116-a1cb-402e-954e-06b426ddc4b2 Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> * chore: opt cli command * refactor: playground * feat: fix style * feat: update website meta info * fix: tool call error --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> Co-authored-by: hustcc <i@hust.cc> Co-authored-by: 逍为 <xiaowei.wzw@antgroup.com> * refactor: 重构 g2-chart skill (#57) * refactor: 重构 g2-chart skill * chore: resolve skill * chore: 去掉 eval 中 list refercnces 逻辑 * chore: playground 模块支持加载外层 env (#58) * chore: playground 模块支持加载外层 env * Apply suggestions from code review Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: hustcc <i@hust.cc> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * docs: add agent.md (#60) * docs: add agent.md * chore: fix typo --------- Co-authored-by: 逍为 <xiaowei.wzw@antgroup.com> * chore: 修改 env 示例 (#59) * chore: 修改 env 示例 * chore: 新增 VL Model 配置示例 * refactor: playground (#61) * refactor: playground * Update playground/src/libs/cli-mode.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update playground/src/libs/skill-mode.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update playground/src/app/api/generate/route.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: 逍为 <xiaowei.wzw@antgroup.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: hustcc <i@hust.cc> Co-authored-by: 逍为 <xiaowei.wzw@antgroup.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 41baec1 commit 833301a

267 files changed

Lines changed: 95926 additions & 19 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude-plugin/marketplace.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@
4545
"./skills/narrative-text-visualization"
4646
]
4747
},
48+
{
49+
"name": "antv-g2-chart",
50+
"description": "Generate G2 v5 chart code. Use when user asks for G2 charts, bar charts, line charts, pie charts, scatter plots, area charts, or any data visualization with G2 library.",
51+
"source": "./",
52+
"strict": false,
53+
"skills": [
54+
"./skills/antv-g2-chart"
55+
]
56+
},
4857
{
4958
"name": "antv-s2-expert",
5059
"description": "S2 multi-dimensional cross-analysis table development assistant. Use when users need help with S2 pivot tables, table sheets, or any @antv/s2 related development.",

.env.example

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# AI Provider API Keys
2+
# Playground Provider Path: playground/src/libs/provider.ts
3+
4+
# DeepSeek API Key
5+
DEEPSEEK_API_KEY=your-deepseek-api-key-here
6+
# DeepSeek API Endpoint
7+
DEEPSEEK_API_ENDPOINT=https://api.deepseek.com
8+
# DeepSeek API Path
9+
DEEPSEEK_API_PATH=/v1/chat/completions
10+
# DeepSeek Model Name
11+
DEEPSEEK_MODEL=model-name
12+
13+
# VL Model Name(Optional)
14+
VL_MODEL=model-name

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ jobs:
2424
- name: Install dependencies
2525
run: npm install
2626

27+
- name: Buidl project
28+
run: npm run build
29+
2730
- name: Run tests
2831
run: npm test

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,35 @@ yarn-error.log*
4242
# OS
4343
.DS_Store
4444
Thumbs.db
45+
46+
# env
47+
.env
48+
49+
# Eval results (local runs, not for review)
50+
# eval/result/
51+
logs
52+
53+
# Validator state directory
54+
eval/temp/
55+
56+
# harness
57+
harness/memory.json
58+
59+
# lock files
60+
pnpm-lock.yaml
61+
62+
# skills index
63+
src/index/
64+
65+
# Playground (Next.js)
66+
playground/.next/
67+
playground/node_modules/
68+
playground/.env.local
69+
playground/out/
70+
71+
72+
# TypeScript build cache
73+
*.tsbuildinfo
74+
75+
# AI
76+
settings.local.json

Agent.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Agent.md - AntV Chart Visualization Skills
2+
3+
## Overview
4+
5+
This project is a skill-based system for generating chart visualization code using AntV libraries (G2, G6, S2, etc.). It provides AI agents with structured knowledge about chart types, best practices, and API usage, enabling them to generate correct chart code from natural language queries.
6+
7+
## Core Workflow
8+
9+
```
10+
┌─────────────────────────┐
11+
│ Document + Code │
12+
└───────────┬─────────────┘
13+
14+
v
15+
┌────────────────────────┐
16+
┌───>│ Skills │<────┐
17+
│ └───────────┬────────────┘ │
18+
│ │ │
19+
│ v │
20+
│ ┌────────────────────────┐ │
21+
│ │ CLI Tool │ │
22+
│ │ (BM25 Retrieve/List) │ │
23+
│ └───────────┬────────────┘ │
24+
│ │ │
25+
│ v │
26+
│ ┌────────────────────────┐ │
27+
│ │ Eval + Harness │ │
28+
│ │ (evaluate & optimize) │─────┘
29+
│ └───────────┬────────────┘
30+
│ │
31+
│ v
32+
│ ┌────────────────────────┐
33+
└────│ Playground │
34+
│ (interactive preview) │
35+
└────────────────────────┘
36+
```
37+
38+
Eval + Harness 通过自动化评测发现问题,再由 LLM 优化 Skill 文档,形成闭环持续提升 Skill 质量。
39+
40+
### 1. Skill Authoring (`skills/`)
41+
42+
Skills are markdown files with YAML frontmatter, organized by library. Each skill documents a chart type or visualization pattern with metadata (category, tags, difficulty, use cases) and content (best practices, API usage, code examples).
43+
44+
```
45+
skills/
46+
├── antv-g2-chart/ # G2 chart skills + reference docs
47+
├── antv-s2-expert/ # S2 pivot table skills
48+
├── chart-visualization/ # Generic chart visualization via REST API
49+
├── icon-retrieval/ # Icon retrieval skill
50+
├── infographic-creator/ # Infographic creation
51+
└── narrative-text-visualization/
52+
```
53+
54+
Skills are the **single source of truth** for chart generation knowledge.
55+
56+
### 2. CLI Tool (`src/`)
57+
58+
The build script (`src/scripts/build.ts`) parses all skill markdown files and generates JSON index files (`src/index/*.index.json`). The CLI (`antv` command) provides three commands:
59+
60+
- `antv retrieve <query>` - BM25 full-text search over skills
61+
- `antv list` - List/filter available skills
62+
- `antv info <library>` - Show library metadata
63+
64+
The retrieval engine (`src/core/bm25.ts`) implements BM25 with Chinese/English tokenization, synonym expansion, and chart-type boosting.
65+
66+
Public API (`src/api.ts`) exports `retrieve()` and `info()` for programmatic use.
67+
68+
### 3. Evaluation (`eval/`)
69+
70+
Automated evaluation framework that measures skill quality across retrieval strategies:
71+
72+
- **tool-call**: LLM uses tools to load skills on demand (multi-turn agent)
73+
- **bm25**: Pre-retrieve top-K skills via BM25, inject into prompt (single-turn)
74+
- **context7**: Fetch official docs via REST API (single-turn)
75+
76+
Key files:
77+
- `eval/data/eval-g2-dataset-174.json` - 174 labeled test cases
78+
- `eval/eval-cli/index.js` - Main eval runner
79+
- `eval/eval-recall.js` - BM25 retrieval recall measurement
80+
81+
### 4. Harness (`harness/`)
82+
83+
Iterative optimization loop that automatically improves skills based on eval results:
84+
85+
```
86+
Eval --> Render Test --> Error Analysis --> Optimize Skills --> Rebuild Index --> Repeat
87+
```
88+
89+
The controller (`harness/controller.js`) orchestrates five agents:
90+
- **EvalAgent** - Run LLM eval on dataset samples
91+
- **RenderAgent** - Execute generated code in headless browser
92+
- **AnalyzeAgent** - Classify errors and attribute to specific skills
93+
- **OptimizeAgent** - LLM rewrites skill docs to fix errors
94+
- **IndexAgent** - Rebuild BM25 search index
95+
96+
Iterates until MAX_PASSES consecutive clean passes are achieved.
97+
98+
### 5. Playground (`playground/`)
99+
100+
Next.js web app for interactive chart generation. Dual-panel UI with chat interface, code editor (Monaco), and real-time chart preview.
101+
102+
Two retrieval modes:
103+
- **Skill mode** - Agent calls `load_skill` / `read_file` tools
104+
- **CLI mode** - Pre-injected BM25 results in system prompt
105+
106+
## Project Structure
107+
108+
```
109+
.
110+
├── src/ # Core library: CLI, API, BM25 retriever, build scripts
111+
│ ├── index.ts # CLI entry point (Commander.js)
112+
│ ├── api.ts # Public Node.js API
113+
│ ├── commands/ # CLI commands (retrieve, list, info)
114+
│ ├── core/ # BM25 engine, types
115+
│ ├── scripts/ # Build script (markdown -> JSON index)
116+
│ └── index/ # Generated JSON index files
117+
├── skills/ # Skill definitions (markdown + YAML frontmatter)
118+
├── eval/ # Evaluation framework and test datasets
119+
├── harness/ # Automated skill optimization loop
120+
├── playground/ # Next.js interactive playground
121+
├── __tests__/ # Vitest unit tests
122+
└── package.json # @antv/chart-visualization-skills
123+
```
124+
125+
## Key Commands
126+
127+
```bash
128+
# Build: parse skills -> generate index -> compile TypeScript
129+
pnpm build
130+
131+
# Test
132+
pnpm test
133+
134+
# Eval: run evaluation on dataset
135+
node eval/eval-cli/index.js --retrieval=bm25 --dataset=eval-g2-dataset-174
136+
137+
# Harness: iterative optimization
138+
node harness/controller.js --library=g2 --sample=10 --retrieval=bm25
139+
140+
# Playground: start dev server
141+
cd playground && pnpm dev
142+
```

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See [Agent.md](./Agent.md) for project architecture and structure.

README.md

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,105 @@ npx skills add antvis/chart-visualization-skills
5050

5151
`AntV S2 Expert` helps users develop with the S2 multi-dimensional cross-analysis table engine. It provides comprehensive guidance on `@antv/s2` core engine, `@antv/s2-react` and `@antv/s2-vue` framework bindings, `@antv/s2-react-components` advanced analysis components, and `@antv/s2-ssr` server-side rendering. Covers pivot tables, table sheets, custom cells, theming, events, interactions, sorting, totals, tooltips, frozen rows/columns, icons, pagination, and more.
5252

53+
- 📈 **antv-g2-chart**: G2 v5 chart code generator. Use when users need to generate G2 charts — bar charts, line charts, pie charts, scatter plots, area charts, heatmaps, and any statistical data visualization with the G2 library.
54+
55+
`AntV G2 Chart` generates accurate, runnable G2 v5 code following Spec Mode best practices. It covers 30+ chart types (interval, line, area, point, rect, cell, treemap, sankey, chord, wordCloud, gauge, and more), data transforms (stackY, dodgeX, binX, fold, etc.), coordinate systems (cartesian, polar, theta, radial), scales, interactions (brush, slider, legend filter), components (axis, legend, tooltip, annotation), and multi-view compositions. Built-in guard rails prevent common v4→v5 migration pitfalls such as using deprecated chain APIs, invalid palette names, or referencing `d3` in user code.
56+
57+
**Evaluation Results**
58+
59+
Harness Engineering approach has been rigorously tested against 174 chart generation test cases, demonstrating significant improvements over baseline methods:
60+
61+
| Model | Success Rate | Improvement |
62+
| :--- | :--- | :--- |
63+
| qwen3-coder-480b-a35b-instruct | **98.2%** | +18.2% |
64+
| Kimi-K2.5 | **97.7%** | +17.7% |
65+
| GLM-5.1 | **93.6%** | +13.6% |
66+
| DeepSeek-V3.2 | **87.3%** | +7.3% |
67+
| Context7 Baseline | 80% | baseline |
68+
69+
The results show that Harness Engineering enables LLMs to achieve near-production-ready accuracy (up to 98.2%), significantly outperforming the Context7 baseline approach.
70+
5371
> [!TIP]
5472
> More skills are coming soon.
5573
74+
## CLI Usage
75+
76+
We also provide a CLI tool named `antv` for easy usage in your terminal, Install globally:
77+
78+
```bash
79+
npm install -g chart-visualization-skills
80+
```
81+
82+
**Retrieve or list skills by query**:
83+
84+
```bash
85+
# Retrieve skills by query
86+
antv retrieve "bar chart" --library g2 --topk 10 --content
87+
88+
# List all available skills
89+
antv list --library g2 --category core
90+
91+
# Show skill info
92+
antv info --library g2
93+
```
94+
95+
**Usage for the command**:
96+
97+
```
98+
Usage: antv [options] [command]
99+
100+
CLI tool for AntV chart visualization skills retrieval
101+
102+
Options:
103+
-V, --version output the version number
104+
-h, --help display help for command
105+
106+
Commands:
107+
retrieve [options] <query> Search for skills matching a query
108+
list [options] List all available skills
109+
info [options] Show skill info from SKILL.md
110+
help [command] display help for command
111+
```
112+
113+
## API Usage
114+
115+
```typescript
116+
import { retrieve } from 'chart-visualization-skills';
117+
118+
const skills = retrieve('bar chart', 'g2', 5);
119+
// with content body: retrieve('bar chart', 'g2', 5, true)
120+
```
121+
122+
```typescript
123+
retrieve(query: string, library?: string, topk?: number, content?: boolean)
124+
```
125+
126+
| Parameter | Type | Default | Description |
127+
| :--- | :--- | :--- | :--- |
128+
| `query` | `string` || Search query |
129+
| `library` | `string` | `'g2'` | Library filter (`g2` or `g6`) |
130+
| `topk` | `number` | `7` | Number of results |
131+
| `content` | `boolean` | `false` | Whether to include markdown content |
132+
133+
> Notes:
134+
> - Default retrieval returns lightweight result objects without the `content` field.
135+
> - `content = true` returns markdown content body (frontmatter metadata is excluded).
136+
137+
```typescript
138+
import { info } from 'chart-visualization-skills';
139+
140+
const skillInfo = info('g2');
141+
// => { name: 'antv-g2-chart', description: '...', content: '...' }
142+
```
143+
144+
```typescript
145+
info(library?: string): SkillInfo | undefined
146+
```
147+
148+
| Parameter | Type | Default | Description |
149+
| :--- | :--- | :--- | :--- |
150+
| `library` | `string` | `'g2'` | Library to get info for (`g2` or `g6`) |
151+
56152
## License
57153

58-
MIT License - see the [LICENSE](LICENSE) file for details.
154+
MIT License - see the [LICENSE](LICENSE) file for details.

__tests__/info.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { info } from '../src/api';
3+
4+
describe('info API', () => {
5+
it('should return skill info for default library', () => {
6+
const result = info();
7+
expect(result).toBeDefined();
8+
expect(result!.name).toBe('antv-g2-chart');
9+
expect(result!.description.length).toBeGreaterThan(0);
10+
expect(result!.content.length).toBeGreaterThan(0);
11+
});
12+
13+
it('should return skill info for g2 library', () => {
14+
const result = info('g2');
15+
expect(result).toBeDefined();
16+
expect(result).toHaveProperty('name');
17+
expect(result).toHaveProperty('description');
18+
expect(result).toHaveProperty('content');
19+
});
20+
21+
it('should return undefined for library without SKILL.md', () => {
22+
const result = info('g6');
23+
// g6 may or may not have a SKILL.md
24+
expect(result === undefined || typeof result.name === 'string').toBe(true);
25+
});
26+
});

__tests__/retrieve.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { retrieve } from '../src/api';
3+
4+
describe('retrieve API', () => {
5+
it('should retrieve skills with default parameters', () => {
6+
const results = retrieve('折线图');
7+
expect(results.length).toBeGreaterThan(0);
8+
expect(results.length).toBeLessThanOrEqual(7);
9+
expect(results[0]).toHaveProperty('id');
10+
expect(results[0]).toHaveProperty('title');
11+
expect(results[0].content).toBeUndefined();
12+
});
13+
14+
it('should respect topk parameter', () => {
15+
const results = retrieve('bar chart', 'g2', 3);
16+
expect(results.length).toBeGreaterThan(0);
17+
expect(results.length).toBeLessThanOrEqual(3);
18+
});
19+
20+
it('should support g6 library parameter', () => {
21+
const results = retrieve('graph layout', 'g6');
22+
expect(Array.isArray(results)).toBe(true);
23+
});
24+
25+
it('should handle mixed Chinese/English query', () => {
26+
const results = retrieve('饼图 tooltip', 'g2', 5);
27+
expect(results.length).toBeGreaterThan(0);
28+
expect(results.length).toBeLessThanOrEqual(5);
29+
});
30+
31+
it('should load markdown content on demand', () => {
32+
const results = retrieve('折线图', 'g2', 1, true);
33+
expect(results.length).toBeGreaterThan(0);
34+
expect(typeof results[0].content).toBe('string');
35+
expect((results[0].content || '').length).toBeGreaterThan(0);
36+
// content should be body only, without frontmatter
37+
expect(results[0].content).not.toMatch(/^---\n/);
38+
});
39+
});

0 commit comments

Comments
 (0)