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,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Terminal render formatting — plain-text CLI formatting functions.
|
|
3
|
-
*
|
|
4
|
-
* Replicates the formatting interface from free-claude-code's
|
|
5
|
-
* messaging/rendering/discord_markdown.py and telegram_markdown.py,
|
|
6
|
-
* but optimized for terminal/CLI output (no markdown-it parser needed).
|
|
7
|
-
*
|
|
8
|
-
* For a CLI app, we keep it simple: bold via ANSI, code via backticks,
|
|
9
|
-
* and no complex markdown rendering — raw text is fine.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import type { RenderFormatting, RenderContext } from './types.js';
|
|
13
|
-
|
|
14
|
-
// ==================== Terminal Formatting ====================
|
|
15
|
-
|
|
16
|
-
/** Bold text using ANSI escape codes */
|
|
17
|
-
function termBold(text: string): string {
|
|
18
|
-
return `\x1b[1m${text}\x1b[22m`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Inline code — wraps in backticks (no escaping needed for terminal display) */
|
|
22
|
-
function termCodeInline(text: string): string {
|
|
23
|
-
return `\`${text}\``;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** Escape text — no-op for terminal; ANSI is fine */
|
|
27
|
-
function termEscapeText(text: string): string {
|
|
28
|
-
return text;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Escape code content — no-op for terminal */
|
|
32
|
-
function termEscapeCode(text: string): string {
|
|
33
|
-
return text;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** Render markdown — pass-through for terminal (simple formatting only) */
|
|
37
|
-
function termRenderMarkdown(text: string): string {
|
|
38
|
-
return text;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Default terminal formatting bundle */
|
|
42
|
-
export const TERMINAL_FORMATTING: RenderFormatting = {
|
|
43
|
-
bold: termBold,
|
|
44
|
-
codeInline: termCodeInline,
|
|
45
|
-
escapeText: termEscapeText,
|
|
46
|
-
escapeCode: termEscapeCode,
|
|
47
|
-
renderMarkdown: termRenderMarkdown,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/** Plain text formatting bundle (no ANSI escapes) */
|
|
51
|
-
export const PLAIN_TEXT_FORMATTING: RenderFormatting = {
|
|
52
|
-
bold: (t: string) => t,
|
|
53
|
-
codeInline: (t: string) => `\`${t}\``,
|
|
54
|
-
escapeText: (t: string) => t,
|
|
55
|
-
escapeCode: (t: string) => t,
|
|
56
|
-
renderMarkdown: (t: string) => t,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// ==================== Render Context Builders ====================
|
|
60
|
-
|
|
61
|
-
export interface BuildRenderContextOptions {
|
|
62
|
-
formatting?: RenderFormatting;
|
|
63
|
-
limitChars?: number;
|
|
64
|
-
thinkingTailMax?: number;
|
|
65
|
-
textTailMax?: number;
|
|
66
|
-
toolOutputTailMax?: number;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function buildRenderContext(
|
|
70
|
-
options: BuildRenderContextOptions = {}
|
|
71
|
-
): RenderContext {
|
|
72
|
-
return {
|
|
73
|
-
formatting: options.formatting ?? TERMINAL_FORMATTING,
|
|
74
|
-
limitChars: options.limitChars ?? 10000,
|
|
75
|
-
thinkingTailMax: options.thinkingTailMax ?? 1000,
|
|
76
|
-
textTailMax: options.textTailMax ?? 2000,
|
|
77
|
-
toolOutputTailMax: options.toolOutputTailMax ?? 1600,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Streaming types — replicated from Claude Code's content block streaming model.
|
|
3
|
-
*
|
|
4
|
-
* The Anthropic Messages API streams content as content_block_start/delta/stop
|
|
5
|
-
* events, where each block (text, thinking, tool_use) has an index and a clear
|
|
6
|
-
* lifecycle. This mirrors the event architecture in free-claude-code's
|
|
7
|
-
* messaging/event_parser.py and messaging/transcript.py.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
// ==================== Raw Wire Events (from API stream chunks) ====================
|
|
11
|
-
|
|
12
|
-
export interface ContentBlockStartEvent {
|
|
13
|
-
type: 'content_block_start';
|
|
14
|
-
index: number;
|
|
15
|
-
content_block: {
|
|
16
|
-
type: 'text';
|
|
17
|
-
text: string;
|
|
18
|
-
} | {
|
|
19
|
-
type: 'thinking';
|
|
20
|
-
thinking: string;
|
|
21
|
-
} | {
|
|
22
|
-
type: 'tool_use';
|
|
23
|
-
id: string;
|
|
24
|
-
name: string;
|
|
25
|
-
input: unknown;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface ContentBlockDeltaEvent {
|
|
30
|
-
type: 'content_block_delta';
|
|
31
|
-
index: number;
|
|
32
|
-
delta: {
|
|
33
|
-
type: 'text_delta';
|
|
34
|
-
text: string;
|
|
35
|
-
} | {
|
|
36
|
-
type: 'thinking_delta';
|
|
37
|
-
thinking: string;
|
|
38
|
-
} | {
|
|
39
|
-
type: 'input_json_delta';
|
|
40
|
-
partial_json: string;
|
|
41
|
-
} | {
|
|
42
|
-
type: 'citations_delta';
|
|
43
|
-
citation: {
|
|
44
|
-
type: string;
|
|
45
|
-
cited_text: string;
|
|
46
|
-
document_index: number;
|
|
47
|
-
document_title?: string | null;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface ContentBlockStopEvent {
|
|
53
|
-
type: 'content_block_stop';
|
|
54
|
-
index: number;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface MessageStartEvent {
|
|
58
|
-
type: 'message_start';
|
|
59
|
-
message: {
|
|
60
|
-
id: string;
|
|
61
|
-
content: unknown[];
|
|
62
|
-
usage?: {
|
|
63
|
-
input_tokens: number;
|
|
64
|
-
output_tokens: number;
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface MessageDeltaEvent {
|
|
70
|
-
type: 'message_delta';
|
|
71
|
-
delta: {
|
|
72
|
-
stop_reason: string;
|
|
73
|
-
stop_sequence: string | null;
|
|
74
|
-
};
|
|
75
|
-
usage?: {
|
|
76
|
-
output_tokens: number;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface MessageStopEvent {
|
|
81
|
-
type: 'message_stop';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface PingEvent {
|
|
85
|
-
type: 'ping';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface ErrorEvent {
|
|
89
|
-
type: 'error';
|
|
90
|
-
error: {
|
|
91
|
-
type: string;
|
|
92
|
-
message: string;
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export type AnthropicStreamEvent =
|
|
97
|
-
| ContentBlockStartEvent
|
|
98
|
-
| ContentBlockDeltaEvent
|
|
99
|
-
| ContentBlockStopEvent
|
|
100
|
-
| MessageStartEvent
|
|
101
|
-
| MessageDeltaEvent
|
|
102
|
-
| MessageStopEvent
|
|
103
|
-
| PingEvent
|
|
104
|
-
| ErrorEvent;
|
|
105
|
-
|
|
106
|
-
// ==================== Parsed Internal Events (what the transcript buffer consumes) ====================
|
|
107
|
-
|
|
108
|
-
export type ParsedEventType =
|
|
109
|
-
| 'thinking_start'
|
|
110
|
-
| 'thinking_delta'
|
|
111
|
-
| 'thinking_stop'
|
|
112
|
-
| 'thinking_chunk'
|
|
113
|
-
| 'text_start'
|
|
114
|
-
| 'text_delta'
|
|
115
|
-
| 'text_stop'
|
|
116
|
-
| 'text_chunk'
|
|
117
|
-
| 'tool_use_start'
|
|
118
|
-
| 'tool_use_delta'
|
|
119
|
-
| 'tool_use_stop'
|
|
120
|
-
| 'tool_use' // non-streaming full tool_use
|
|
121
|
-
| 'tool_result'
|
|
122
|
-
| 'block_stop'
|
|
123
|
-
| 'error'
|
|
124
|
-
| 'complete';
|
|
125
|
-
|
|
126
|
-
export interface ParsedEvent {
|
|
127
|
-
type: ParsedEventType;
|
|
128
|
-
index?: number;
|
|
129
|
-
text?: string;
|
|
130
|
-
id?: string;
|
|
131
|
-
name?: string;
|
|
132
|
-
input?: unknown;
|
|
133
|
-
partial_json?: string;
|
|
134
|
-
tool_use_id?: string;
|
|
135
|
-
content?: unknown;
|
|
136
|
-
is_error?: boolean;
|
|
137
|
-
message?: string;
|
|
138
|
-
status?: string;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// ==================== Segment Types (for the transcript buffer) ====================
|
|
142
|
-
|
|
143
|
-
export type SegmentKind =
|
|
144
|
-
| 'thinking'
|
|
145
|
-
| 'text'
|
|
146
|
-
| 'tool_call'
|
|
147
|
-
| 'tool_result'
|
|
148
|
-
| 'subagent'
|
|
149
|
-
| 'error';
|
|
150
|
-
|
|
151
|
-
export interface StreamSegment {
|
|
152
|
-
kind: SegmentKind;
|
|
153
|
-
/** Unique tool use id (for tool_call / tool_result) */
|
|
154
|
-
id?: string;
|
|
155
|
-
/** Tool name (for tool_call) */
|
|
156
|
-
name?: string;
|
|
157
|
-
/** Accumulated text content */
|
|
158
|
-
text: string;
|
|
159
|
-
/** Whether tool call is closed (received stop) */
|
|
160
|
-
closed?: boolean;
|
|
161
|
-
/** Subagent nesting level */
|
|
162
|
-
indentLevel?: number;
|
|
163
|
-
/** Whether tool result is an error */
|
|
164
|
-
isError?: boolean;
|
|
165
|
-
/** Subagent description (for subagent segments) */
|
|
166
|
-
description?: string;
|
|
167
|
-
/** Tool calls made by subagent */
|
|
168
|
-
toolCalls?: number;
|
|
169
|
-
/** Tools used by subagent */
|
|
170
|
-
toolsUsed?: Set<string>;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// ==================== Transcript Render Context ====================
|
|
174
|
-
|
|
175
|
-
/** Formatting functions used by segment renderers */
|
|
176
|
-
export interface RenderFormatting {
|
|
177
|
-
/** Bold formatting */
|
|
178
|
-
bold: (text: string) => string;
|
|
179
|
-
/** Inline code formatting */
|
|
180
|
-
codeInline: (text: string) => string;
|
|
181
|
-
/** Escape text for the target format */
|
|
182
|
-
escapeText: (text: string) => string;
|
|
183
|
-
/** Escape text inside code spans/blocks */
|
|
184
|
-
escapeCode: (text: string) => string;
|
|
185
|
-
/** Render markdown string into target platform format */
|
|
186
|
-
renderMarkdown: (text: string) => string;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export interface RenderContext {
|
|
190
|
-
/** Formatting function bundle */
|
|
191
|
-
formatting: RenderFormatting;
|
|
192
|
-
/** Max chars for thinking tail */
|
|
193
|
-
thinkingTailMax?: number;
|
|
194
|
-
/** Max chars for text tail */
|
|
195
|
-
textTailMax?: number;
|
|
196
|
-
/** Max chars for tool output */
|
|
197
|
-
toolOutputTailMax?: number;
|
|
198
|
-
/** Total limit chars for rendered output */
|
|
199
|
-
limitChars: number;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// ==================== Rendering Profile ====================
|
|
203
|
-
|
|
204
|
-
export interface RenderingProfile {
|
|
205
|
-
/** Format status: emoji + label + optional suffix */
|
|
206
|
-
formatStatus: (emoji: string, label: string, suffix?: string) => string;
|
|
207
|
-
/** Platform parse mode (e.g. "MarkdownV2", null for plain/terminal) */
|
|
208
|
-
parseMode: string | null;
|
|
209
|
-
/** Render context with formatting functions */
|
|
210
|
-
renderCtx: RenderContext;
|
|
211
|
-
/** Max characters for a single message */
|
|
212
|
-
limitChars: number;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// ==================== Event Pipeline Types ====================
|
|
216
|
-
|
|
217
|
-
/** Event types that update the transcript */
|
|
218
|
-
export const TRANSCRIPT_EVENT_TYPES = new Set<ParsedEventType>([
|
|
219
|
-
'thinking_start',
|
|
220
|
-
'thinking_delta',
|
|
221
|
-
'thinking_chunk',
|
|
222
|
-
'thinking_stop',
|
|
223
|
-
'text_start',
|
|
224
|
-
'text_delta',
|
|
225
|
-
'text_chunk',
|
|
226
|
-
'text_stop',
|
|
227
|
-
'tool_use_start',
|
|
228
|
-
'tool_use_delta',
|
|
229
|
-
'tool_use_stop',
|
|
230
|
-
'tool_use',
|
|
231
|
-
'tool_result',
|
|
232
|
-
'block_stop',
|
|
233
|
-
'error',
|
|
234
|
-
]);
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SkillLoader - SKILL.md 文件解析器
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import * as yaml from 'yaml';
|
|
8
|
-
import type { ParsedSkillFile, SkillFrontmatter } from './types.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
export function isValidSkillName(name: string): boolean {
|
|
15
|
-
if (!name || typeof name !== 'string') return false;
|
|
16
|
-
if (name.length < 1 || name.length > 64) return false;
|
|
17
|
-
return /^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(name);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
export function isValidDescription(description: string): boolean {
|
|
24
|
-
if (!description || typeof description !== 'string') return false;
|
|
25
|
-
return description.length <= 1024;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @param content - 文件内容
|
|
32
|
-
* @returns 解析后的 frontmatter 和 body
|
|
33
|
-
* @throws 如果格式无效或缺少必填字段
|
|
34
|
-
*/
|
|
35
|
-
export function parseSkillFile(content: string): ParsedSkillFile {
|
|
36
|
-
// 匹
|
|
37
|
-
const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
|
|
38
|
-
const match = content.match(frontmatterRegex);
|
|
39
|
-
|
|
40
|
-
if (!match) {
|
|
41
|
-
throw new Error('Invalid SKILL.md format: missing YAML frontmatter (must start with ---)');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const [, frontmatterStr, body] = match;
|
|
45
|
-
|
|
46
|
-
// 解
|
|
47
|
-
let frontmatter: SkillFrontmatter;
|
|
48
|
-
try {
|
|
49
|
-
frontmatter = yaml.parse(frontmatterStr);
|
|
50
|
-
} catch (error) {
|
|
51
|
-
throw new Error(`Invalid YAML in frontmatter: ${(error as Error).message}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// 验证必填字
|
|
55
|
-
if (!frontmatter.name || typeof frontmatter.name !== 'string') {
|
|
56
|
-
throw new Error('SKILL.md must have a "name" field');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (!isValidSkillName(frontmatter.name)) {
|
|
60
|
-
throw new Error(
|
|
61
|
-
`Invalid skill name "${frontmatter.name}": must be 1-64 characters, ` +
|
|
62
|
-
'lowercase letters, numbers, and hyphens only'
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// 验证必填字
|
|
67
|
-
if (!frontmatter.description || typeof frontmatter.description !== 'string') {
|
|
68
|
-
throw new Error('SKILL.md must have a "description" field');
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!isValidDescription(frontmatter.description)) {
|
|
72
|
-
throw new Error('Skill description must be 1024 characters or less');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// 验证可选字段类
|
|
76
|
-
if (frontmatter['allowed-tools'] !== undefined) {
|
|
77
|
-
if (!Array.isArray(frontmatter['allowed-tools'])) {
|
|
78
|
-
throw new Error('"allowed-tools" must be an array');
|
|
79
|
-
}
|
|
80
|
-
for (const tool of frontmatter['allowed-tools']) {
|
|
81
|
-
if (typeof tool !== 'string') {
|
|
82
|
-
throw new Error('"allowed-tools" must contain only strings');
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (frontmatter['user-invocable'] !== undefined) {
|
|
88
|
-
if (typeof frontmatter['user-invocable'] !== 'boolean') {
|
|
89
|
-
throw new Error('"user-invocable" must be a boolean');
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (frontmatter['disable-model-invocation'] !== undefined) {
|
|
94
|
-
if (typeof frontmatter['disable-model-invocation'] !== 'boolean') {
|
|
95
|
-
throw new Error('"disable-model-invocation" must be a boolean');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
frontmatter,
|
|
101
|
-
body: body.trim(),
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
*
|
|
107
|
-
*/
|
|
108
|
-
export function extractMetadataFields(frontmatter: SkillFrontmatter): {
|
|
109
|
-
allowedTools?: string[];
|
|
110
|
-
argumentHint?: string;
|
|
111
|
-
userInvocable: boolean;
|
|
112
|
-
disableModelInvocation: boolean;
|
|
113
|
-
model?: string;
|
|
114
|
-
whenToUse?: string;
|
|
115
|
-
version?: string;
|
|
116
|
-
} {
|
|
117
|
-
return {
|
|
118
|
-
allowedTools: frontmatter['allowed-tools'],
|
|
119
|
-
argumentHint: frontmatter['argument-hint'],
|
|
120
|
-
userInvocable: frontmatter['user-invocable'] ?? false,
|
|
121
|
-
disableModelInvocation: frontmatter['disable-model-invocation'] ?? false,
|
|
122
|
-
model: frontmatter.model,
|
|
123
|
-
whenToUse: frontmatter.when_to_use,
|
|
124
|
-
version: frontmatter.version,
|
|
125
|
-
};
|
|
126
|
-
}
|