Skip to content

Commit 1c8c4a4

Browse files
Sisyphean-aclaude
andcommitted
refactor(core): 统一功能模块架构并增强类型安全
- 新增 FeatureModule 接口统一所有功能模块的激活/停用方法 - 新增 FeatureLoader 实现安全的模块加载和错误处理机制 - 新增 FusiToolsConfig 类型定义,提供类型安全的配置访问 - 新增 feature-schema.json 用于验证 feature.json 配置 - 重构 extension.ts 使用统一的模块加载器 - 移除 helloWorld 示例命令 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0e77647 commit 1c8c4a4

11 files changed

Lines changed: 914 additions & 108 deletions

File tree

package.json

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,45 @@
254254
}
255255
}
256256
],
257+
"views": {
258+
"scm": [
259+
{
260+
"id": "fusi-tools.aiCommitView",
261+
"name": "AI 提交助手",
262+
"icon": "$(sparkle)"
263+
},
264+
{
265+
"id": "fusi-tools.gitIgnoreManager.view",
266+
"name": "忽略文件(Git)",
267+
"icon": "$(circle-slash)",
268+
"when": "config.fusi-tools.gitIgnoreManager.enabled"
269+
},
270+
{
271+
"id": "fusi-tools.gitWorktree.view",
272+
"name": "工作树 (Worktrees)",
273+
"icon": "$(git-branch)",
274+
"when": "config.fusi-tools.gitWorktree.enabled",
275+
"visibility": "collapsed"
276+
}
277+
],
278+
"projectFavorites-container": [
279+
{
280+
"id": "fusi-tools.projectFavorites.view",
281+
"name": "常用文件",
282+
"icon": "$(star-full)"
283+
}
284+
],
285+
"scratchpad-container": [
286+
{
287+
"type": "webview",
288+
"id": "scratchpad.view",
289+
"name": "随手记",
290+
"icon": "$(edit)",
291+
"when": "config.fusi-tools.scratchpad.enabled"
292+
}
293+
]
294+
},
257295
"commands": [
258-
{
259-
"command": "fusi-tools.helloWorld",
260-
"title": "Demo: 你好世界"
261-
},
262296
{
263297
"command": "fusi-tools.previewSmartDiff",
264298
"title": "查看预处理",
@@ -429,44 +463,6 @@
429463
"category": "Fusi Tools"
430464
}
431465
],
432-
"views": {
433-
"scm": [
434-
{
435-
"id": "fusi-tools.aiCommitView",
436-
"name": "AI 提交助手",
437-
"icon": "$(sparkle)"
438-
},
439-
{
440-
"id": "fusi-tools.gitIgnoreManager.view",
441-
"name": "忽略文件(Git)",
442-
"icon": "$(circle-slash)",
443-
"when": "config.fusi-tools.gitIgnoreManager.enabled"
444-
},
445-
{
446-
"id": "fusi-tools.gitWorktree.view",
447-
"name": "工作树 (Worktrees)",
448-
"icon": "$(git-branch)",
449-
"when": "config.fusi-tools.gitWorktree.enabled",
450-
"visibility": "collapsed"
451-
}
452-
],
453-
"projectFavorites-container": [
454-
{
455-
"id": "fusi-tools.projectFavorites.view",
456-
"name": "常用文件",
457-
"icon": "$(star-full)"
458-
}
459-
],
460-
"scratchpad-container": [
461-
{
462-
"type": "webview",
463-
"id": "scratchpad.view",
464-
"name": "随手记",
465-
"icon": "$(edit)",
466-
"when": "config.fusi-tools.scratchpad.enabled"
467-
}
468-
]
469-
},
470466
"menus": {
471467
"view/item/context": [
472468
{

scripts/feature-schema.json

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://fusi-tools/feature.schema.json",
4+
"title": "Fusi Tools Feature Configuration",
5+
"description": "Schema for feature.json files in Fusi Tools",
6+
"type": "object",
7+
"properties": {
8+
"contributes": {
9+
"type": "object",
10+
"description": "VS Code contribution points",
11+
"properties": {
12+
"commands": {
13+
"type": "array",
14+
"description": "Commands contributed by this feature",
15+
"items": {
16+
"type": "object",
17+
"required": ["command", "title"],
18+
"properties": {
19+
"command": {
20+
"type": "string",
21+
"pattern": "^fusi-tools\\.",
22+
"description": "Command identifier (must start with 'fusi-tools.')"
23+
},
24+
"title": {
25+
"type": "string",
26+
"description": "Command title shown in UI"
27+
},
28+
"icon": {
29+
"type": "string",
30+
"description": "Icon for the command"
31+
},
32+
"category": {
33+
"type": "string",
34+
"description": "Command category"
35+
}
36+
}
37+
}
38+
},
39+
"configuration": {
40+
"type": "array",
41+
"description": "Configuration settings",
42+
"items": {
43+
"type": "object",
44+
"required": ["title", "properties"],
45+
"properties": {
46+
"title": {
47+
"type": "string",
48+
"description": "Configuration section title"
49+
},
50+
"properties": {
51+
"type": "object",
52+
"description": "Configuration properties",
53+
"additionalProperties": {
54+
"type": "object",
55+
"required": ["type"],
56+
"properties": {
57+
"type": {
58+
"type": "string",
59+
"enum": ["string", "boolean", "number", "array", "object"]
60+
},
61+
"default": {
62+
"description": "Default value"
63+
},
64+
"order": {
65+
"type": "number",
66+
"description": "Display order in settings UI"
67+
},
68+
"markdownDescription": {
69+
"type": "string",
70+
"description": "Markdown description for settings UI"
71+
},
72+
"enum": {
73+
"type": "array",
74+
"description": "Allowed values for string type"
75+
},
76+
"enumDescriptions": {
77+
"type": "array",
78+
"items": { "type": "string" },
79+
"description": "Descriptions for enum values"
80+
},
81+
"items": {
82+
"type": "object",
83+
"description": "Schema for array items"
84+
}
85+
}
86+
}
87+
}
88+
}
89+
}
90+
},
91+
"views": {
92+
"type": "object",
93+
"description": "Views contributed by this feature",
94+
"additionalProperties": {
95+
"type": "array",
96+
"items": {
97+
"type": "object",
98+
"required": ["id", "name"],
99+
"properties": {
100+
"id": {
101+
"type": "string",
102+
"description": "View identifier"
103+
},
104+
"name": {
105+
"type": "string",
106+
"description": "View name"
107+
},
108+
"type": {
109+
"type": "string",
110+
"enum": ["tree", "webview"],
111+
"description": "View type"
112+
},
113+
"icon": {
114+
"type": "string",
115+
"description": "View icon"
116+
},
117+
"when": {
118+
"type": "string",
119+
"description": "When clause for view visibility"
120+
},
121+
"visibility": {
122+
"type": "string",
123+
"enum": ["visible", "collapsed", "hidden"],
124+
"description": "Initial visibility state"
125+
}
126+
}
127+
}
128+
}
129+
},
130+
"viewsContainers": {
131+
"type": "object",
132+
"description": "View containers",
133+
"properties": {
134+
"activitybar": {
135+
"type": "array",
136+
"items": {
137+
"type": "object",
138+
"required": ["id", "title", "icon"],
139+
"properties": {
140+
"id": { "type": "string" },
141+
"title": { "type": "string" },
142+
"icon": { "type": "string" }
143+
}
144+
}
145+
},
146+
"panel": {
147+
"type": "array",
148+
"items": {
149+
"type": "object",
150+
"required": ["id", "title", "icon"],
151+
"properties": {
152+
"id": { "type": "string" },
153+
"title": { "type": "string" },
154+
"icon": { "type": "string" }
155+
}
156+
}
157+
}
158+
}
159+
},
160+
"menus": {
161+
"type": "object",
162+
"description": "Menu contributions",
163+
"additionalProperties": {
164+
"type": "array",
165+
"items": {
166+
"type": "object",
167+
"required": ["command"],
168+
"properties": {
169+
"command": {
170+
"type": "string",
171+
"description": "Command to execute"
172+
},
173+
"when": {
174+
"type": "string",
175+
"description": "When clause"
176+
},
177+
"group": {
178+
"type": "string",
179+
"description": "Menu group"
180+
}
181+
}
182+
}
183+
}
184+
}
185+
},
186+
"additionalProperties": false
187+
},
188+
"activationEvents": {
189+
"type": "array",
190+
"description": "Additional activation events for this feature",
191+
"items": {
192+
"type": "string"
193+
}
194+
}
195+
},
196+
"additionalProperties": false
197+
}

0 commit comments

Comments
 (0)