feat(plugin): custom SVG icons, market stats, submit link, and native locale scaffold (#170)

* feat(plugin): custom SVG icons, market stats, submit link, and native locale scaffold

* chore(ci): allow spaces in PR model names and rename agent declaration to tool

* fix(plugin): validate icon.svg size and markup during static scan
This commit is contained in:
千川白浪 authored and GitHub committed 2026-12-04 22:34:12 +08:00
1 parent 4053ffb60c
commit 781f129fc1
33 files changed
+543 -72

No files matched your search

+4 -2
View File
@@ -4,9 +4,11 @@
- 实现归属仓库与关联的跨仓提交或运行时版本(纯本仓改动可填无)
- 旧版或缺失运行时下的兼容与降级表现(不涉及运行时可填不适用)
## 模型与 Agent 申报
## 模型与编程工具申报
<!-- 请逐行填写参与代码编写的实际模型和 Agent。模型格式为 model: 提供方/模型名称,Agent 格式为 agent: 名称。 -->
<!-- 请逐行填写参与代码编写的实际模型与编程工具,不要放在代码块或 HTML 注释内。
模型格式:model: 提供方/模型名称(例如 model: deepseek/deepseek-R1 或 model: google/Gemini 4 Neon)
编程工具格式:tool: 名称(例如 tool: Cursor、tool: Claude Code、tool: WorkBuddy、tool: 豆包;兼容旧的 agent: 写法) -->
## 验证记录
+12 -6
View File
@@ -1,8 +1,11 @@
import { readFile } from "node:fs/promises";
import { pathToFileURL } from "node:url";
const MODEL_LINE_RE = /^ {0,3}model:[ \t]+[\p{L}\p{N}][\p{L}\p{N}_.+() -]*\/[\p{L}\p{N}][\p{L}\p{N}_.+() -]*$/u;
const TOOL_LINE_RE = /^ {0,3}(?:tool|agent):[ \t]+[\p{L}\p{N}][\p{L}\p{N}_.+() /-]*$/u;
export function missingDeclarations(body) {
const missing = new Set(["model", "agent"]);
const missing = new Set(["model", "tool"]);
if (typeof body !== "string") return [...missing];
let fence = null;
for (const line of body.replace(/<!--[^]*?(?:-->|$)/g, "").split(/\r?\n/)) {
@@ -11,10 +14,13 @@ export function missingDeclarations(body) {
if (delimiter && delimiter[1][0] === fence[0] && delimiter[1].length >= fence.length && !delimiter[2].trim()) fence = null;
} else if (delimiter) {
fence = delimiter[1];
} else if (/^ {0,3}model:[ \t]+[\p{L}\p{N}_.-]+\/[\p{L}\p{N}_.-]+[ \t]*$/u.test(line)) {
missing.delete("model");
} else if (/^ {0,3}agent:[ \t]+[\p{L}\p{N}][\p{L}\p{N}_.+() /-]*$/u.test(line.trimEnd())) {
missing.delete("agent");
} else {
const trimmed = line.trimEnd();
if (MODEL_LINE_RE.test(trimmed)) {
missing.delete("model");
} else if (TOOL_LINE_RE.test(trimmed)) {
missing.delete("tool");
}
}
if (missing.size === 0) break;
}
@@ -52,7 +58,7 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
token: process.env.GITHUB_TOKEN,
});
if (result.status === "closed") {
console.error(`::error::PR closed because its description is missing ${result.missing.join(" and ")}. Declare the actual model and agent used (format examples: model: deepseek/deepseek-R1 and agent: WorkBuddy).`);
console.error(`::error::PR closed because its description is missing ${result.missing.join(" and ")}. Declare the actual model and coding tool used (format examples: model: deepseek/deepseek-R1 and tool: Cursor).`);
process.exitCode = 1;
}
}
+18 -12
View File
@@ -6,23 +6,29 @@ const declaration = "model: deepseek/deepseek-R1";
const opened = { action: "opened", pull_request: { number: 42, base: { ref: "main" } } };
const options = { apiUrl: "https://api.example.invalid", repository: "owner/repo", token: "test" };
test("requires visible model and agent declarations", () => {
for (const agent of ["WorkBuddy", "豆包", "OpenAI Codex"]) {
assert.deepEqual(missingDeclarations(`${declaration}\r\nagent: ${agent}`), []);
test("requires visible model and coding tool declarations", () => {
for (const model of ["deepseek/deepseek-R1", "google/Gemini 4 Neon", "anthropic/Claude 4.5 Sonnet"]) {
for (const tool of ["tool: Cursor", "tool: WorkBuddy", "tool: 豆包", "tool: OpenAI Codex", "agent: WorkBuddy"]) {
assert.deepEqual(missingDeclarations(`model: ${model}\r\n${tool}`), []);
}
}
assert.deepEqual(missingDeclarations(declaration), ["agent"]);
assert.deepEqual(missingDeclarations("agent: 豆包"), ["model"]);
assert.deepEqual(missingDeclarations(`${declaration}\nagent: `), ["agent"]);
assert.deepEqual(missingDeclarations(`${declaration}\n<!-- agent: WorkBuddy -->`), ["agent"]);
assert.deepEqual(missingDeclarations("```\n" + declaration + "\nagent: 豆包\n```"), ["model", "agent"]);
assert.deepEqual(missingDeclarations(null), ["model", "agent"]);
assert.deepEqual(missingDeclarations(declaration), ["tool"]);
assert.deepEqual(missingDeclarations("tool: 豆包"), ["model"]);
assert.deepEqual(missingDeclarations("model: google/\ntool: Cursor"), ["model"]);
assert.deepEqual(missingDeclarations("model: /gemini\ntool: Cursor"), ["model"]);
assert.deepEqual(missingDeclarations("model: gemini\ntool: Cursor"), ["model"]);
assert.deepEqual(missingDeclarations(`${declaration}\ntool: `), ["tool"]);
assert.deepEqual(missingDeclarations(`${declaration}\n<!-- tool: WorkBuddy -->`), ["tool"]);
assert.deepEqual(missingDeclarations("```\n" + declaration + "\ntool: 豆包\n```"), ["model", "tool"]);
assert.deepEqual(missingDeclarations(null), ["model", "tool"]);
});
test("closes a new PR when either declaration is missing from its current description", async () => {
const cases = [
["", ["model", "agent"]],
[declaration, ["agent"]],
["agent: 豆包", ["model"]],
["", ["model", "tool"]],
[declaration, ["tool"]],
["tool: 豆包", ["model"]],
[`${declaration}\ntool: WorkBuddy`, []],
[`${declaration}\nagent: WorkBuddy`, []],
];
for (const [body, missing] of cases) {
+2 -2
View File
@@ -1,4 +1,4 @@
name: PR Model and Agent Declaration
name: PR Model and Coding Tool Declaration
on:
pull_request_target:
@@ -21,7 +21,7 @@ jobs:
persist-credentials: false
sparse-checkout-cone-mode: false
sparse-checkout: /.github/scripts/pr-model.mjs
- name: Check the model and agent declarations
- name: Check the model and coding tool declarations
env:
GITHUB_TOKEN: ${{ github.token }}
run: node .github/scripts/pr-model.mjs