Skip to content

Commit 592efa9

Browse files
authored
fix: 不支持顶层await,增强implement、solve的识别 (#21)
* fix: 修复F2的顶层await、增加S2的元信息 * fix: 去掉learn模式,增强implement和solve的识别 * fix: 修复单测
1 parent e38e180 commit 592efa9

4 files changed

Lines changed: 87 additions & 18 deletions

File tree

__tests__/tools/extract_antv_topic.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "extract_antv_topic",
3-
"description": "AntV Intelligent Assistant Preprocessing Tool - Specifically designed to handle any user queries related to AntV visualization libraries.\n This tool is the first step in processing AntV technology stack issues, responsible for intelligently identifying, parsing, and structuring user visualization requirements.\n\n**MANDATORY: Must be called for ANY new AntV-related queries, including simple questions. Always precedes query_antv_document tool.**\n\nWhen to use this tool:\n- **AntV-related queries**: Questions about g2/g6/l7/x6/f2/s2/g/ava/adc libraries.\n- **Visualization tasks**: Creating charts, graphs, maps, or other visualizations.\n- **Problem solving**: Debugging errors, performance issues, or compatibility problems.\n- **Learning & implementation**: Understanding concepts or requesting code examples.\n\nKey features:\n- **Smart Library Detection**: Scans installed AntV libraries and recommends the best fit based on query and project dependencies.\n- **Topic & Intent Extraction**: Intelligently extracts technical topics and determines user intent (learn/implement/solve).\n- **Task Complexity Handling**: Detects complex tasks and decomposes them into manageable subtasks.\n- **Seamless Integration**: Prepares structured data for the query_antv_document tool to provide precise solutions.",
3+
"description": "AntV Intelligent Assistant Preprocessing Tool - Specifically designed to handle any user queries related to AntV visualization libraries.\n This tool is the first step in processing AntV technology stack issues, responsible for intelligently identifying, parsing, and structuring user visualization requirements.\n\n**MANDATORY: Must be called for ANY new AntV-related queries, including simple questions. Always precedes query_antv_document tool.**\n\nWhen to use this tool:\n- **AntV-related queries**: Questions about g2/g6/l7/x6/f2/s2/g/ava/adc libraries.\n- **Visualization tasks**: Creating charts, graphs, maps, or other visualizations.\n- **Problem solving**: Debugging errors, performance issues, or compatibility problems.\n- **Learning & implementation**: Understanding concepts or requesting code examples.\n\nKey features:\n- **Smart Library Detection**: Scans installed AntV libraries and recommends the best fit based on query and project dependencies.\n- **Topic & Intent Extraction**: Intelligently extracts technical topics and determines user intent (implement/solve).\n- **Task Complexity Handling**: Detects complex tasks and decomposes them into manageable subtasks.\n- **Seamless Integration**: Prepares structured data for the query_antv_document tool to provide precise solutions.",
44
"inputSchema": {
55
"$schema": "http://json-schema.org/draft-07/schema#",
66
"type": "object",

src/constant.ts

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,84 @@ export const ANTV_LIBRARY_META = {
7070
`,
7171
codeStyle: `
7272
<convention>
73-
- Use F2's components directly in JSX. If TypeScript errors occur, add @ts-ignore above the component
74-
- Code examples are for Node environment. For React framework, import ReactCanvas from '@antv/f2-react' and use <ReactCanvas/> component instead of <Canvas/> component
73+
- Use F2's components directly in JSX. If TypeScript errors occur, add @ts-ignore above the component.
74+
- Code examples are for Node environment. For React framework, import ReactCanvas from '@antv/f2-react' and use <ReactCanvas/> component instead of <Canvas/> component.
7575
- In F2's canvas coordinate system, Y coordinates increase from top to bottom, and X coordinates increase from left to right by default. Therefore, all values for offsetY, offsetX, x, y and similar properties are relative to the top-left corner of the canvas.
76+
- **CRITICAL: The top-level scope does not support \`await\`. You MUST handle asynchronous operations like \`canvas.render()\` according to the following logic:**
77+
- **If \`canvas.render()\` is the final action and nothing follows it, you MUST remove the \`await\` keyword.**
78+
- **WRONG:** \`await canvas.render();\`
79+
- **CORRECT:** \`canvas.render();\`
80+
- **If there is any code that must run *after* \`canvas.render()\` completes, you MUST wrap the \`await\` and all subsequent code in an \`async\` IIFE (Immediately Invoked Function Expression).**
81+
- **WRONG:**
82+
\`\`\`javascript
83+
await canvas.render();
84+
console.log('Render complete.');
85+
\`\`\`
86+
- **CORRECT:**
87+
\`\`\`javascript
88+
(async () => {
89+
await canvas.render();
90+
console.log('Render complete.');
91+
})();
92+
\`\`\`
7693
</convention>
7794
`,
7895
},
7996
s2: {
8097
id: 's2' as AntVLibrary,
8198
name: 'S2',
8299
description: 'Table analysis, spreadsheet-like interactions, data grids',
83-
keywords: '',
84-
codeStyle: '',
100+
keywords: `
101+
<components>
102+
- 基础透视表 (Basic Pivot Table)
103+
- 自定义单元格 (Custom Cell)
104+
- 表组件 (Sheet Component)
105+
- 字段标记 (Field Marking)
106+
- 多行文本 (Multi-line Text)
107+
- 分页 (Pagination)
108+
- 排序 (Sorting)
109+
- 透视表模式 (Pivot Mode)
110+
- 明细表模式 (Table Mode)
111+
- 下钻功能 (Drill Down)
112+
- 导出功能 (Export)
113+
- 分页组件 (Pagination Component)
114+
- 表格组件 (Sheet Component)
115+
- 合并单元格 (Merged Cell)
116+
- 迷你图表 (Mini Chart)
117+
- 冻结 (Frozen)
118+
- 头部操作图标 (Header Action Icon)
119+
- 复制导出 (Copy Export)
120+
- 单元格对齐 (Cell Alignment)
121+
- 获取单元格数据 (Get Cell Data)
122+
- 获取实例 (Get Instance)
123+
- 编辑表 (Editable Table)
124+
- 趋势分析表 (Strategy Table)
125+
- 趋势分析 (Strategy Analysis)
126+
- 透视表 (Pivot Table)
127+
- 明细表 (Table)
128+
- 树状结构 (Tree Structure)
129+
- 展开/折叠 (Expand/Collapse)
130+
- 刷选 (Brush Selection)
131+
- 单选 (Single Selection)
132+
- 多选 (Multiple Selection)
133+
- 行选/列选 (Row/Column Selection)
134+
- 区间选择 (Range Selection)
135+
- 悬停高亮 (Hover Highlight)
136+
- 复制功能 (Copy Function)
137+
- 隐藏列头 (Hide Column Header)
138+
- 链接跳转 (Link Jump)
139+
- 事件处理 (Event Handling)
140+
- 单元格渲染 (Cell Rendering)
141+
- 透视图表 (Pivot Chart)
142+
</components>
143+
`,
144+
codeStyle: `
145+
<convention>
146+
- **Default to using the core \`@antv/s2\` package** for simple pivot tables or tables without complex interactions. If the user's request can be fulfilled with a basic \`PivotSheet\` or \`TableSheet\` instance, do not use a framework-specific wrapper.
147+
- **You MUST use the \`@antv/s2-react\` package and its \`SheetComponent\`** if the user's request involves advanced features such as building a trend analysis table (e.g., with in-cell mini charts), an editable table, or requires pre-built analysis components like \`Switch\` or \`Export\`.
148+
- **The \`@antv/s2-vue\` library is unmaintained and MUST NOT be used.** For Vue.js implementations, you MUST generate code that manually wraps the core \`@antv/s2\` package within a standard Vue component.
149+
</convention>
150+
`,
85151
},
86152
g: {
87153
id: 'g' as AntVLibrary,

src/tools/extract_antv_topic.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,20 @@ ${libraryMappings}
104104
105105
**Determine User Intent:**
106106
Based on the tone and content of the query, select the most matching intent:
107-
- **learn**: Learning and understanding (e.g., what is, how to understand, introduce)
108-
- **implement**: Implementing functionality (e.g., how to create, how to implement, code examples)
109-
- **solve**: Solving problems (e.g., errors, not working, fixing issues)
107+
- **implement**: Creating new functionality, implementing features, code examples, configuration setup
108+
- **solve**: Fixing problems, troubleshooting errors, resolving styling issues, debugging functionality(If uncertain, default to solve.)
109+
110+
**Critical Identification Rules:**
111+
- **solve** intent: Query asks "how to configure/set/modify/change" existing features, styling properties, or visual attributes (colors, borders, fonts, sizes, positions)
112+
- Examples: "怎么配置堆叠面积图的描边为不同的颜色", "坐标轴文本样式怎么修改", "怎么设置折线图的颜色"
113+
- Key patterns: "怎么/如何/为什么"
114+
- **implement** intent: Query asks "create/build/implement" new charts, components, or functionality
115+
- Examples: "创建一个柱状图", "写一个", "实现"
116+
- Key patterns: "创建/实现/添加/构建/改成/修改"
117+
118+
**Additional Classification Examples:**
119+
- **solve**: "tooltip不显示怎么办", "图表渲染不出来", "颜色显示不正确", "数据格式错误", "点击事件没反应"
120+
- **implement**: "帮我写一个饼图", "实现拖拽功能", "添加一个图例", "创建一个仪表盘"
110121
111122
**Assess Task Complexity:**
112123
Determine if the query is complex based on:
@@ -128,7 +139,7 @@ If complex, decompose into 2-4 subtasks, each subtask should:
128139
{
129140
"library": "detected_or_specified_library",
130141
"topic": "topic1, topic2, topic3",
131-
"intent": "learn|implement|solve",
142+
"intent": "implement|solve",
132143
"isComplexTask": false
133144
}
134145
\`\`\`
@@ -175,7 +186,7 @@ When to use this tool:
175186
176187
Key features:
177188
- **Smart Library Detection**: Scans installed AntV libraries and recommends the best fit based on query and project dependencies.
178-
- **Topic & Intent Extraction**: Intelligently extracts technical topics and determines user intent (learn/implement/solve).
189+
- **Topic & Intent Extraction**: Intelligently extracts technical topics and determines user intent (implement/solve).
179190
- **Task Complexity Handling**: Detects complex tasks and decomposes them into manageable subtasks.
180191
- **Seamless Integration**: Prepares structured data for the query_antv_document tool to provide precise solutions.`,
181192
inputSchema: ExtractAntVTopicInputSchema,

src/tools/query_antv_document.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,6 @@ function generateImplementationGuidance(
171171
library: AntVLibrary,
172172
): string {
173173
switch (intent) {
174-
case 'learn':
175-
return (
176-
`## 💡 Learning Tips\n\n` +
177-
`- Review the concepts and examples above\n` +
178-
`- Try running the code examples in your development environment\n` +
179-
`- Start with basic implementations before adding complexity\n\n`
180-
);
181-
182174
case 'implement':
183175
const config = getLibraryConfig(library);
184176

0 commit comments

Comments
 (0)