aegiscode 3.1.8 → 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 +549 -552
  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,119 @@
1
+ /**
2
+ * CLI 中间件
3
+ *
4
+ *
5
+ * - 验证参数
6
+ * - 加载配置
7
+ * - 设置全局状态
8
+ */
9
+
10
+ import type { CliArguments } from './types.js';
11
+ import { configManager } from '../config/index.js';
12
+
13
+ /**
14
+ *
15
+ *
16
+ *
17
+ * 1. 处理 --yolo 快捷方式
18
+ * 2. 检测工具列表冲突
19
+ */
20
+ export const validatePermissions = (argv: CliArguments): void => {
21
+ // 1. 处理 --yolo 快捷方
22
+ if (argv.yolo) {
23
+ if (argv.permissionMode && argv.permissionMode !== 'yolo') {
24
+ throw new Error(
25
+ 'Cannot use both --yolo and --permission-mode with different values'
26
+ );
27
+ }
28
+ argv.permissionMode = 'yolo';
29
+ console.error('\x1b[33m⚠ YOLO MODE — Claude will execute ALL commands without confirmation. Use with caution.\x1b[0m');
30
+ }
31
+
32
+ // 2. 验证工具列表冲
33
+ if (Array.isArray(argv.allowedTools) && Array.isArray(argv.disallowedTools)) {
34
+ const allowedSet = new Set(argv.allowedTools);
35
+ const intersection = argv.disallowedTools.filter(tool => allowedSet.has(tool));
36
+
37
+ if (intersection.length > 0) {
38
+ throw new Error(
39
+ `Tools cannot be both allowed and disallowed: ${intersection.join(', ')}`
40
+ );
41
+ }
42
+ }
43
+ };
44
+
45
+ /**
46
+ *
47
+ *
48
+ *
49
+ * 1. 初始化 ConfigManager
50
+ * 2. 应用 CLI 参数
51
+ * 3. 验证会话选项
52
+ */
53
+ export const loadConfiguration = async (argv: CliArguments): Promise<void> => {
54
+ // 跳过 --init 命令的配置加
55
+ if (argv.init) {
56
+ return;
57
+ }
58
+
59
+ try {
60
+ // 1. 初始化 ConfigManager(加载配置文件 + 环境变
61
+ await configManager.initialize();
62
+
63
+ // 2. 应用 CLI 参数(最高优先
64
+ configManager.applyCliArgs({
65
+ apiKey: argv.apiKey,
66
+ baseURL: argv.baseUrl,
67
+ model: argv.model,
68
+ });
69
+
70
+ if (argv.debug) {
71
+ console.log('[CLI] Configuration loaded successfully');
72
+ const paths = configManager.getLoadedConfigPaths();
73
+ if (paths.length > 0) {
74
+ console.log('[CLI] Loaded config files:', paths);
75
+ }
76
+ }
77
+ } catch (error) {
78
+ console.error('❌ Failed to initialize configuration');
79
+ console.error(
80
+ 'Error:',
81
+ error instanceof Error ? error.message : 'Unknown error'
82
+ );
83
+ console.error('');
84
+ console.error('Please check:');
85
+ console.error(' 1. Config file format (~/.aegis/config.json)');
86
+ console.error(' 2. Run "aegis --init" to create default config');
87
+ console.error(' 3. Config file permissions');
88
+ process.exit(1);
89
+ }
90
+
91
+ // 3. 验证会话选
92
+ if (argv.continue && argv.resume) {
93
+ throw new Error('Cannot use both --continue and --resume flags');
94
+ }
95
+ };
96
+
97
+ /**
98
+ *
99
+ *
100
+ *
101
+ * 1. 验证输出格式组合
102
+ */
103
+ export const validateOutput = (argv: CliArguments): void => {
104
+ // 验证输出格式只能与 --print 一起使
105
+ if (argv.outputFormat && argv.outputFormat !== 'text' && !argv.print) {
106
+ throw new Error('--output-format can only be used with --print flag');
107
+ }
108
+ };
109
+
110
+ /**
111
+ *
112
+ *
113
+ */
114
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
+ export const middlewareChain: any[] = [
116
+ validatePermissions,
117
+ loadConfiguration,
118
+ validateOutput,
119
+ ];
@@ -0,0 +1,75 @@
1
+ /**
2
+ * CLI 类型定义
3
+ */
4
+
5
+ import type { Arguments } from 'yargs';
6
+
7
+ /**
8
+ *
9
+ */
10
+ export type PermissionMode = 'default' | 'autoEdit' | 'yolo';
11
+
12
+ /**
13
+ * UI 主题
14
+ */
15
+ export type ThemeName = 'default' | 'dark' | 'ocean' | 'forest' | 'sunset';
16
+
17
+ /**
18
+ * CLI 参数接口
19
+ */
20
+ export interface CliArguments extends Arguments {
21
+ // 调试选
22
+ debug?: boolean;
23
+
24
+ // AI 选
25
+ apiKey?: string;
26
+ baseUrl?: string;
27
+ model?: string;
28
+ maxTurns?: number;
29
+ router?: boolean;
30
+
31
+ // 安全选
32
+ permissionMode?: PermissionMode;
33
+ yolo?: boolean;
34
+ allowedTools?: string[];
35
+ disallowedTools?: string[];
36
+
37
+ // 会话选
38
+ continue?: boolean;
39
+ resume?: string | boolean;
40
+
41
+ // 输出选
42
+ print?: boolean;
43
+ outputFormat?: 'text' | 'json';
44
+
45
+ // UI 选
46
+ theme?: ThemeName;
47
+ plain?: boolean;
48
+
49
+ // 命令相
50
+ init?: boolean;
51
+
52
+ // 位置参数(初始消
53
+ message?: string;
54
+ }
55
+
56
+ /**
57
+ *
58
+ *
59
+ */
60
+ export type MiddlewareFunction<T = CliArguments> = (
61
+ argv: T
62
+ ) => void | Promise<void>;
63
+
64
+ /**
65
+ * App Props - 传递给 UI 组件的属性
66
+ */
67
+ export interface AppProps {
68
+ apiKey: string;
69
+ baseURL?: string;
70
+ model?: string;
71
+ initialMessage?: string;
72
+ debug?: boolean;
73
+ permissionMode?: PermissionMode;
74
+ resumeSessionId?: string;
75
+ }