aegiscode 3.1.7 → 3.1.10

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.
Files changed (206) hide show
  1. package/README.md +23 -15
  2. package/dist/main.js +555 -556
  3. package/package.json +4 -2
  4. package/src/agent/Agent.ts +903 -0
  5. package/src/agent/SimpleAgent.ts +48 -0
  6. package/src/agent/index.ts +54 -0
  7. package/src/agent/orchestrator/AppBuilder.ts +443 -0
  8. package/src/agent/orchestrator/CouncilAgent.ts +310 -0
  9. package/src/agent/orchestrator/DiscussionRoom.ts +462 -0
  10. package/src/agent/orchestrator/OrchestratorAgent.ts +637 -0
  11. package/src/agent/orchestrator/index.ts +38 -0
  12. package/src/agent/orchestrator/utils.ts +397 -0
  13. package/src/agent/pricing.ts +115 -0
  14. package/src/agent/router.ts +74 -0
  15. package/src/agent/routerStats.ts +121 -0
  16. package/src/agent/types.ts +318 -0
  17. package/src/auth/login.ts +383 -0
  18. package/src/cli/config.ts +189 -0
  19. package/src/cli/index.ts +17 -0
  20. package/src/cli/middleware.ts +119 -0
  21. package/src/cli/types.ts +75 -0
  22. package/src/config/ConfigManager.ts +587 -0
  23. package/src/config/index.ts +7 -0
  24. package/src/config/types.ts +584 -0
  25. package/src/context/CompactionService.ts +300 -0
  26. package/src/context/ContextManager.ts +450 -0
  27. package/src/context/FileAnalyzer.ts +267 -0
  28. package/src/context/TokenCounter.ts +265 -0
  29. package/src/context/index.ts +27 -0
  30. package/src/context/storage/CacheStore.ts +176 -0
  31. package/src/context/storage/JSONLStore.ts +201 -0
  32. package/src/context/storage/MemoryStore.ts +205 -0
  33. package/src/context/storage/PersistentStore.ts +327 -0
  34. package/src/context/storage/index.ts +9 -0
  35. package/src/context/storage/pathUtils.ts +114 -0
  36. package/src/context/test.ts +309 -0
  37. package/src/context/types.ts +268 -0
  38. package/src/hooks/HookExecutor.ts +434 -0
  39. package/src/hooks/HookManager.ts +596 -0
  40. package/src/hooks/HookService.ts +269 -0
  41. package/src/hooks/Matcher.ts +157 -0
  42. package/src/hooks/index.ts +63 -0
  43. package/src/hooks/types.ts +424 -0
  44. package/src/main.tsx +596 -0
  45. package/src/mcp/HealthMonitor.ts +150 -0
  46. package/src/mcp/McpClient.ts +491 -0
  47. package/src/mcp/McpRegistry.ts +321 -0
  48. package/src/mcp/createMcpTool.ts +251 -0
  49. package/src/mcp/index.ts +15 -0
  50. package/src/mcp/server.ts +334 -0
  51. package/src/mcp/test-server.ts +88 -0
  52. package/src/mcp/test.ts +372 -0
  53. package/src/mcp/types.ts +247 -0
  54. package/src/memory/AgentMemoryBus.ts +432 -0
  55. package/src/memory/CloudSync.ts +99 -0
  56. package/src/memory/DriveSync.ts +106 -0
  57. package/src/memory/SharedMemory.ts +951 -0
  58. package/src/memory/index.ts +14 -0
  59. package/src/memory/machineFingerprint.ts +40 -0
  60. package/src/orchestrator/SubAgentMetadata.ts +136 -0
  61. package/src/prompts/builder.ts +213 -0
  62. package/src/prompts/default.ts +144 -0
  63. package/src/prompts/index.ts +16 -0
  64. package/src/prompts/plan.ts +64 -0
  65. package/src/prompts/test.ts +78 -0
  66. package/src/services/AnthropicChatService.ts +341 -0
  67. package/src/services/ChatService.ts +347 -0
  68. package/src/services/ClaudeCliChatService.ts +256 -0
  69. package/src/services/CloudSync.ts +168 -0
  70. package/src/services/CostLedger.ts +211 -0
  71. package/src/services/Heartbeat.ts +135 -0
  72. package/src/services/LearningCollector.ts +291 -0
  73. package/src/services/OllamaInstaller.ts +342 -0
  74. package/src/services/VersionChecker.ts +445 -0
  75. package/src/services/index.ts +57 -0
  76. package/src/services/streaming/OpenAIEventAdapter.ts +126 -0
  77. package/src/services/streaming/RenderingProfile.ts +90 -0
  78. package/src/services/streaming/StreamEventParser.ts +181 -0
  79. package/src/services/streaming/ThrottledRenderer.ts +139 -0
  80. package/src/services/streaming/TranscriptBuffer.ts +574 -0
  81. package/src/services/streaming/eventStatusMap.ts +52 -0
  82. package/src/services/streaming/index.ts +46 -0
  83. package/src/services/streaming/renderFormatting.ts +79 -0
  84. package/src/services/streaming/types.ts +234 -0
  85. package/src/skills/SkillLoader.ts +126 -0
  86. package/src/skills/SkillRegistry.ts +366 -0
  87. package/src/skills/index.ts +48 -0
  88. package/src/skills/types.ts +146 -0
  89. package/src/slash-commands/billing.ts +70 -0
  90. package/src/slash-commands/build.ts +413 -0
  91. package/src/slash-commands/builtinCommands.ts +2733 -0
  92. package/src/slash-commands/clone.ts +242 -0
  93. package/src/slash-commands/council.ts +125 -0
  94. package/src/slash-commands/custom/CustomCommandExecutor.ts +143 -0
  95. package/src/slash-commands/custom/CustomCommandLoader.ts +251 -0
  96. package/src/slash-commands/custom/CustomCommandRegistry.ts +144 -0
  97. package/src/slash-commands/custom/index.ts +7 -0
  98. package/src/slash-commands/debate.ts +254 -0
  99. package/src/slash-commands/gmail.ts +105 -0
  100. package/src/slash-commands/index.ts +388 -0
  101. package/src/slash-commands/mcpCommand.ts +205 -0
  102. package/src/slash-commands/types.ts +201 -0
  103. package/src/store/index.ts +76 -0
  104. package/src/store/selectors.ts +246 -0
  105. package/src/store/slices/appSlice.ts +205 -0
  106. package/src/store/slices/commandSlice.ts +115 -0
  107. package/src/store/slices/configSlice.ts +46 -0
  108. package/src/store/slices/focusSlice.ts +64 -0
  109. package/src/store/slices/index.ts +9 -0
  110. package/src/store/slices/sessionSlice.ts +424 -0
  111. package/src/store/streaming-buffer.ts +425 -0
  112. package/src/store/test.ts +296 -0
  113. package/src/store/types.ts +274 -0
  114. package/src/store/vanilla.ts +186 -0
  115. package/src/tools/builtin/bash.ts +236 -0
  116. package/src/tools/builtin/council.ts +105 -0
  117. package/src/tools/builtin/edit.ts +213 -0
  118. package/src/tools/builtin/glob.ts +136 -0
  119. package/src/tools/builtin/grep.ts +263 -0
  120. package/src/tools/builtin/index.ts +61 -0
  121. package/src/tools/builtin/memory.ts +66 -0
  122. package/src/tools/builtin/read.ts +168 -0
  123. package/src/tools/builtin/skill.ts +97 -0
  124. package/src/tools/builtin/snapshot.ts +40 -0
  125. package/src/tools/builtin/task.ts +106 -0
  126. package/src/tools/builtin/write.ts +134 -0
  127. package/src/tools/createTool.ts +221 -0
  128. package/src/tools/execution/ExecutionPipeline.ts +263 -0
  129. package/src/tools/execution/index.ts +40 -0
  130. package/src/tools/execution/stages/CacheStage.ts +131 -0
  131. package/src/tools/execution/stages/ConfirmationStage.ts +203 -0
  132. package/src/tools/execution/stages/DiscoveryStage.ts +46 -0
  133. package/src/tools/execution/stages/ExecutionStage.ts +48 -0
  134. package/src/tools/execution/stages/FormattingStage.ts +44 -0
  135. package/src/tools/execution/stages/HookStage.ts +72 -0
  136. package/src/tools/execution/stages/PermissionStage.ts +287 -0
  137. package/src/tools/execution/stages/PostHookStage.ts +71 -0
  138. package/src/tools/execution/stages/index.ts +12 -0
  139. package/src/tools/execution/test.ts +266 -0
  140. package/src/tools/execution/types.ts +273 -0
  141. package/src/tools/index.ts +81 -0
  142. package/src/tools/registry.ts +304 -0
  143. package/src/tools/schemas.ts +109 -0
  144. package/src/tools/test.ts +220 -0
  145. package/src/tools/types.ts +175 -0
  146. package/src/tools/validation/PermissionChecker.ts +242 -0
  147. package/src/tools/validation/SensitiveFileDetector.ts +210 -0
  148. package/src/tools/validation/index.ts +11 -0
  149. package/src/ui/App.tsx +166 -0
  150. package/src/ui/components/AegisInterface.tsx +484 -0
  151. package/src/ui/components/common/ChatSearch.tsx +150 -0
  152. package/src/ui/components/common/ErrorBoundary.tsx +82 -0
  153. package/src/ui/components/common/ExitMessage.tsx +120 -0
  154. package/src/ui/components/common/LoadingIndicator.tsx +49 -0
  155. package/src/ui/components/common/index.ts +6 -0
  156. package/src/ui/components/dialog/ConfirmationPrompt.tsx +208 -0
  157. package/src/ui/components/dialog/InteractiveSelector.tsx +149 -0
  158. package/src/ui/components/dialog/SetupWizard.tsx +297 -0
  159. package/src/ui/components/dialog/UpdatePrompt.tsx +155 -0
  160. package/src/ui/components/dialog/index.ts +8 -0
  161. package/src/ui/components/index.ts +28 -0
  162. package/src/ui/components/input/CommandSuggestions.tsx +139 -0
  163. package/src/ui/components/input/CustomTextInput.tsx +220 -0
  164. package/src/ui/components/input/InputArea.tsx +361 -0
  165. package/src/ui/components/input/PromptSuggestions.tsx +66 -0
  166. package/src/ui/components/input/index.ts +6 -0
  167. package/src/ui/components/layout/ChatStatusBar.tsx +90 -0
  168. package/src/ui/components/layout/ContextBar.tsx +79 -0
  169. package/src/ui/components/layout/MessageArea.tsx +96 -0
  170. package/src/ui/components/layout/MessageList.tsx +647 -0
  171. package/src/ui/components/layout/MessageSeparator.tsx +26 -0
  172. package/src/ui/components/layout/WelcomeMessage.tsx +93 -0
  173. package/src/ui/components/layout/index.ts +7 -0
  174. package/src/ui/components/markdown/CodeHighlighter.tsx +292 -0
  175. package/src/ui/components/markdown/MessageRenderer.tsx +1211 -0
  176. package/src/ui/components/markdown/index.ts +8 -0
  177. package/src/ui/components/markdown/parser.ts +336 -0
  178. package/src/ui/components/markdown/types.ts +66 -0
  179. package/src/ui/focus/FocusManager.ts +137 -0
  180. package/src/ui/focus/index.ts +13 -0
  181. package/src/ui/focus/types.ts +54 -0
  182. package/src/ui/focus/useFocus.ts +75 -0
  183. package/src/ui/hooks/index.ts +11 -0
  184. package/src/ui/hooks/useAgent.ts +284 -0
  185. package/src/ui/hooks/useCommandHistory.ts +87 -0
  186. package/src/ui/hooks/useCommandProcessor.ts +443 -0
  187. package/src/ui/hooks/useConfirmation.ts +99 -0
  188. package/src/ui/hooks/useCtrlCHandler.ts +100 -0
  189. package/src/ui/hooks/useInputBuffer.ts +122 -0
  190. package/src/ui/hooks/useTerminalSize.ts +68 -0
  191. package/src/ui/hooks/useTerminalWidth.ts +5 -0
  192. package/src/ui/hooks/useWindowedList.ts +118 -0
  193. package/src/ui/render-debugger.ts +621 -0
  194. package/src/ui/test.ts +189 -0
  195. package/src/ui/themes/ThemeManager.ts +332 -0
  196. package/src/ui/themes/aegisTheme.ts +87 -0
  197. package/src/ui/themes/darkTheme.ts +87 -0
  198. package/src/ui/themes/defaultTheme.ts +85 -0
  199. package/src/ui/themes/index.ts +10 -0
  200. package/src/ui/themes/lightTheme.ts +89 -0
  201. package/src/ui/themes/popularThemes.ts +187 -0
  202. package/src/ui/themes/types.ts +130 -0
  203. package/src/utils/clipboard.ts +48 -0
  204. package/src/utils/debug.ts +43 -0
  205. package/src/utils/environment.ts +68 -0
  206. package/src/utils/index.ts +10 -0
