Skip to content

Commit 5f61397

Browse files
committed
♻️ 重命名 ==CATTool== 为 ==SkillScript==,清除所有 CATTool 残留
- ==CATTool== / ==/CATTool== 头格式改为 ==SkillScript== / ==/SkillScript== - UUID 前缀从 cattool- 改为 skillscript- - .cattool.js 文件扩展名改为 .skill.js - ScriptInfo.cattool 字段改为 skillScript - 变量/函数名中所有 cattool/CATTool 引用统一为 skillScript
1 parent ddd0dfb commit 5f61397

19 files changed

Lines changed: 139 additions & 121 deletions

e2e/agent-fixtures.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ export const test = base.extend<AgentFixtures>({
8787
const context = await chromium.launchPersistentContext("", {
8888
headless: false,
8989
args: ["--headless=new", `--disable-extensions-except=${pathToExtension}`, `--load-extension=${pathToExtension}`],
90+
...(() => {
91+
const proxy =
92+
process.env.E2E_PROXY ||
93+
process.env.https_proxy ||
94+
process.env.http_proxy ||
95+
process.env.HTTPS_PROXY ||
96+
process.env.HTTP_PROXY;
97+
return proxy ? { proxy: { server: proxy } } : {};
98+
})(),
9099
});
91100

92101
await use(context);

e2e/agent-skill.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ You are a greeting assistant. Use execute_skill_script to run the say_hello scri
1111
`;
1212

1313
const SAY_HELLO_CODE = `
14-
// ==CATTool==
14+
// ==SkillScript==
1515
// @name say_hello
1616
// @description Say hello to someone
1717
// @param name string [required] Person's name
18-
// ==/CATTool==
18+
// ==/SkillScript==
1919
2020
return "Hello, " + args.name + "! Welcome!";
2121
`.trim();

e2e/fixtures.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ export const test = base.extend<{
1111
const context = await chromium.launchPersistentContext("", {
1212
headless: false,
1313
args: ["--headless=new", `--disable-extensions-except=${pathToExtension}`, `--load-extension=${pathToExtension}`],
14+
...(() => {
15+
const proxy =
16+
process.env.E2E_PROXY ||
17+
process.env.https_proxy ||
18+
process.env.http_proxy ||
19+
process.env.HTTPS_PROXY ||
20+
process.env.HTTP_PROXY;
21+
return proxy ? { proxy: { server: proxy } } : {};
22+
})(),
1423
});
1524
await use(context);
1625
await context.close();

example/agent/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Agent 示例
22

3-
Agent 相关的 Skills、CATTools 和使用示例已迁移到独立仓库:
3+
Agent 相关的 Skills、Skill Scripts 和使用示例已迁移到独立仓库:
44

55
- **GitHub**: https://github.com/scriptscat/skills

src/app/service/agent/skill_script_executor.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ function createRecord(
1818
description: "测试工具",
1919
params,
2020
grants: [],
21-
code: `// ==CATTool==
21+
code: `// ==SkillScript==
2222
// @name test_tool
23-
// ==/CATTool==
23+
// ==/SkillScript==
2424
return args.value;`,
2525
installtime: Date.now(),
2626
updatetime: Date.now(),
@@ -132,9 +132,9 @@ describe("SkillScriptExecutor", () => {
132132
description: "查天气",
133133
params: [],
134134
grants: ["GM.xmlHttpRequest"],
135-
code: `// ==CATTool==
135+
code: `// ==SkillScript==
136136
// @name weather
137-
// ==/CATTool==
137+
// ==/SkillScript==
138138
const result = await GM.xmlHttpRequest({url: "http://example.com"});
139139
return result;`,
140140
installtime: 1,
@@ -147,7 +147,7 @@ return result;`,
147147
const params = getCallParams(sender);
148148
expect(params.grants).toEqual(["GM.xmlHttpRequest"]);
149149
expect(params.name).toBe("weather");
150-
expect(params.code).not.toContain("==CATTool==");
150+
expect(params.code).not.toContain("==SkillScript==");
151151
});
152152

153153
it("应处理多个混合类型参数", async () => {
@@ -164,15 +164,15 @@ return result;`,
164164
expect(getCallParams(sender).args).toEqual({ city: "上海", days: 7, detailed: true });
165165
});
166166

167-
it("应生成 cattool- 前缀的 UUID", async () => {
167+
it("应生成 skillscript- 前缀的 UUID", async () => {
168168
const sender = createMockSender();
169169
const record = createRecord();
170170
const executor = new SkillScriptExecutor(record, sender);
171171

172172
await executor.execute({});
173173

174174
const params = getCallParams(sender);
175-
expect(params.uuid).toMatch(/^cattool-/);
175+
expect(params.uuid).toMatch(/^skillscript-/);
176176
expect(params.uuid.length).toBeGreaterThan(SKILL_SCRIPT_UUID_PREFIX.length);
177177
});
178178

@@ -235,7 +235,7 @@ return result;`,
235235

236236
describe("getSkillScriptNameByUuid", () => {
237237
it("未注册的 UUID 应返回空字符串", () => {
238-
expect(getSkillScriptNameByUuid("cattool-unknown-uuid")).toBe("");
238+
expect(getSkillScriptNameByUuid("skillscript-unknown-uuid")).toBe("");
239239
});
240240

241241
it("空字符串应返回空字符串", () => {
@@ -245,7 +245,7 @@ describe("getSkillScriptNameByUuid", () => {
245245

246246
describe("getSkillScriptGrantsByUuid", () => {
247247
it("未注册的 UUID 应返回空数组", () => {
248-
expect(getSkillScriptGrantsByUuid("cattool-unknown-uuid")).toEqual([]);
248+
expect(getSkillScriptGrantsByUuid("skillscript-unknown-uuid")).toEqual([]);
249249
});
250250

251251
it("执行期间应能通过 UUID 获取 grants", async () => {
@@ -287,8 +287,8 @@ describe("getSkillScriptGrantsByUuid", () => {
287287
});
288288

289289
describe("SKILL_SCRIPT_UUID_PREFIX", () => {
290-
it("应为 'cattool-'", () => {
291-
expect(SKILL_SCRIPT_UUID_PREFIX).toBe("cattool-");
290+
it("应为 'skillscript-'", () => {
291+
expect(SKILL_SCRIPT_UUID_PREFIX).toBe("skillscript-");
292292
});
293293
});
294294

@@ -525,7 +525,7 @@ describe("SkillScriptExecutor 超时处理", () => {
525525
await vi.advanceTimersByTimeAsync(30_000);
526526
await execPromise;
527527

528-
expect(capturedUuid).toMatch(/^cattool-/);
528+
expect(capturedUuid).toMatch(/^skillscript-/);
529529
expect(getSkillScriptNameByUuid(capturedUuid)).toBe("");
530530
});
531531

src/app/service/agent/skill_script_executor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { executeSkillScript } from "@App/app/service/offscreen/client";
66
import { uuidv4 } from "@App/pkg/utils/uuid";
77

88
// Skill Script UUID 前缀,用于在 GM API 请求中识别 Skill Script
9-
export const SKILL_SCRIPT_UUID_PREFIX = "cattool-";
9+
export const SKILL_SCRIPT_UUID_PREFIX = "skillscript-";
1010

1111
// Skill Script 默认超时(ms)
1212
const SKILL_SCRIPT_DEFAULT_TIMEOUT_MS = 30_000;

src/app/service/service_worker/agent.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ function createTestService() {
5959
return { service, mockRepo, mockSkillRepo, mockModelRepo };
6060
}
6161

62-
const VALID_CATTOOL_CODE = `// ==CATTool==
62+
const VALID_SKILLSCRIPT_CODE = `// ==SkillScript==
6363
// @name test-tool
6464
// @description A test tool
6565
// @param {string} input - The input
66-
// ==/CATTool==
66+
// ==/SkillScript==
6767
module.exports = async function(params) { return params.input; }`;
6868

6969
// ---- Skill 系统测试 ----
@@ -431,7 +431,7 @@ You are a full-featured skill.`;
431431
const scripts = [
432432
{
433433
name: "my-tool",
434-
code: VALID_CATTOOL_CODE,
434+
code: VALID_SKILLSCRIPT_CODE,
435435
},
436436
];
437437

@@ -495,7 +495,7 @@ description: Has invalid script
495495
---
496496
Some prompt.`;
497497

498-
await expect(service.installSkill(skillMd, [{ name: "bad-tool", code: "not a cattool" }])).rejects.toThrow(
498+
await expect(service.installSkill(skillMd, [{ name: "bad-tool", code: "not a skillscript" }])).rejects.toThrow(
499499
"Invalid SkillScript"
500500
);
501501
});
@@ -537,7 +537,7 @@ name: taobao-helper
537537
description: 淘宝购物助手
538538
---
539539
你是一个淘宝购物助手。`,
540-
scripts: [{ name: "taobao_extract.js", code: VALID_CATTOOL_CODE }],
540+
scripts: [{ name: "taobao_extract.js", code: VALID_SKILLSCRIPT_CODE }],
541541
references: [
542542
{ name: "api_docs.md", content: "# API Docs\n淘宝接口文档" },
543543
{ name: "guide.txt", content: "使用指南" },
@@ -549,7 +549,7 @@ description: 淘宝购物助手
549549
expect(record.name).toBe("taobao-helper");
550550
expect(record.description).toBe("淘宝购物助手");
551551
expect(record.prompt).toBe("你是一个淘宝购物助手。");
552-
expect(record.toolNames).toEqual(["test-tool"]); // 脚本名称从 ==CATTool== metadata 中解析
552+
expect(record.toolNames).toEqual(["test-tool"]); // 脚本名称从 ==SkillScript== metadata 中解析
553553
expect(record.referenceNames).toEqual(["api_docs.md", "guide.txt"]);
554554

555555
// 验证 saveSkill 调用参数
@@ -569,17 +569,17 @@ description: 淘宝购物助手
569569
it("ZIP 结果中多个脚本应全部安装", async () => {
570570
const { service, mockSkillRepo } = createTestService();
571571

572-
const anotherToolCode = `// ==CATTool==
572+
const anotherToolCode = `// ==SkillScript==
573573
// @name another-tool
574574
// @description Another tool
575575
// @param {string} query - Search query
576-
// ==/CATTool==
576+
// ==/SkillScript==
577577
return query;`;
578578

579579
const record = await service.installSkill(
580580
`---\nname: multi-tool\ndescription: Multi tools skill\n---\nMulti tool prompt.`,
581581
[
582-
{ name: "tool1.js", code: VALID_CATTOOL_CODE },
582+
{ name: "tool1.js", code: VALID_SKILLSCRIPT_CODE },
583583
{ name: "tool2.js", code: anotherToolCode },
584584
],
585585
[]
@@ -964,7 +964,7 @@ describe("classifyErrorCode", () => {
964964
});
965965

966966
it("消息含 timed out 应分类为 tool_timeout", () => {
967-
expect(classifyErrorCode(new Error('CATTool "foo" timed out after 30s'))).toBe("tool_timeout");
967+
expect(classifyErrorCode(new Error('SkillScript "foo" timed out after 30s'))).toBe("tool_timeout");
968968
});
969969

970970
it("errorCode 属性为 tool_timeout 应分类为 tool_timeout", () => {

src/app/service/service_worker/agent.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export class AgentService {
190190
if (!this.resourceService) return undefined;
191191
const rs = this.resourceService;
192192
return async (url: string) => {
193-
const res = await rs.getResource("cattool-require", url, "require", false);
193+
const res = await rs.getResource("skillscript-require", url, "require", false);
194194
return res?.content as string | undefined;
195195
};
196196
}
@@ -230,11 +230,11 @@ export class AgentService {
230230
for (const script of scripts) {
231231
const metadata = parseSkillScriptMetadata(script.code);
232232
if (!metadata) {
233-
throw new Error(`Invalid SkillScript "${script.name}": missing ==CATTool== header`);
233+
throw new Error(`Invalid SkillScript "${script.name}": missing ==SkillScript== header`);
234234
}
235235
// 下载并缓存 @require 资源
236236
if (metadata.requires.length > 0 && this.resourceService) {
237-
const dummyUuid = "cattool-require";
237+
const dummyUuid = "skillscript-require";
238238
await Promise.all(
239239
metadata.requires.map((url) => this.resourceService!.getResource(dummyUuid, url, "require", true))
240240
);

src/app/service/service_worker/script.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ export class ScriptService {
9999
}
100100
// 处理url, 实现安装脚本
101101
let targetUrl: string;
102-
// 判断是否为 file:///*/*.user.js 或 file:///*/*.cattool.js
103-
if (req.url.startsWith("file://") && (req.url.endsWith(".user.js") || req.url.endsWith(".cattool.js"))) {
102+
// 判断是否为 file:///*/*.user.js 或 file:///*/*.skill.js
103+
if (req.url.startsWith("file://") && (req.url.endsWith(".user.js") || req.url.endsWith(".skill.js"))) {
104104
targetUrl = req.url;
105105
} else {
106106
const reqUrl = new URL(req.url);
@@ -167,7 +167,7 @@ export class ScriptService {
167167
{ schemes: ["http", "https"], hostEquals: "docs.scriptcat.org", pathPrefix: "/en/docs/script_installation/" },
168168
{ schemes: ["http", "https"], hostEquals: "www.tampermonkey.net", pathPrefix: "/script_installation.php" },
169169
{ schemes: ["file"], pathSuffix: ".user.js" },
170-
{ schemes: ["file"], pathSuffix: ".cattool.js" },
170+
{ schemes: ["file"], pathSuffix: ".skill.js" },
171171
],
172172
}
173173
);
@@ -252,9 +252,9 @@ export class ScriptService {
252252
isUrlFilterCaseSensitive: false,
253253
requestDomains: ["bitbucket.org"], // Chrome 101+
254254
},
255-
// CATTool (.cattool.js) 安装检测
255+
// SkillScript (.skill.js) 安装检测
256256
{
257-
regexFilter: "^([^?#]+?\\.cattool\\.js)",
257+
regexFilter: "^([^?#]+?\\.skill\\.js)",
258258
resourceTypes: [chrome.declarativeNetRequest.ResourceType.MAIN_FRAME],
259259
requestMethods: ["get" as chrome.declarativeNetRequest.RequestMethod],
260260
isUrlFilterCaseSensitive: false,
@@ -913,11 +913,11 @@ export class ScriptService {
913913
}
914914
}
915915
// 检测是否为 SkillScript
916-
const cattoolMeta = parseSkillScriptMetadata(code);
917-
if (cattoolMeta) {
916+
const skillScriptMeta = parseSkillScriptMetadata(code);
917+
if (skillScriptMeta) {
918918
const si = [
919919
false,
920-
{ uuid, code, url, source: upsertBy, metadata: {}, userSubscribe: false, cattool: true } as ScriptInfo,
920+
{ uuid, code, url, source: upsertBy, metadata: {}, userSubscribe: false, skillScript: true } as ScriptInfo,
921921
options,
922922
];
923923
await cacheInstance.set(`${CACHE_KEY_SCRIPT_INFO}${uuid}`, si);

src/pages/components/layout/MainLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ const MainLayout: React.FC<{
253253
if (!file.name || !file.size) {
254254
throw new Error("No Read Access Right for File");
255255
}
256-
// 先检查内容,后弹出安装页面(支持 UserScript 和 CATTool
256+
// 先检查内容,后弹出安装页面(支持 UserScript 和 SkillScript
257257
const checkOk = await Promise.allSettled([
258258
file.text().then((code) => {
259259
// 先尝试 UserScript 解析

0 commit comments

Comments
 (0)