Skip to content

Commit 062632f

Browse files
authored
Merge branch 'release' into perf/setAttributes
2 parents c64d014 + 00d08e9 commit 062632f

599 files changed

Lines changed: 15162 additions & 20479 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.

.changeset/eight-books-fail.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@antv/g-plugin-annotation': minor
3+
'@antv/g-canvas': minor
4+
'@antv/g-lite': minor
5+
---
6+
7+
refactor: remove legacy code

.eslintignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# build
2+
dist/
3+
build/
4+
lib/
5+
esm/
6+
coverage/
7+
types/
8+
9+
# dependencies
10+
node_modules/
11+
12+
# configs
13+
.commitlintrc.cjs
14+
.eslintrc.cjs
15+
.lintstagedrc.mjs
16+
babel.config.mjs
17+
rollup.config.mjs
18+
vite.config.mjs
19+
vite.config.js
20+
jest.unit.config.js
21+
jest.visual.config.js
22+
23+
# large packages
24+
packages/g-devtool/
25+
packages/g-webgpu-compiler/
26+
packages/site/
27+
28+
# tests
29+
__tests__/
30+
scripts/
31+
32+
# docs
33+
site/
34+
35+
# others
36+
*.min.js
37+
gui.min.js

.eslintrc.cjs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,6 @@
11
// see docs: https://eslint.org/docs/user-guide/configuring
22