@@ -0,0 +1,85 @@
1
+ import type { Theme, BaseColors, Spacing } from './types.js';
2
+
3
+ const aegisColors: BaseColors = {
4
+ primary: '#00e5c0', // ÆGIS teal
5
+ secondary: '#7c6fd4', // purple
6
+ accent: '#00e5c0',
7
+ success: '#22c55e',
8
+ warning: '#f59e0b',
9
+ error: '#ef4444',
10
+ info: '#00e5c0',
11
+ text: {
12
+ primary: '#e8e6f4',
13
+ secondary: '#8882a4',
14
+ muted: '#44405a',
15
+ light: '#e8e6f4',
16
+ },
17
+ background: {
18
+ primary: '#04040c',
19
+ secondary: '#181828',
20
+ dark: '#0c0c16',
21
+ },
22
+ border: {
23
+ light: '#1a1a2a',
24
+ dark: '#1a1a2a',
25
+ },
26
+ syntax: {
27
+ keyword: '#00e5c0',
28
+ string: '#7c6fd4',
29
+ number: '#f59e0b',
30
+ comment: '#44405a',
31
+ function: '#f472b6',
32
+ variable: '#e8e6f4',
33
+ operator: '#89DDFF',
34
+ type: '#FFCB6B',
35
+ tag: '#F07178',
36
+ attr: '#C3E88D',
37
+ default: '#A6ACCD',
38
+ },
39
+ };
40
+
41
+ const spacing: Spacing = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4 };
42
+
43
+ const tokens = {
44
+ elevation: {
45
+ flat: 'rgba(0,0,0,0)',
46
+ raised: 'rgba(0, 229, 192, 0.08)',
47
+ overlay: 'rgba(0, 0, 0, 0.4)',
48
+ sticky: 'rgba(0, 229, 192, 0.12)',
49
+ },
50
+ radius: {
51
+ sm: 0,
52
+ md: 1,
53
+ lg: 2,
54
+ full: 0,
55
+ },
56
+ animation: {
57
+ fast: 80,
58
+ normal: 150,
59
+ slow: 300,
60
+ easing: 'ease-out',
61
+ },
62
+ semantic: {
63
+ interactive: {
64
+ idle: aegisColors.primary,
65
+ hover: '#33ffd9',
66
+ active: '#00bfa0',
67
+ disabled: '#44405a',
68
+ },
69
+ focus: {
70
+ ring: '#00e5c0',
71
+ glow: 'rgba(0, 229, 192, 0.3)',
72
+ },
73
+ code: {
74
+ background: '#08080f',
75
+ border: '#1a1a2a',
76
+ },
77
+ },
78
+ };
79
+
80
+ export const defaultTheme: Theme = {
81
+ name: 'default',
82
+ colors: aegisColors,
83
+ spacing,
84
+ tokens,
85
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ *
3
+ */
4
+
5
+ export * from './types.js';
6
+ export { defaultTheme } from './defaultTheme.js';
7
+ export { darkTheme } from './darkTheme.js';
8
+ export { lightTheme } from './lightTheme.js';
9
+ export { ThemeManager, themeManager } from './ThemeManager.js';
10
+ export { aegisTheme } from './aegisTheme.js';
@@ -0,0 +1,89 @@
1
+ /**
2
+ *
3
+ *
4
+ */
5
+
6
+ import type { Theme } from './types.js';
7
+ import { defaultTheme } from './defaultTheme.js';
8
+
9
+ const lightTokens = {
10
+ elevation: {
11
+ flat: 'rgba(0,0,0,0)',
12
+ raised: 'rgba(37, 99, 235, 0.06)',
13
+ overlay: 'rgba(0, 0, 0, 0.15)',
14
+ sticky: 'rgba(37, 99, 235, 0.1)',
15
+ },
16
+ radius: {
17
+ sm: 0,
18
+ md: 1,
19
+ lg: 2,
20
+ full: 0,
21
+ },
22
+ animation: {
23
+ fast: 80,
24
+ normal: 150,
25
+ slow: 300,
26
+ easing: 'ease-out',
27
+ },
28
+ semantic: {
29
+ interactive: {
30
+ idle: '#2563eb',
31
+ hover: '#1d4ed8',
32
+ active: '#1e40af',
33
+ disabled: '#9ca3af',
34
+ },
35
+ focus: {
36
+ ring: '#2563eb',
37
+ glow: 'rgba(37, 99, 235, 0.25)',
38
+ },
39
+ code: {
40
+ background: '#f9fafb',
41
+ border: '#d1d5db',
42
+ },
43
+ },
44
+ };
45
+
46
+ export const lightTheme: Theme = {
47
+ ...defaultTheme,
48
+ name: 'light',
49
+ tokens: lightTokens,
50
+ colors: {
51
+ ...defaultTheme.colors,
52
+ // 使用更深的颜色确保对比
53
+ primary: '#2563eb', // blue-600
54
+ secondary: '#4f46e5', // indigo-600
55
+ accent: '#7c3aed', // violet-600
56
+ success: '#16a34a', // green-600
57
+ warning: '#d97706', // amber-600
58
+ error: '#dc2626', // red-600
59
+ info: '#0891b2', // cyan-600
60
+ text: {
61
+ primary: '#111827', // gray-900 - 最深的文
62
+ secondary: '#374151', // gray-700
63
+ muted: '#6b7280', // gray-500
64
+ light: '#f9fafb', // gray-50
65
+ },
66
+ background: {
67
+ primary: '#ffffff',
68
+ secondary: '#e5e7eb', // gray-200
69
+ dark: '#111827', // gray-900
70
+ },
71
+ border: {
72
+ light: '#d1d5db', // gray-300
73
+ dark: '#6b7280', // gray-500
74
+ },
75
+ syntax: {
76
+ comment: '#6b7280', // gray-500
77
+ string: '#047857', // emerald-700
78
+ number: '#be185d', // pink-700
79
+ keyword: '#6d28d9', // violet-700
80
+ function: '#1d4ed8', // blue-700
81
+ variable: '#111827', // gray-900
82
+ operator: '#b45309', // amber-700
83
+ type: '#0e7490', // cyan-700
84
+ tag: '#b91c1c', // red-700
85
+ attr: '#a16207', // yellow-700
86
+ default: '#111827', // gray-900
87
+ },
88
+ },
89
+ };
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Popular themes: Dracula, Nord, Tokyo Night, Catppuccin
3
+ */
4
+
5
+ import type { Theme, BaseColors, Spacing } from './types.js';
6
+
7
+ const defaultSpacing: Spacing = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4 };
8
+
9
+ // ─── Dracula ───────────────────────────────────────────────
10
+ const draculaColors: BaseColors = {
11
+ primary: '#bd93f9', // purple
12
+ secondary: '#ff79c6', // pink
13
+ accent: '#50fa7b', // green
14
+ success: '#50fa7b',
15
+ warning: '#f1fa8c',
16
+ error: '#ff5555',
17
+ info: '#8be9fd',
18
+ text: {
19
+ primary: '#f8f8f2',
20
+ secondary: '#e9e9f0',
21
+ muted: '#6272a4',
22
+ light: '#f8f8f2',
23
+ },
24
+ background: {
25
+ primary: '#282a36',
26
+ secondary: '#44475a',
27
+ dark: '#21222c',
28
+ },
29
+ border: {
30
+ light: '#44475a',
31
+ dark: '#21222c',
32
+ },
33
+ syntax: {
34
+ keyword: '#ff79c6',
35
+ string: '#f1fa8c',
36
+ number: '#bd93f9',
37
+ comment: '#6272a4',
38
+ function: '#50fa7b',
39
+ variable: '#f8f8f2',
40
+ operator: '#ff79c6',
41
+ type: '#8be9fd',
42
+ tag: '#ff5555',
43
+ attr: '#50fa7b',
44
+ default: '#f8f8f2',
45
+ },
46
+ };
47
+
48
+ export const draculaTheme: Theme = {
49
+ name: 'dracula',
50
+ colors: draculaColors,
51
+ spacing: defaultSpacing,
52
+ };
53
+
54
+ // ─── Nord ──────────────────────────────────────────────────
55
+ const nordColors: BaseColors = {
56
+ primary: '#88c0d0', // frost
57
+ secondary: '#81a1c1', // frost
58
+ accent: '#a3be8c', // green
59
+ success: '#a3be8c',
60
+ warning: '#ebcb8b',
61
+ error: '#bf616a',
62
+ info: '#88c0d0',
63
+ text: {
64
+ primary: '#eceff4',
65
+ secondary: '#e5e9f0',
66
+ muted: '#616e88',
67
+ light: '#eceff4',
68
+ },
69
+ background: {
70
+ primary: '#2e3440',
71
+ secondary: '#3b4252',
72
+ dark: '#242933',
73
+ },
74
+ border: {
75
+ light: '#4c566a',
76
+ dark: '#2e3440',
77
+ },
78
+ syntax: {
79
+ keyword: '#81a1c1',
80
+ string: '#a3be8c',
81
+ number: '#b48ead',
82
+ comment: '#616e88',
83
+ function: '#88c0d0',
84
+ variable: '#d8dee9',
85
+ operator: '#81a1c1',
86
+ type: '#8fbcbb',
87
+ tag: '#bf616a',
88
+ attr: '#a3be8c',
89
+ default: '#eceff4',
90
+ },
91
+ };
92
+
93
+ export const nordTheme: Theme = {
94
+ name: 'nord',
95
+ colors: nordColors,
96
+ spacing: defaultSpacing,
97
+ };
98
+
99
+ // ─── Tokyo Night ───────────────────────────────────────────
100
+ const tokyoNightColors: BaseColors = {
101
+ primary: '#7aa2f7', // blue
102
+ secondary: '#bb9af7', // purple
103
+ accent: '#7dcfff', // cyan
104
+ success: '#9ece6a',
105
+ warning: '#e0af68',
106
+ error: '#f7768e',
107
+ info: '#7dcfff',
108
+ text: {
109
+ primary: '#c0caf5',
110
+ secondary: '#a9b1d6',
111
+ muted: '#565f89',
112
+ light: '#c0caf5',
113
+ },
114
+ background: {
115
+ primary: '#1a1b26',
116
+ secondary: '#24283b',
117
+ dark: '#0f0f17',
118
+ },
119
+ border: {
120
+ light: '#3b4261',
121
+ dark: '#1a1b26',
122
+ },
123
+ syntax: {
124
+ keyword: '#bb9af7',
125
+ string: '#9ece6a',
126
+ number: '#ff9e64',
127
+ comment: '#565f89',
128
+ function: '#7aa2f7',
129
+ variable: '#c0caf5',
130
+ operator: '#89DDFF',
131
+ type: '#ff9e64',
132
+ tag: '#f7768e',
133
+ attr: '#9ece6a',
134
+ default: '#c0caf5',
135
+ },
136
+ };
137
+
138
+ export const tokyoNightTheme: Theme = {
139
+ name: 'tokyo-night',
140
+ colors: tokyoNightColors,
141
+ spacing: defaultSpacing,
142
+ };
143
+
144
+ // ─── Catppuccin Mocha ──────────────────────────────────────
145
+ const catppuccinColors: BaseColors = {
146
+ primary: '#89b4fa', // blue
147
+ secondary: '#cba6f7', // mauve
148
+ accent: '#a6e3a1', // green
149
+ success: '#a6e3a1',
150
+ warning: '#f9e2af',
151
+ error: '#f38ba8',
152
+ info: '#89dceb',
153
+ text: {
154
+ primary: '#cdd6f4',
155
+ secondary: '#bac2de',
156
+ muted: '#6c7086',
157
+ light: '#cdd6f4',
158
+ },
159
+ background: {
160
+ primary: '#1e1e2e',
161
+ secondary: '#313244',
162
+ dark: '#181825',
163
+ },
164
+ border: {
165
+ light: '#45475a',
166
+ dark: '#1e1e2e',
167
+ },
168
+ syntax: {
169
+ keyword: '#cba6f7',
170
+ string: '#a6e3a1',
171
+ number: '#fab387',
172
+ comment: '#6c7086',
173
+ function: '#89b4fa',
174
+ variable: '#cdd6f4',
175
+ operator: '#89dceb',
176
+ type: '#f9e2af',
177
+ tag: '#f38ba8',
178
+ attr: '#a6e3a1',
179
+ default: '#cdd6f4',
180
+ },
181
+ };
182
+
183
+ export const catppuccinTheme: Theme = {
184
+ name: 'catppuccin',
185
+ colors: catppuccinColors,
186
+ spacing: defaultSpacing,
187
+ };
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Theme type definitions
3
+ *
4
+ * Extended with design tokens for consistent spacing, elevation, and semantic colors.
5
+ */
6
+
7
+ export type ColorMode = 'dark' | 'light' | 'unknown';
8
+
9
+ export interface SyntaxColors {
10
+ comment: string;
11
+ string: string;
12
+ number: string;
13
+ keyword: string;
14
+ function: string;
15
+ variable: string;
16
+ operator: string;
17
+ type: string;
18
+ tag: string;
19
+ attr: string;
20
+ default: string;
21
+ }
22
+
23
+ export interface BaseColors {
24
+ primary: string;
25
+ secondary: string;
26
+ accent: string;
27
+ success: string;
28
+ warning: string;
29
+ error: string;
30
+ info: string;
31
+ text: {
32
+ primary: string;
33
+ secondary: string;
34
+ muted: string;
35
+ light: string;
36
+ };
37
+ background: {
38
+ primary: string;
39
+ secondary: string;
40
+ dark: string;
41
+ };
42
+ border: {
43
+ light: string;
44
+ dark: string;
45
+ };
46
+ syntax: SyntaxColors;
47
+ }
48
+
49
+ export interface Spacing {
50
+ xs: number;
51
+ sm: number;
52
+ md: number;
53
+ lg: number;
54
+ xl: number;
55
+ }
56
+
57
+ // ========== Design Tokens (new) ==========
58
+
59
+ /** Elevation / shadow depth for panels, modals, overlays */
60
+ export interface ElevationTokens {
61
+ flat: string; // No elevation (background surface)
62
+ raised: string; // Cards, panels
63
+ overlay: string; // Modals, dialogs
64
+ sticky: string; // Status bars, headers that should stand out
65
+ }
66
+
67
+ /** Border radius tokens */
68
+ export interface RadiusTokens {
69
+ sm: number;
70
+ md: number;
71
+ lg: number;
72
+ full: number;
73
+ }
74
+
75
+ /** Animation / transition tokens */
76
+ export interface AnimationTokens {
77
+ fast: number; // ms — hover, micro-interactions
78
+ normal: number; // ms — standard transitions
79
+ slow: number; // ms — page/appear transitions
80
+ easing: string; // CSS easing function name or cubic-bezier
81
+ }
82
+
83
+ /** Semantic color roles */
84
+ export interface SemanticTokens {
85
+ /** Interactive element states */
86
+ interactive: {
87
+ idle: string;
88
+ hover: string;
89
+ active: string;
90
+ disabled: string;
91
+ };
92
+ /** Focus ring */
93
+ focus: {
94
+ ring: string;
95
+ glow: string;
96
+ };
97
+ /** Code block styling */
98
+ code: {
99
+ background: string;
100
+ border: string;
101
+ };
102
+ }
103
+
104
+ export interface DesignTokens {
105
+ elevation: ElevationTokens;
106
+ radius: RadiusTokens;
107
+ animation: AnimationTokens;
108
+ semantic: SemanticTokens;
109
+ }
110
+
111
+ export interface Theme {
112
+ name: string;
113
+ colors: BaseColors;
114
+ spacing: Spacing;
115
+ /** Optional design tokens for fine-grained UI control */
116
+ tokens?: DesignTokens;
117
+ }
118
+
119
+ export interface RoleStyle {
120
+ color: string;
121
+ prefix: string;
122
+ bold?: boolean;
123
+ }
124
+
125
+ export interface ThemePreset {
126
+ id: string;
127
+ name: string;
128
+ description?: string;
129
+ theme: Theme;
130
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Clipboard helper with an OSC 52 fallback.
3
+ *
4
+ * Native tools (pbcopy/xclip/xsel/clip) require a desktop clipboard and,
5
+ * on Linux, an X11/Wayland display — neither is available over plain SSH
6
+ * or on minimal/headless installs. OSC 52 asks the terminal emulator
7
+ * itself to set the clipboard and works in that case too (most modern
8
+ * terminals support it, including over SSH and inside tmux/screen).
9
+ */
10
+ export async function copyToClipboard(text: string): Promise<void> {
11
+ const { execSync } = await import('child_process');
12
+ const platform = process.platform;
13
+
14
+ try {
15
+ if (platform === 'darwin') {
16
+ execSync('pbcopy', { input: text });
17
+ return;
18
+ }
19
+ if (platform === 'win32') {
20
+ execSync('clip', { input: text });
21
+ return;
22
+ }
23
+ if (platform === 'linux') {
24
+ try {
25
+ execSync('xclip -selection clipboard', { input: text });
26
+ return;
27
+ } catch {
28
+ execSync('xsel --clipboard --input', { input: text });
29
+ return;
30
+ }
31
+ }
32
+ } catch {
33
+ // Fall through to the OSC 52 escape sequence below.
34
+ }
35
+
36
+ writeOsc52(text);
37
+ }
38
+
39
+ function writeOsc52(text: string): void {
40
+ const base64 = Buffer.from(text, 'utf8').toString('base64');
41
+ // Wrap in tmux passthrough so it reaches the outer terminal when running
42
+ // inside tmux, where OSC 52 would otherwise be swallowed by tmux itself.
43
+ const sequence = `\x1b]52;c;${base64}\x07`;
44
+ const payload = process.env.TMUX
45
+ ? `\x1bPtmux;\x1b${sequence}\x1b\\`
46
+ : sequence;
47
+ process.stdout.write(payload);
48
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Debug 日志工具
3
+ *
4
+ *
5
+ */
6
+
7
+ /** 设置全局 debug 状态(由 main.tsx parseDebugEarly 调用) */
8
+ export function setGlobalDebug(enabled: boolean): void {
9
+ (globalThis as any).__AEGIS_DEBUG__ = enabled;
10
+ }
11
+
12
+ /** 获取全局 debug 状态 */
13
+ export function isDebugEnabled(): boolean {
14
+ return (globalThis as any).__AEGIS_DEBUG__ === true;
15
+ }
16
+
17
+ /**
18
+ *
19
+ */
20
+ export function createDebugLogger(prefix: string) {
21
+ return {
22
+ log: (...args: unknown[]) => {
23
+ if (isDebugEnabled()) {
24
+ console.log(`[${prefix}]`, ...args);
25
+ }
26
+ },
27
+ warn: (...args: unknown[]) => {
28
+ if (isDebugEnabled()) {
29
+ console.warn(`[${prefix}]`, ...args);
30
+ }
31
+ },
32
+ error: (...args: unknown[]) => {
33
+ // 错误始终输
34
+ console.error(`[${prefix}]`, ...args);
35
+ },
36
+ };
37
+ }
38
+
39
+ // 预定义
40
+ export const agentDebug = createDebugLogger('Agent');
41
+ export const mcpDebug = createDebugLogger('MCP');
42
+ export const mcpClientDebug = (name: string) => createDebugLogger(`McpClient:${name}`);
43
+ export const mcpRegistryDebug = createDebugLogger('McpRegistry');
@@ -0,0 +1,68 @@
1
+ /**
2
+ *
3
+ *
4
+ *
5
+ */
6
+
7
+ import os from 'os';
8
+
9
+ /**
10
+ *
11
+ */
12
+ export interface EnvironmentInfo {
13
+ workingDirectory: string;
14
+ homeDirectory: string;
15
+ platform: string;
16
+ nodeVersion: string;
17
+ currentDate: string;
18
+ shell: string;
19
+ username: string;
20
+ }
21
+
22
+ /**
23
+ *
24
+ */
25
+ export function getEnvironmentInfo(): EnvironmentInfo {
26
+ return {
27
+ workingDirectory: process.cwd(),
28
+ homeDirectory: os.homedir(),
29
+ platform: `${os.platform()} ${os.release()}`,
30
+ nodeVersion: process.version,
31
+ currentDate: new Date().toLocaleDateString('zh-CN', {
32
+ year: 'numeric',
33
+ month: 'long',
34
+ day: 'numeric',
35
+ weekday: 'long',
36
+ }),
37
+ shell: process.env.SHELL || 'unknown',
38
+ username: (() => { try { return os.userInfo().username; } catch { return process.env.USER || 'user'; } })(),
39
+ };
40
+ }
41
+
42
+ /**
43
+ *
44
+ *
45
+ *
46
+ */
47
+ export function getEnvironmentContext(): string {
48
+ const env = getEnvironmentInfo();
49
+
50
+ return `# Environment Context
51
+
52
+ ## Working Directory
53
+ **Current**: \`${env.workingDirectory}\`
54
+ **Home**: \`${env.homeDirectory}\`
55
+
56
+ ## System Information
57
+ - **Platform**: ${env.platform}
58
+ - **Node.js**: ${env.nodeVersion}
59
+ - **Shell**: ${env.shell}
60
+ - **Date**: ${env.currentDate}
61
+
62
+ ## File Path Guidelines
63
+ When using file tools, provide **absolute paths**:
64
+ - ✅ Correct: \`${env.workingDirectory}/package.json\`
65
+ - ❌ Incorrect: \`package.json\` (relative path)
66
+
67
+ The working directory is the root for all relative references.`;
68
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Utils 模块导出
3
+ */
4
+
5
+ export {
6
+ getEnvironmentInfo,
7
+ getEnvironmentContext,
8
+ } from './environment.js';
9
+
10
+ export type { EnvironmentInfo } from './environment.js';