aegiscode 3.1.10 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/aegis.js +165 -0
- package/package.json +18 -86
- package/LICENSE +0 -21
- package/README.md +0 -394
- package/dist/main.js +0 -2171
- package/gui/run-gui.cjs +0 -13
- package/src/agent/Agent.ts +0 -903
- package/src/agent/SimpleAgent.ts +0 -48
- package/src/agent/index.ts +0 -54
- package/src/agent/orchestrator/AppBuilder.ts +0 -443
- package/src/agent/orchestrator/CouncilAgent.ts +0 -310
- package/src/agent/orchestrator/DiscussionRoom.ts +0 -462
- package/src/agent/orchestrator/OrchestratorAgent.ts +0 -637
- package/src/agent/orchestrator/index.ts +0 -38
- package/src/agent/orchestrator/utils.ts +0 -397
- package/src/agent/pricing.ts +0 -115
- package/src/agent/router.ts +0 -74
- package/src/agent/routerStats.ts +0 -121
- package/src/agent/types.ts +0 -318
- package/src/auth/login.ts +0 -383
- package/src/cli/config.ts +0 -189
- package/src/cli/index.ts +0 -17
- package/src/cli/middleware.ts +0 -119
- package/src/cli/types.ts +0 -75
- package/src/config/ConfigManager.ts +0 -587
- package/src/config/index.ts +0 -7
- package/src/config/types.ts +0 -584
- package/src/context/CompactionService.ts +0 -300
- package/src/context/ContextManager.ts +0 -450
- package/src/context/FileAnalyzer.ts +0 -267
- package/src/context/TokenCounter.ts +0 -265
- package/src/context/index.ts +0 -27
- package/src/context/storage/CacheStore.ts +0 -176
- package/src/context/storage/JSONLStore.ts +0 -201
- package/src/context/storage/MemoryStore.ts +0 -205
- package/src/context/storage/PersistentStore.ts +0 -327
- package/src/context/storage/index.ts +0 -9
- package/src/context/storage/pathUtils.ts +0 -114
- package/src/context/test.ts +0 -309
- package/src/context/types.ts +0 -268
- package/src/hooks/HookExecutor.ts +0 -434
- package/src/hooks/HookManager.ts +0 -596
- package/src/hooks/HookService.ts +0 -269
- package/src/hooks/Matcher.ts +0 -157
- package/src/hooks/index.ts +0 -63
- package/src/hooks/types.ts +0 -424
- package/src/main.tsx +0 -596
- package/src/mcp/HealthMonitor.ts +0 -150
- package/src/mcp/McpClient.ts +0 -491
- package/src/mcp/McpRegistry.ts +0 -321
- package/src/mcp/createMcpTool.ts +0 -251
- package/src/mcp/index.ts +0 -15
- package/src/mcp/server.ts +0 -334
- package/src/mcp/test-server.ts +0 -88
- package/src/mcp/test.ts +0 -372
- package/src/mcp/types.ts +0 -247
- package/src/memory/AgentMemoryBus.ts +0 -432
- package/src/memory/CloudSync.ts +0 -99
- package/src/memory/DriveSync.ts +0 -106
- package/src/memory/SharedMemory.ts +0 -951
- package/src/memory/index.ts +0 -14
- package/src/memory/machineFingerprint.ts +0 -40
- package/src/orchestrator/SubAgentMetadata.ts +0 -136
- package/src/prompts/builder.ts +0 -213
- package/src/prompts/default.ts +0 -144
- package/src/prompts/index.ts +0 -16
- package/src/prompts/plan.ts +0 -64
- package/src/prompts/test.ts +0 -78
- package/src/services/AnthropicChatService.ts +0 -341
- package/src/services/ChatService.ts +0 -347
- package/src/services/ClaudeCliChatService.ts +0 -256
- package/src/services/CloudSync.ts +0 -168
- package/src/services/CostLedger.ts +0 -211
- package/src/services/Heartbeat.ts +0 -135
- package/src/services/LearningCollector.ts +0 -291
- package/src/services/OllamaInstaller.ts +0 -342
- package/src/services/VersionChecker.ts +0 -445
- package/src/services/index.ts +0 -57
- package/src/services/streaming/OpenAIEventAdapter.ts +0 -126
- package/src/services/streaming/RenderingProfile.ts +0 -90
- package/src/services/streaming/StreamEventParser.ts +0 -181
- package/src/services/streaming/ThrottledRenderer.ts +0 -139
- package/src/services/streaming/TranscriptBuffer.ts +0 -574
- package/src/services/streaming/eventStatusMap.ts +0 -52
- package/src/services/streaming/index.ts +0 -46
- package/src/services/streaming/renderFormatting.ts +0 -79
- package/src/services/streaming/types.ts +0 -234
- package/src/skills/SkillLoader.ts +0 -126
- package/src/skills/SkillRegistry.ts +0 -366
- package/src/skills/index.ts +0 -48
- package/src/skills/types.ts +0 -146
- package/src/slash-commands/billing.ts +0 -70
- package/src/slash-commands/build.ts +0 -413
- package/src/slash-commands/builtinCommands.ts +0 -2733
- package/src/slash-commands/clone.ts +0 -242
- package/src/slash-commands/council.ts +0 -125
- package/src/slash-commands/custom/CustomCommandExecutor.ts +0 -143
- package/src/slash-commands/custom/CustomCommandLoader.ts +0 -251
- package/src/slash-commands/custom/CustomCommandRegistry.ts +0 -144
- package/src/slash-commands/custom/index.ts +0 -7
- package/src/slash-commands/debate.ts +0 -254
- package/src/slash-commands/gmail.ts +0 -105
- package/src/slash-commands/index.ts +0 -388
- package/src/slash-commands/mcpCommand.ts +0 -205
- package/src/slash-commands/types.ts +0 -201
- package/src/store/index.ts +0 -76
- package/src/store/selectors.ts +0 -246
- package/src/store/slices/appSlice.ts +0 -205
- package/src/store/slices/commandSlice.ts +0 -115
- package/src/store/slices/configSlice.ts +0 -46
- package/src/store/slices/focusSlice.ts +0 -64
- package/src/store/slices/index.ts +0 -9
- package/src/store/slices/sessionSlice.ts +0 -424
- package/src/store/streaming-buffer.ts +0 -425
- package/src/store/test.ts +0 -296
- package/src/store/types.ts +0 -274
- package/src/store/vanilla.ts +0 -186
- package/src/tools/builtin/bash.ts +0 -236
- package/src/tools/builtin/council.ts +0 -105
- package/src/tools/builtin/edit.ts +0 -213
- package/src/tools/builtin/glob.ts +0 -136
- package/src/tools/builtin/grep.ts +0 -263
- package/src/tools/builtin/index.ts +0 -61
- package/src/tools/builtin/memory.ts +0 -66
- package/src/tools/builtin/read.ts +0 -168
- package/src/tools/builtin/skill.ts +0 -97
- package/src/tools/builtin/snapshot.ts +0 -40
- package/src/tools/builtin/task.ts +0 -106
- package/src/tools/builtin/write.ts +0 -134
- package/src/tools/createTool.ts +0 -221
- package/src/tools/execution/ExecutionPipeline.ts +0 -263
- package/src/tools/execution/index.ts +0 -40
- package/src/tools/execution/stages/CacheStage.ts +0 -131
- package/src/tools/execution/stages/ConfirmationStage.ts +0 -203
- package/src/tools/execution/stages/DiscoveryStage.ts +0 -46
- package/src/tools/execution/stages/ExecutionStage.ts +0 -48
- package/src/tools/execution/stages/FormattingStage.ts +0 -44
- package/src/tools/execution/stages/HookStage.ts +0 -72
- package/src/tools/execution/stages/PermissionStage.ts +0 -287
- package/src/tools/execution/stages/PostHookStage.ts +0 -71
- package/src/tools/execution/stages/index.ts +0 -12
- package/src/tools/execution/test.ts +0 -266
- package/src/tools/execution/types.ts +0 -273
- package/src/tools/index.ts +0 -81
- package/src/tools/registry.ts +0 -304
- package/src/tools/schemas.ts +0 -109
- package/src/tools/test.ts +0 -220
- package/src/tools/types.ts +0 -175
- package/src/tools/validation/PermissionChecker.ts +0 -242
- package/src/tools/validation/SensitiveFileDetector.ts +0 -210
- package/src/tools/validation/index.ts +0 -11
- package/src/ui/App.tsx +0 -166
- package/src/ui/components/AegisInterface.tsx +0 -484
- package/src/ui/components/common/ChatSearch.tsx +0 -150
- package/src/ui/components/common/ErrorBoundary.tsx +0 -82
- package/src/ui/components/common/ExitMessage.tsx +0 -120
- package/src/ui/components/common/LoadingIndicator.tsx +0 -49
- package/src/ui/components/common/index.ts +0 -6
- package/src/ui/components/dialog/ConfirmationPrompt.tsx +0 -208
- package/src/ui/components/dialog/InteractiveSelector.tsx +0 -149
- package/src/ui/components/dialog/SetupWizard.tsx +0 -297
- package/src/ui/components/dialog/UpdatePrompt.tsx +0 -155
- package/src/ui/components/dialog/index.ts +0 -8
- package/src/ui/components/index.ts +0 -28
- package/src/ui/components/input/CommandSuggestions.tsx +0 -139
- package/src/ui/components/input/CustomTextInput.tsx +0 -220
- package/src/ui/components/input/InputArea.tsx +0 -361
- package/src/ui/components/input/PromptSuggestions.tsx +0 -66
- package/src/ui/components/input/index.ts +0 -6
- package/src/ui/components/layout/ChatStatusBar.tsx +0 -90
- package/src/ui/components/layout/ContextBar.tsx +0 -79
- package/src/ui/components/layout/MessageArea.tsx +0 -96
- package/src/ui/components/layout/MessageList.tsx +0 -647
- package/src/ui/components/layout/MessageSeparator.tsx +0 -26
- package/src/ui/components/layout/WelcomeMessage.tsx +0 -93
- package/src/ui/components/layout/index.ts +0 -7
- package/src/ui/components/markdown/CodeHighlighter.tsx +0 -292
- package/src/ui/components/markdown/MessageRenderer.tsx +0 -1211
- package/src/ui/components/markdown/index.ts +0 -8
- package/src/ui/components/markdown/parser.ts +0 -336
- package/src/ui/components/markdown/types.ts +0 -66
- package/src/ui/focus/FocusManager.ts +0 -137
- package/src/ui/focus/index.ts +0 -13
- package/src/ui/focus/types.ts +0 -54
- package/src/ui/focus/useFocus.ts +0 -75
- package/src/ui/hooks/index.ts +0 -11
- package/src/ui/hooks/useAgent.ts +0 -284
- package/src/ui/hooks/useCommandHistory.ts +0 -87
- package/src/ui/hooks/useCommandProcessor.ts +0 -443
- package/src/ui/hooks/useConfirmation.ts +0 -99
- package/src/ui/hooks/useCtrlCHandler.ts +0 -100
- package/src/ui/hooks/useInputBuffer.ts +0 -122
- package/src/ui/hooks/useTerminalSize.ts +0 -68
- package/src/ui/hooks/useTerminalWidth.ts +0 -5
- package/src/ui/hooks/useWindowedList.ts +0 -118
- package/src/ui/render-debugger.ts +0 -621
- package/src/ui/test.ts +0 -189
- package/src/ui/themes/ThemeManager.ts +0 -332
- package/src/ui/themes/aegisTheme.ts +0 -87
- package/src/ui/themes/darkTheme.ts +0 -87
- package/src/ui/themes/defaultTheme.ts +0 -85
- package/src/ui/themes/index.ts +0 -10
- package/src/ui/themes/lightTheme.ts +0 -89
- package/src/ui/themes/popularThemes.ts +0 -187
- package/src/ui/themes/types.ts +0 -130
- package/src/utils/clipboard.ts +0 -48
- package/src/utils/debug.ts +0 -43
- package/src/utils/environment.ts +0 -68
- package/src/utils/index.ts +0 -10
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SkillRegistry - Skills 注册中心
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import * as fs from 'node:fs';
|
|
9
|
-
import * as path from 'node:path';
|
|
10
|
-
import * as os from 'node:os';
|
|
11
|
-
import { parseSkillFile, extractMetadataFields } from './SkillLoader.js';
|
|
12
|
-
import type {
|
|
13
|
-
SkillMetadata,
|
|
14
|
-
SkillContent,
|
|
15
|
-
SkillSource,
|
|
16
|
-
SkillDiscoveryResult,
|
|
17
|
-
} from './types.js';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
const BUILTIN_SKILLS: Map<string, SkillContent> = new Map([
|
|
23
|
-
// skill-creator 内
|
|
24
|
-
['skill-creator', {
|
|
25
|
-
metadata: {
|
|
26
|
-
name: 'skill-creator',
|
|
27
|
-
description: 'Create and manage custom skills. Use when you want to add new SKILL.md files.',
|
|
28
|
-
userInvocable: true,
|
|
29
|
-
disableModelInvocation: false,
|
|
30
|
-
source: 'builtin',
|
|
31
|
-
sourceDir: 'aegis',
|
|
32
|
-
path: '',
|
|
33
|
-
basePath: '',
|
|
34
|
-
},
|
|
35
|
-
instructions: `# Skill Creator 指南
|
|
36
|
-
|
|
37
|
-
你是一个 Skill 创建助手。帮助用户创建新的 SKILL.md 文件。
|
|
38
|
-
|
|
39
|
-
## SKILL.md 格式
|
|
40
|
-
|
|
41
|
-
\`\`\`markdown
|
|
42
|
-
---
|
|
43
|
-
name: my-skill
|
|
44
|
-
description: 简短描述这个 Skill 做什么,以及何时使用它。
|
|
45
|
-
allowed-tools:
|
|
46
|
-
- Read
|
|
47
|
-
- Grep
|
|
48
|
-
- Bash(git:*)
|
|
49
|
-
user-invocable: true
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
# Skill 标题
|
|
53
|
-
|
|
54
|
-
详细的指令内容...
|
|
55
|
-
\`\`\`
|
|
56
|
-
|
|
57
|
-
## 必填字段
|
|
58
|
-
|
|
59
|
-
- **name**: 1-64 字符,小写字母+数字+连字符
|
|
60
|
-
- **description**: ≤1024 字符,描述功能和触发时机
|
|
61
|
-
|
|
62
|
-
## 可选字段
|
|
63
|
-
|
|
64
|
-
- **allowed-tools**: 限制可用工具
|
|
65
|
-
- **user-invocable**: 允许 /name 调用
|
|
66
|
-
- **disable-model-invocation**: 禁止 AI 自动调用
|
|
67
|
-
- **argument-hint**: 参数提示,如 \`<file_path>\`
|
|
68
|
-
|
|
69
|
-
## 存放位置
|
|
70
|
-
|
|
71
|
-
- 项目级(Git 共享): \`.aegis/skills/<name>/SKILL.md\`
|
|
72
|
-
- 用户级(全局): \`~/.aegis/skills/<name>/SKILL.md\`
|
|
73
|
-
|
|
74
|
-
## 示例
|
|
75
|
-
|
|
76
|
-
请告诉我你想创建什么类型的 Skill,我会帮你生成完整的 SKILL.md 文件。
|
|
77
|
-
`,
|
|
78
|
-
}],
|
|
79
|
-
]);
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Skills 注册中心(单例)
|
|
83
|
-
*/
|
|
84
|
-
export class SkillRegistry {
|
|
85
|
-
private static instance: SkillRegistry | null = null;
|
|
86
|
-
private skills: Map<string, SkillMetadata> = new Map();
|
|
87
|
-
private initialized = false;
|
|
88
|
-
private workspaceRoot: string = process.cwd();
|
|
89
|
-
|
|
90
|
-
private constructor() {}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
*/
|
|
95
|
-
static getInstance(): SkillRegistry {
|
|
96
|
-
if (!SkillRegistry.instance) {
|
|
97
|
-
SkillRegistry.instance = new SkillRegistry();
|
|
98
|
-
}
|
|
99
|
-
return SkillRegistry.instance;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
*
|
|
104
|
-
*/
|
|
105
|
-
static resetInstance(): void {
|
|
106
|
-
SkillRegistry.instance = null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* 1. 内置 Skills
|
|
114
|
-
* 2. ~/.claude/skills
|
|
115
|
-
* 3. ~/.aegis/skills
|
|
116
|
-
* 4. .claude/skills
|
|
117
|
-
* 5. .aegis/skills(最高优先级)
|
|
118
|
-
*/
|
|
119
|
-
async initialize(workspaceRoot?: string): Promise<SkillDiscoveryResult> {
|
|
120
|
-
if (workspaceRoot) {
|
|
121
|
-
this.workspaceRoot = workspaceRoot;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const result: SkillDiscoveryResult = {
|
|
125
|
-
count: 0,
|
|
126
|
-
bySource: { user: 0, project: 0, builtin: 0 },
|
|
127
|
-
errors: [],
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// 1. 加载内置 Skills(优先级最
|
|
131
|
-
this.loadBuiltinSkills();
|
|
132
|
-
result.bySource.builtin = BUILTIN_SKILLS.size;
|
|
133
|
-
|
|
134
|
-
// 2. 按优先级扫描目录(后加载的覆盖先加载
|
|
135
|
-
const homeDir = os.homedir();
|
|
136
|
-
|
|
137
|
-
// 用户级 - claude 目
|
|
138
|
-
await this.scanDirectory(
|
|
139
|
-
path.join(homeDir, '.claude', 'skills'),
|
|
140
|
-
'user',
|
|
141
|
-
'claude',
|
|
142
|
-
result
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
// 用户级 - aegis 目
|
|
146
|
-
await this.scanDirectory(
|
|
147
|
-
path.join(homeDir, '.aegis', 'skills'),
|
|
148
|
-
'user',
|
|
149
|
-
'aegis',
|
|
150
|
-
result
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
// 项目级 - claude 目
|
|
154
|
-
await this.scanDirectory(
|
|
155
|
-
path.join(this.workspaceRoot, '.claude', 'skills'),
|
|
156
|
-
'project',
|
|
157
|
-
'claude',
|
|
158
|
-
result
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
// 项目级 - aegis 目录(最高优先
|
|
162
|
-
await this.scanDirectory(
|
|
163
|
-
path.join(this.workspaceRoot, '.aegis', 'skills'),
|
|
164
|
-
'project',
|
|
165
|
-
'aegis',
|
|
166
|
-
result
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
result.count = this.skills.size;
|
|
170
|
-
this.initialized = true;
|
|
171
|
-
|
|
172
|
-
return result;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
*
|
|
177
|
-
*/
|
|
178
|
-
private loadBuiltinSkills(): void {
|
|
179
|
-
for (const [name, content] of BUILTIN_SKILLS) {
|
|
180
|
-
this.skills.set(name, content.metadata);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
*
|
|
186
|
-
*/
|
|
187
|
-
private async scanDirectory(
|
|
188
|
-
dir: string,
|
|
189
|
-
source: SkillSource,
|
|
190
|
-
sourceDir: 'claude' | 'aegis',
|
|
191
|
-
result: SkillDiscoveryResult
|
|
192
|
-
): Promise<void> {
|
|
193
|
-
if (!fs.existsSync(dir)) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
let entries: fs.Dirent[];
|
|
198
|
-
try {
|
|
199
|
-
entries = await fs.promises.readdir(dir, { withFileTypes: true });
|
|
200
|
-
} catch {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
for (const entry of entries) {
|
|
205
|
-
if (!entry.isDirectory()) continue;
|
|
206
|
-
|
|
207
|
-
const skillDir = path.join(dir, entry.name);
|
|
208
|
-
const skillPath = path.join(skillDir, 'SKILL.md');
|
|
209
|
-
|
|
210
|
-
if (!fs.existsSync(skillPath)) continue;
|
|
211
|
-
|
|
212
|
-
try {
|
|
213
|
-
const metadata = await this.loadMetadata(skillPath, source, sourceDir);
|
|
214
|
-
this.skills.set(metadata.name, metadata);
|
|
215
|
-
|
|
216
|
-
if (source === 'user') {
|
|
217
|
-
result.bySource.user++;
|
|
218
|
-
} else {
|
|
219
|
-
result.bySource.project++;
|
|
220
|
-
}
|
|
221
|
-
} catch (error) {
|
|
222
|
-
result.errors.push({
|
|
223
|
-
path: skillPath,
|
|
224
|
-
error: (error as Error).message,
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
*
|
|
232
|
-
*/
|
|
233
|
-
private async loadMetadata(
|
|
234
|
-
skillPath: string,
|
|
235
|
-
source: SkillSource,
|
|
236
|
-
sourceDir: 'claude' | 'aegis'
|
|
237
|
-
): Promise<SkillMetadata> {
|
|
238
|
-
const content = await fs.promises.readFile(skillPath, 'utf-8');
|
|
239
|
-
const { frontmatter } = parseSkillFile(content);
|
|
240
|
-
const fields = extractMetadataFields(frontmatter);
|
|
241
|
-
|
|
242
|
-
return {
|
|
243
|
-
name: frontmatter.name,
|
|
244
|
-
description: frontmatter.description,
|
|
245
|
-
...fields,
|
|
246
|
-
source,
|
|
247
|
-
sourceDir,
|
|
248
|
-
path: skillPath,
|
|
249
|
-
basePath: path.dirname(skillPath),
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
*
|
|
255
|
-
*/
|
|
256
|
-
async loadContent(name: string): Promise<SkillContent | null> {
|
|
257
|
-
const metadata = this.skills.get(name);
|
|
258
|
-
if (!metadata) {
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// 内置 Skill 直接返
|
|
263
|
-
if (metadata.source === 'builtin') {
|
|
264
|
-
return BUILTIN_SKILLS.get(name) || null;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// 从文件加
|
|
268
|
-
try {
|
|
269
|
-
const content = await fs.promises.readFile(metadata.path, 'utf-8');
|
|
270
|
-
const { body } = parseSkillFile(content);
|
|
271
|
-
|
|
272
|
-
return {
|
|
273
|
-
metadata,
|
|
274
|
-
instructions: body,
|
|
275
|
-
};
|
|
276
|
-
} catch {
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
*
|
|
283
|
-
*/
|
|
284
|
-
getAllSkills(): SkillMetadata[] {
|
|
285
|
-
return Array.from(this.skills.values());
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
*
|
|
290
|
-
*/
|
|
291
|
-
getModelInvocableSkills(): SkillMetadata[] {
|
|
292
|
-
return Array.from(this.skills.values())
|
|
293
|
-
.filter(skill => !skill.disableModelInvocation);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
*
|
|
298
|
-
*/
|
|
299
|
-
getUserInvocableSkills(): SkillMetadata[] {
|
|
300
|
-
return Array.from(this.skills.values())
|
|
301
|
-
.filter(skill => skill.userInvocable);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
*
|
|
306
|
-
*/
|
|
307
|
-
hasSkill(name: string): boolean {
|
|
308
|
-
return this.skills.has(name);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
*
|
|
313
|
-
*/
|
|
314
|
-
getSkill(name: string): SkillMetadata | undefined {
|
|
315
|
-
return this.skills.get(name);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
*
|
|
320
|
-
*/
|
|
321
|
-
getCount(): number {
|
|
322
|
-
return this.skills.size;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
*
|
|
327
|
-
*/
|
|
328
|
-
async refresh(): Promise<SkillDiscoveryResult> {
|
|
329
|
-
this.skills.clear();
|
|
330
|
-
this.initialized = false;
|
|
331
|
-
return this.initialize(this.workspaceRoot);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*/
|
|
339
|
-
generateAvailableSkillsList(): string {
|
|
340
|
-
const skills = this.getModelInvocableSkills();
|
|
341
|
-
if (skills.length === 0) {
|
|
342
|
-
return '';
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const lines = skills.map(skill => {
|
|
346
|
-
const hint = skill.argumentHint ? ` ${skill.argumentHint}` : '';
|
|
347
|
-
return `- ${skill.name}${hint}: ${skill.description}`;
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
return `<available_skills>
|
|
351
|
-
${lines.join('\n')}
|
|
352
|
-
</available_skills>`;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
*
|
|
357
|
-
*/
|
|
358
|
-
isInitialized(): boolean {
|
|
359
|
-
return this.initialized;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// 导出单例获取函
|
|
364
|
-
export function getSkillRegistry(): SkillRegistry {
|
|
365
|
-
return SkillRegistry.getInstance();
|
|
366
|
-
}
|
package/src/skills/index.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skills 模块
|
|
3
|
-
*
|
|
4
|
-
* Skills 是一种核心扩展机制,允许通过 Markdown 文件(SKILL.md)定义专业能力。
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* 1. 发现阶段:系统提示仅包含 Skills 名称和描述
|
|
9
|
-
* 2. 激活阶段:AI 判断需要某个 Skill 时调用 Skill 工具
|
|
10
|
-
* 3. 加载阶段:按需加载完整 SKILL.md 内容
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export * from './types.js';
|
|
14
|
-
export * from './SkillLoader.js';
|
|
15
|
-
export { SkillRegistry, getSkillRegistry } from './SkillRegistry.js';
|
|
16
|
-
|
|
17
|
-
// 便捷初始化函
|
|
18
|
-
import { getSkillRegistry } from './SkillRegistry.js';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @param workspaceRoot - 工作区根目录
|
|
24
|
-
* @returns 发现结果
|
|
25
|
-
*/
|
|
26
|
-
export async function initializeSkills(workspaceRoot?: string) {
|
|
27
|
-
const registry = getSkillRegistry();
|
|
28
|
-
return registry.initialize(workspaceRoot);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @param name - Skill 名称
|
|
35
|
-
* @returns Skill 内容,如果不存在返回 null
|
|
36
|
-
*/
|
|
37
|
-
export async function loadSkillContent(name: string) {
|
|
38
|
-
const registry = getSkillRegistry();
|
|
39
|
-
return registry.loadContent(name);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
export function generateSkillsPrompt(): string {
|
|
46
|
-
const registry = getSkillRegistry();
|
|
47
|
-
return registry.generateAvailableSkillsList();
|
|
48
|
-
}
|
package/src/skills/types.ts
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skills 系统类型定义
|
|
3
|
-
*
|
|
4
|
-
* Skills 是一种核心扩展机制,允许通过 SKILL.md 定义专业能力和最佳实践。
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Skill 来源
|
|
10
|
-
*/
|
|
11
|
-
export type SkillSource = 'user' | 'project' | 'builtin';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Skill 元数据(启动时加载,占用少量 Token)
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
export interface SkillMetadata {
|
|
19
|
-
/** 唯一标识,小写+数字+连字符,≤64字符 */
|
|
20
|
-
name: string;
|
|
21
|
-
|
|
22
|
-
/** 激活描述,≤1024字符,包含"什么"和"何时使用" */
|
|
23
|
-
description: string;
|
|
24
|
-
|
|
25
|
-
/** 工具访问限制,如 ['Read', 'Grep', 'Bash(git:*)'] */
|
|
26
|
-
allowedTools?: string[];
|
|
27
|
-
|
|
28
|
-
/** 参数提示,如 '<file_path>' */
|
|
29
|
-
argumentHint?: string;
|
|
30
|
-
|
|
31
|
-
/** 是否支持 /skill-name 调用(默认 false) */
|
|
32
|
-
userInvocable: boolean;
|
|
33
|
-
|
|
34
|
-
/** 是否禁止 AI 自动调用(默认 false) */
|
|
35
|
-
disableModelInvocation: boolean;
|
|
36
|
-
|
|
37
|
-
/** 指定执行模型 */
|
|
38
|
-
model?: string;
|
|
39
|
-
|
|
40
|
-
/** 额外触发条件,补充 description */
|
|
41
|
-
whenToUse?: string;
|
|
42
|
-
|
|
43
|
-
/** 版本号 */
|
|
44
|
-
version?: string;
|
|
45
|
-
|
|
46
|
-
/** 来源 */
|
|
47
|
-
source: SkillSource;
|
|
48
|
-
|
|
49
|
-
/** 来源目录类型 */
|
|
50
|
-
sourceDir: 'claude' | 'aegis';
|
|
51
|
-
|
|
52
|
-
/** SKILL.md 文件路径 */
|
|
53
|
-
path: string;
|
|
54
|
-
|
|
55
|
-
/** Skill 目录路径 */
|
|
56
|
-
basePath: string;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Skill 完整内容(按需加载)
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*/
|
|
64
|
-
export interface SkillContent {
|
|
65
|
-
metadata: SkillMetadata;
|
|
66
|
-
/** Markdown 正文(指令内容) */
|
|
67
|
-
instructions: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* SKILL.md Frontmatter 配置
|
|
72
|
-
*/
|
|
73
|
-
export interface SkillFrontmatter {
|
|
74
|
-
/** 必填:Skill 名称 */
|
|
75
|
-
name: string;
|
|
76
|
-
|
|
77
|
-
/** 必填:描述(AI 用于判断何时调用) */
|
|
78
|
-
description: string;
|
|
79
|
-
|
|
80
|
-
/** 可选:允许的工具列表 */
|
|
81
|
-
'allowed-tools'?: string[];
|
|
82
|
-
|
|
83
|
-
/** 可选:是否允许用户通过 /name 调用 */
|
|
84
|
-
'user-invocable'?: boolean;
|
|
85
|
-
|
|
86
|
-
/** 可选:是否禁止 AI 自动调用 */
|
|
87
|
-
'disable-model-invocation'?: boolean;
|
|
88
|
-
|
|
89
|
-
/** 可选:参数提示 */
|
|
90
|
-
'argument-hint'?: string;
|
|
91
|
-
|
|
92
|
-
/** 可选:指定模型 */
|
|
93
|
-
model?: string;
|
|
94
|
-
|
|
95
|
-
/** 可选:额外触发条件 */
|
|
96
|
-
when_to_use?: string;
|
|
97
|
-
|
|
98
|
-
/** 可选:版本号 */
|
|
99
|
-
version?: string;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
*
|
|
104
|
-
*/
|
|
105
|
-
export interface ParsedSkillFile {
|
|
106
|
-
frontmatter: SkillFrontmatter;
|
|
107
|
-
body: string;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Skill 发现结果
|
|
112
|
-
*/
|
|
113
|
-
export interface SkillDiscoveryResult {
|
|
114
|
-
/** 加载的 Skills 数量 */
|
|
115
|
-
count: number;
|
|
116
|
-
/** 按来源分类的数量 */
|
|
117
|
-
bySource: {
|
|
118
|
-
user: number;
|
|
119
|
-
project: number;
|
|
120
|
-
builtin: number;
|
|
121
|
-
};
|
|
122
|
-
/** 错误列表 */
|
|
123
|
-
errors: Array<{
|
|
124
|
-
path: string;
|
|
125
|
-
error: string;
|
|
126
|
-
}>;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Skill 工具参数
|
|
131
|
-
*/
|
|
132
|
-
export interface SkillToolParams {
|
|
133
|
-
/** Skill 名称 */
|
|
134
|
-
skill: string;
|
|
135
|
-
/** 可选:传递给 Skill 的参数 */
|
|
136
|
-
args?: string;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Skill 工具结果
|
|
141
|
-
*/
|
|
142
|
-
export interface SkillToolResult {
|
|
143
|
-
success: boolean;
|
|
144
|
-
content?: string;
|
|
145
|
-
error?: string;
|
|
146
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /billing — AEGIS Billing info
|
|
3
|
-
*/
|
|
4
|
-
import { exec } from 'child_process';
|
|
5
|
-
|
|
6
|
-
function openUrl(url: string) {
|
|
7
|
-
const cmd = process.platform === 'darwin' ? `open "${url}"` :
|
|
8
|
-
process.platform === 'win32' ? `start "${url}"` :
|
|
9
|
-
`xdg-open "${url}"`;
|
|
10
|
-
exec(cmd, () => {});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const PROVIDERS = [
|
|
14
|
-
{
|
|
15
|
-
id: 'claude',
|
|
16
|
-
name: 'Claude (Anthropic)',
|
|
17
|
-
description: 'Best quality — Claude Sonnet 4.5',
|
|
18
|
-
pricing: '$3/MTok input · $15/MTok output',
|
|
19
|
-
url: 'https://console.anthropic.com/settings/billing',
|
|
20
|
-
recommend: true,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
id: 'deepseek',
|
|
24
|
-
name: 'DeepSeek',
|
|
25
|
-
description: 'Best value — fast & affordable',
|
|
26
|
-
pricing: '$0.14/MTok input · $0.28/MTok output',
|
|
27
|
-
url: 'https://platform.deepseek.com/usage',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
id: 'groq',
|
|
31
|
-
name: 'Groq',
|
|
32
|
-
description: 'Free tier — 100k tokens/day',
|
|
33
|
-
pricing: 'Free · Dev tier available',
|
|
34
|
-
url: 'https://console.groq.com/settings/billing',
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
export async function runBilling(args: string): Promise<string> {
|
|
39
|
-
const arg = args.trim().toLowerCase();
|
|
40
|
-
|
|
41
|
-
// Direct open
|
|
42
|
-
const found = PROVIDERS.find(p => p.id === arg);
|
|
43
|
-
if (found) {
|
|
44
|
-
openUrl(found.url);
|
|
45
|
-
return `Opening ${found.name} billing...\n${found.url}`;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Show info
|
|
49
|
-
const lines: string[] = [
|
|
50
|
-
'## ⬡ API Billing',
|
|
51
|
-
'',
|
|
52
|
-
'> AEGIS CLI uses auto-routing — cheapest provider selected per request.',
|
|
53
|
-
'> Pricing includes a margin on provider cost.',
|
|
54
|
-
'',
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
for (const p of PROVIDERS) {
|
|
58
|
-
const rec = p.recommend ? ' ★ recommended' : '';
|
|
59
|
-
lines.push(`**${p.name}**${rec}`);
|
|
60
|
-
lines.push(`${p.description}`);
|
|
61
|
-
lines.push(`${p.pricing}`);
|
|
62
|
-
lines.push(`${p.url}`);
|
|
63
|
-
lines.push('');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
lines.push('---');
|
|
67
|
-
lines.push('Run `/billing claude` · `/billing deepseek` · `/billing groq` to open billing page');
|
|
68
|
-
|
|
69
|
-
return lines.join('\n');
|
|
70
|
-
}
|