33
module.exports = {
4-
ignorePatterns: [
5-
'node_modules',
6-
//
7-
'.commitlintrc.cjs',
8-
'.eslintrc.cjs',
9-
'.lintstagedrc.mjs',
10-
'babel.config.mjs',
11-
'rollup.config.mjs',
12-
'vite.config.mjs',
13-
'jest.unit.config.js',
14-
'jest.visual.config.js',
15-
//
16-
'packages/g-devtool',
17-
'packages/g-webgpu-compiler',
18-
'packages/site',
19-
//
20-
'build',
21-
'coverage',
22-
'esm',
23-
'lib',
24-
'dist',
25-
'rust',
26-
'__tests__',
27-
'scripts',
28-
'types',
29-
//
30-
'gui.min.js',
31-
],
324
extends: [
335
'eslint:recommended',
346
'plugin:@typescript-eslint/recommended',
@@ -86,6 +58,7 @@ module.exports = {
8658
//
8759
'@typescript-eslint/naming-convention': 'warn',
8860
'@typescript-eslint/no-explicit-any': 'warn',
61+
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
8962
'@typescript-eslint/no-unsafe-member-access': 'warn',
9063
'@typescript-eslint/no-unsafe-assignment': 'warn',
9164
'@typescript-eslint/no-unsafe-return': 'warn',

.github/workflows/bug-report-reproduction-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
if: contains(join(github.event.issue.labels.*.name, ','), 'bug') && steps.analyze-issue.outputs.response != 'pass'
4343
uses: actions/github-script@v7
4444
env:
45-
AI_RESPONSE: steps.analyze-issue.outputs.response
45+
AI_RESPONSE: ${{ steps.analyze-issue.outputs.response }}
4646
with:
4747
script: |
4848
await github.rest.issues.createComment({
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Discussion Automated Processing
2+
3+
on:
4+
discussion:
5+
types: [created, edited]
6+
workflow_dispatch:
7+
inputs:
8+
discussion_number:
9+
description: 'Discussion number to process'
10+
required: true
11+
type: number
12+
13+
permissions:
14+
discussions: write
15+
pull-requests: read
16+
contents: read
17+
18+
jobs:
19+
discussion-response:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v3
24+
- uses: pnpm/action-setup@v4
25+
with:
26+
version: 10
27+
- name: Set up Node.js
28+
uses: actions/setup-node@v3
29+
with:
30+
node-version: 20
31+
- name: Install dependencies
32+
run: |
33+
pnpm i
34+
pnpm add openai @antv/mcp-server-antv -w
35+
- name: Process Discussion
36+
uses: actions/github-script@v7
37+
env:
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
with:
40+
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
script: |
42+
// 1. Get discussion object from context
43+
let discussion = context.payload.discussion;
44+
45+
// 2. Handle manual trigger case
46+
if (context.eventName === 'workflow_dispatch') {
47+
console.log('Manual trigger mode, fetching Discussion details via GraphQL...');
48+
const discussionNumber = parseInt(context.payload.inputs.discussion_number, 10);
49+
50+
// Use GraphQL query instead of REST API
51+
const { repository } = await github.graphql(
52+
`query($owner: String!, $repo: String!, $number: Int!) {
53+
repository(owner: $owner, name: $repo) {
54+
discussion(number: $number) {
55+
id
56+
number
57+
title
58+
body
59+
author {
60+
login
61+
}
62+
}
63+
}
64+
}`,
65+
{
66+
owner: context.repo.owner,
67+
repo: context.repo.repo,
68+
number: discussionNumber,
69+
}
70+
);
71+
72+
// Adjust the returned data structure to match webhook payload for compatibility with subsequent scripts
73+
discussion = {
74+
...repository.discussion,
75+
node_id: repository.discussion.id, // GraphQL returns `id`, which is `node_id`
76+
user: repository.discussion.author // GraphQL returns `author`, map it to `user`
77+
};
78+
79+
if (!discussion) {
80+
throw new Error(`Could not find Discussion #${discussionNumber}`);
81+
}
82+
console.log(`Successfully retrieved data for Discussion #${discussionNumber}.`);
83+
}
84+
85+
console.log('Discussion object to be processed:', discussion);
86+
87+
// 3. Call external JS script and pass the discussion object (this part remains unchanged)
88+
const script = require('./.github/workflows/scripts/discussion-automated.js');
89+
await script({
90+
github,
91+
core,
92+
context,
93+
discussion // Pass discussion object
94+
});
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Issue Automated Processing
2+
3+
on:
4+
issues:
5+
types: [opened, reopened, edited]
6+
workflow_dispatch:
7+
inputs:
8+
issue_number:
9+
description: 'Issue number to process'
10+
required: true
11+
type: number
12+
13+
permissions:
14+
issues: write
15+
pull-requests: read
16+
contents: read
17+
18+
jobs:
19+
issue-response:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v3
24+
- uses: pnpm/action-setup@v4
25+
with:
26+
version: 10
27+
- name: Set up Node.js
28+
uses: actions/setup-node@v3
29+
with:
30+
node-version: 20
31+
- name: Install dependencies
32+
run: |
33+
pnpm i
34+
pnpm add openai @antv/mcp-server-antv -w
35+
- name: Process Issue
36+
uses: actions/github-script@v7
37+
env:
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} #
39+
with:
40+
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
script: |
42+
let issue = context.payload.issue;
43+
44+
if (context.eventName === 'workflow_dispatch') {
45+
const issueNumber = context.payload.inputs.issue_number;
46+
const { data: issueData } = await github.rest.issues.get({
47+
owner: context.repo.owner,
48+
repo: context.repo.repo,
49+
issue_number: issueNumber
50+
});
51+
issue = issueData;
52+
}
53+
54+
const script = require('./.github/workflows/scripts/issue-automated.js');
55+
await script({
56+
github,
57+
core,
58+
context,
59+
issue
60+
});

.github/workflows/moderator.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: AI Moderator
2+
on:
3+
issues:
4+
types: [opened]
5+
issue_comment:
6+
types: [created]
7+
pull_request_review_comment:
8+
types: [created]
9+
10+
jobs:
11+
spam-detection:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
issues: write
15+
pull-requests: write
16+
models: read
17+
contents: read
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: github/ai-moderator@v1
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
spam-label: 'spam'
24+
ai-label: 'ai-generated'
25+
minimize-detected-comments: true
26+
# Built-in prompt configuration (all enabled by default)
27+
enable-spam-detection: true
28+
enable-link-spam-detection: true
29+
enable-ai-detection: true
30+
# custom-prompt-path: '.github/prompts/my-custom.prompt.yml' # Optional
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
const { OpenAI } = require("openai");
2+
const { QueryAntVDocumentTool, ExtractAntVTopicTool } = require('@antv/mcp-server-antv/build/tools');
3+
4+
/**
5+
* @param {Object} param
6+
* @param {import('@actions/github').GitHub} param.github
7+
* @param {import('@actions/core')} param.core
8+
* @param {Object} param.context GitHub Action context
9+
* @param {Object} param.discussion The discussion object from the payload
10+
*/
11+
module.exports = async ({ github, core, context, discussion }) => {
12+
try {
13+
core.info('Starting to process discussion...', context.repo.repo);
14+
const library = `g`;
15+
if (!discussion || !discussion.node_id) { // Check if node_id exists
16+
core.setFailed('Could not find discussion information or node_id');
17+
return;
18+
}
19+
20+
// 1. Get information from discussion object (unchanged)
21+
const discussionNumber = discussion.number;
22+
const discussionTitle = discussion.title;
23+
core.info(`Processing discussion #${discussionNumber}: ${discussionTitle}`);
24+
25+
// 2. AI processing logic (completely unchanged)
26+
const combinedQuery = prepareAIPrompt(context, discussion);
27+
const topicExtractionResult = await ExtractAntVTopicTool.run({ query: combinedQuery });
28+
const aiResponse = await getAIResponse(core, topicExtractionResult.content[0].text);
29+
const jsonMatch = aiResponse.match(/```json\s*(\{[\s\S]*?\})\s*```/);
30+
const processedTopicContent = JSON.parse(jsonMatch[1]);
31+
const queryDocumentParams = {
32+
library,
33+
query: combinedQuery,
34+
topic: processedTopicContent.topic,
35+
intent: processedTopicContent.intent,
36+
tokens: 5000,
37+
...(processedTopicContent.subTasks && { subTasks: processedTopicContent.subTasks }),
38+
};
39+
const documentationResult = await QueryAntVDocumentTool.run(queryDocumentParams);
40+
const response = await getAIResponse(core, documentationResult.content[0].text);
41+
42+
// 3. Key modification: Use GraphQL Mutation to create a comment
43+
core.info(`Preparing to post a reply to Discussion #${discussion.number}...`);
44+
const mutation = `
45+
mutation AddDiscussionComment($discussionId: ID!, $body: String!) {
46+
addDiscussionComment(input: {discussionId: $discussionId, body: $body}) {
47+
comment {
48+
id
49+
url
50+
}
51+
}
52+
}`;
53+
54+
const variables = {
55+
// Key: GraphQL needs the global node_id, not the number
56+
discussionId: discussion.node_id,
57+
body: `@${discussion.user.login} Hello! Here is an automated response to your question:\n\n${response}\n\n---\n*This is an automated response generated by AI. If you have any questions, our team will follow up as soon as possible.*`
58+
};
59+
60+
await github.graphql(mutation, variables);
61+
62+
core.info('Successfully posted the reply!');
63+
64+
} catch (error) {
65+
core.setFailed(`Failed to process discussion: ${error.message}`);
66+
core.error(error.stack);
67+
}
68+
};
69+
70+
// prepareAIPrompt 函数保持不变
71+
function prepareAIPrompt(context, post) {
72+
return `
73+
You are an intelligent assistant for the ${context.repo.repo} project. This is an automated response system for GitHub discussions.
74+
Please analyze the following discussion and provide a professional, helpful response.
75+
76+
## Current Discussion
77+
- Title: ${post.title}
78+
- Content: ${post.body}
79+
80+
Please provide a complete and helpful response, but avoid being too verbose. The response should be well-structured and use appropriate Markdown formatting.
81+
`;
82+
}
83+
84+
// getAIResponse 函数保持不变
85+
async function getAIResponse(core, userQuestion) {
86+
try {
87+
core.info('Calling GitHub AI API...');
88+
const token = process.env.GH_TOKEN;
89+
if (!token) { throw new Error('GH_TOKEN environment variable not found'); }
90+
const endpoint = "https://models.github.ai/inference";
91+
const client = new OpenAI({ baseURL: endpoint, apiKey: token });
92+
const response = await client.chat.completions.create({
93+
messages: [{ role: "user", content: userQuestion }],
94+
temperature: 0.7,
95+
top_p: 1.0,
96+
model: "openai/gpt-4.1"
97+
});
98+
core.info('Successfully received AI response');
99+
return response.choices[0].message.content;
100+
} catch (error) {
101+
core.warning(`Failed to call GitHub AI API: ${error.message}`);
102+
return `Thank you for starting this discussion!\n\nOur team will review your question as soon as possible. Thank you for your understanding and support!`;
103+
}
104+
}

0 commit comments

Comments
 (0)