aegiscode 3.1.10 → 3.2.0

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 (209) hide show
  1. package/bin/aegis-cli-linux-x64 +0 -0
  2. package/bin/cli.js +68 -0
  3. package/package.json +11 -48
  4. package/scripts/download-binary.mjs +155 -0
  5. package/dist/main.js +0 -2171
  6. package/gui/run-gui.cjs +0 -13
  7. package/src/agent/Agent.ts +0 -903
  8. package/src/agent/SimpleAgent.ts +0 -48
  9. package/src/agent/index.ts +0 -54
  10. package/src/agent/orchestrator/AppBuilder.ts +0 -443
  11. package/src/agent/orchestrator/CouncilAgent.ts +0 -310
  12. package/src/agent/orchestrator/DiscussionRoom.ts +0 -462
  13. package/src/agent/orchestrator/OrchestratorAgent.ts +0 -637
  14. package/src/agent/orchestrator/index.ts +0 -38
  15. package/src/agent/orchestrator/utils.ts +0 -397
  16. package/src/agent/pricing.ts +0 -115
  17. package/src/agent/router.ts +0 -74
  18. package/src/agent/routerStats.ts +0 -121
  19. package/src/agent/types.ts +0 -318
  20. package/src/auth/login.ts +0 -383
  21. package/src/cli/config.ts +0 -189
  22. package/src/cli/index.ts +0 -17
  23. package/src/cli/middleware.ts +0 -119
  24. package/src/cli/types.ts +0 -75
  25. package/src/config/ConfigManager.ts +0 -587
  26. package/src/config/index.ts +0 -7
  27. package/src/config/types.ts +0 -584
  28. package/src/context/CompactionService.ts +0 -300
  29. package/src/context/ContextManager.ts +0 -450
  30. package/src/context/FileAnalyzer.ts +0 -267
  31. package/src/context/TokenCounter.ts +0 -265
  32. package/src/context/index.ts +0 -27
  33. package/src/context/storage/CacheStore.ts +0 -176
  34. package/src/context/storage/JSONLStore.ts +0 -201
  35. package/src/context/storage/MemoryStore.ts +0 -205
  36. package/src/context/storage/PersistentStore.ts +0 -327
  37. package/src/context/storage/index.ts +0 -9
  38. package/src/context/storage/pathUtils.ts +0 -114
  39. package/src/context/test.ts +0 -309
  40. package/src/context/types.ts +0 -268
  41. package/src/hooks/HookExecutor.ts +0 -434
  42. package/src/hooks/HookManager.ts +0 -596
  43. package/src/hooks/HookService.ts +0 -269
  44. package/src/hooks/Matcher.ts +0 -157
  45. package/src/hooks/index.ts +0 -63
  46. package/src/hooks/types.ts +0 -424
  47. package/src/main.tsx +0 -596
  48. package/src/mcp/HealthMonitor.ts +0 -150
  49. package/src/mcp/McpClient.ts +0 -491
  50. package/src/mcp/McpRegistry.ts +0 -321
  51. package/src/mcp/createMcpTool.ts +0 -251
  52. package/src/mcp/index.ts +0 -15
  53. package/src/mcp/server.ts +0 -334
  54. package/src/mcp/test-server.ts +0 -88
  55. package/src/mcp/test.ts +0 -372
  56. package/src/mcp/types.ts +0 -247
  57. package/src/memory/AgentMemoryBus.ts +0 -432
  58. package/src/memory/CloudSync.ts +0 -99
  59. package/src/memory/DriveSync.ts +0 -106
  60. package/src/memory/SharedMemory.ts +0 -951
  61. package/src/memory/index.ts +0 -14
  62. package/src/memory/machineFingerprint.ts +0 -40
  63. package/src/orchestrator/SubAgentMetadata.ts +0 -136
  64. package/src/prompts/builder.ts +0 -213
  65. package/src/prompts/default.ts +0 -144
  66. package/src/prompts/index.ts +0 -16
  67. package/src/prompts/plan.ts +0 -64
  68. package/src/prompts/test.ts +0 -78
  69. package/src/services/AnthropicChatService.ts +0 -341
  70. package/src/services/ChatService.ts +0 -347
  71. package/src/services/ClaudeCliChatService.ts +0 -256
  72. package/src/services/CloudSync.ts +0 -168
  73. package/src/services/CostLedger.ts +0 -211
  74. package/src/services/Heartbeat.ts +0 -135
  75. package/src/services/LearningCollector.ts +0 -291
  76. package/src/services/OllamaInstaller.ts +0 -342
  77. package/src/services/VersionChecker.ts +0 -445
  78. package/src/services/index.ts +0 -57
  79. package/src/services/streaming/OpenAIEventAdapter.ts +0 -126
  80. package/src/services/streaming/RenderingProfile.ts +0 -90
  81. package/src/services/streaming/StreamEventParser.ts +0 -181
  82. package/src/services/streaming/ThrottledRenderer.ts +0 -139
  83. package/src/services/streaming/TranscriptBuffer.ts +0 -574
  84. package/src/services/streaming/eventStatusMap.ts +0 -52
  85. package/src/services/streaming/index.ts +0 -46
  86. package/src/services/streaming/renderFormatting.ts +0 -79
  87. package/src/services/streaming/types.ts +0 -234
  88. package/src/skills/SkillLoader.ts +0 -126
  89. package/src/skills/SkillRegistry.ts +0 -366
  90. package/src/skills/index.ts +0 -48
  91. package/src/skills/types.ts +0 -146
  92. package/src/slash-commands/billing.ts +0 -70
  93. package/src/slash-commands/build.ts +0 -413
  94. package/src/slash-commands/builtinCommands.ts +0 -2733
  95. package/src/slash-commands/clone.ts +0 -242
  96. package/src/slash-commands/council.ts +0 -125
  97. package/src/slash-commands/custom/CustomCommandExecutor.ts +0 -143
  98. package/src/slash-commands/custom/CustomCommandLoader.ts +0 -251
  99. package/src/slash-commands/custom/CustomCommandRegistry.ts +0 -144
  100. package/src/slash-commands/custom/index.ts +0 -7
  101. package/src/slash-commands/debate.ts +0 -254
  102. package/src/slash-commands/gmail.ts +0 -105
  103. package/src/slash-commands/index.ts +0 -388
  104. package/src/slash-commands/mcpCommand.ts +0 -205
  105. package/src/slash-commands/types.ts +0 -201
  106. package/src/store/index.ts +0 -76
  107. package/src/store/selectors.ts +0 -246
  108. package/src/store/slices/appSlice.ts +0 -205
  109. package/src/store/slices/commandSlice.ts +0 -115
  110. package/src/store/slices/configSlice.ts +0 -46
  111. package/src/store/slices/focusSlice.ts +0 -64
  112. package/src/store/slices/index.ts +0 -9
  113. package/src/store/slices/sessionSlice.ts +0 -424
  114. package/src/store/streaming-buffer.ts +0 -425
  115. package/src/store/test.ts +0 -296
  116. package/src/store/types.ts +0 -274
  117. package/src/store/vanilla.ts +0 -186
  118. package/src/tools/builtin/bash.ts +0 -236
  119. package/src/tools/builtin/council.ts +0 -105
  120. package/src/tools/builtin/edit.ts +0 -213
  121. package/src/tools/builtin/glob.ts +0 -136
  122. package/src/tools/builtin/grep.ts +0 -263
  123. package/src/tools/builtin/index.ts +0 -61
  124. package/src/tools/builtin/memory.ts +0 -66
  125. package/src/tools/builtin/read.ts +0 -168
  126. package/src/tools/builtin/skill.ts +0 -97
  127. package/src/tools/builtin/snapshot.ts +0 -40
  128. package/src/tools/builtin/task.ts +0 -106
  129. package/src/tools/builtin/write.ts +0 -134
  130. package/src/tools/createTool.ts +0 -221
  131. package/src/tools/execution/ExecutionPipeline.ts +0 -263
  132. package/src/tools/execution/index.ts +0 -40
  133. package/src/tools/execution/stages/CacheStage.ts +0 -131
  134. package/src/tools/execution/stages/ConfirmationStage.ts +0 -203
  135. package/src/tools/execution/stages/DiscoveryStage.ts +0 -46
  136. package/src/tools/execution/stages/ExecutionStage.ts +0 -48
  137. package/src/tools/execution/stages/FormattingStage.ts +0 -44
  138. package/src/tools/execution/stages/HookStage.ts +0 -72
  139. package/src/tools/execution/stages/PermissionStage.ts +0 -287
  140. package/src/tools/execution/stages/PostHookStage.ts +0 -71
  141. package/src/tools/execution/stages/index.ts +0 -12
  142. package/src/tools/execution/test.ts +0 -266
  143. package/src/tools/execution/types.ts +0 -273
  144. package/src/tools/index.ts +0 -81
  145. package/src/tools/registry.ts +0 -304
  146. package/src/tools/schemas.ts +0 -109
  147. package/src/tools/test.ts +0 -220
  148. package/src/tools/types.ts +0 -175
  149. package/src/tools/validation/PermissionChecker.ts +0 -242
  150. package/src/tools/validation/SensitiveFileDetector.ts +0 -210
  151. package/src/tools/validation/index.ts +0 -11
  152. package/src/ui/App.tsx +0 -166
  153. package/src/ui/components/AegisInterface.tsx +0 -484
  154. package/src/ui/components/common/ChatSearch.tsx +0 -150
  155. package/src/ui/components/common/ErrorBoundary.tsx +0 -82
  156. package/src/ui/components/common/ExitMessage.tsx +0 -120
  157. package/src/ui/components/common/LoadingIndicator.tsx +0 -49
  158. package/src/ui/components/common/index.ts +0 -6
  159. package/src/ui/components/dialog/ConfirmationPrompt.tsx +0 -208
  160. package/src/ui/components/dialog/InteractiveSelector.tsx +0 -149
  161. package/src/ui/components/dialog/SetupWizard.tsx +0 -297
  162. package/src/ui/components/dialog/UpdatePrompt.tsx +0 -155
  163. package/src/ui/components/dialog/index.ts +0 -8
  164. package/src/ui/components/index.ts +0 -28
  165. package/src/ui/components/input/CommandSuggestions.tsx +0 -139
  166. package/src/ui/components/input/CustomTextInput.tsx +0 -220
  167. package/src/ui/components/input/InputArea.tsx +0 -361
  168. package/src/ui/components/input/PromptSuggestions.tsx +0 -66
  169. package/src/ui/components/input/index.ts +0 -6
  170. package/src/ui/components/layout/ChatStatusBar.tsx +0 -90
  171. package/src/ui/components/layout/ContextBar.tsx +0 -79
  172. package/src/ui/components/layout/MessageArea.tsx +0 -96
  173. package/src/ui/components/layout/MessageList.tsx +0 -647
  174. package/src/ui/components/layout/MessageSeparator.tsx +0 -26
  175. package/src/ui/components/layout/WelcomeMessage.tsx +0 -93
  176. package/src/ui/components/layout/index.ts +0 -7
  177. package/src/ui/components/markdown/CodeHighlighter.tsx +0 -292
  178. package/src/ui/components/markdown/MessageRenderer.tsx +0 -1211
  179. package/src/ui/components/markdown/index.ts +0 -8
  180. package/src/ui/components/markdown/parser.ts +0 -336
  181. package/src/ui/components/markdown/types.ts +0 -66
  182. package/src/ui/focus/FocusManager.ts +0 -137
  183. package/src/ui/focus/index.ts +0 -13
  184. package/src/ui/focus/types.ts +0 -54
  185. package/src/ui/focus/useFocus.ts +0 -75
  186. package/src/ui/hooks/index.ts +0 -11
  187. package/src/ui/hooks/useAgent.ts +0 -284
  188. package/src/ui/hooks/useCommandHistory.ts +0 -87
  189. package/src/ui/hooks/useCommandProcessor.ts +0 -443
  190. package/src/ui/hooks/useConfirmation.ts +0 -99
  191. package/src/ui/hooks/useCtrlCHandler.ts +0 -100
  192. package/src/ui/hooks/useInputBuffer.ts +0 -122
  193. package/src/ui/hooks/useTerminalSize.ts +0 -68
  194. package/src/ui/hooks/useTerminalWidth.ts +0 -5
  195. package/src/ui/hooks/useWindowedList.ts +0 -118
  196. package/src/ui/render-debugger.ts +0 -621
  197. package/src/ui/test.ts +0 -189
  198. package/src/ui/themes/ThemeManager.ts +0 -332
  199. package/src/ui/themes/aegisTheme.ts +0 -87
  200. package/src/ui/themes/darkTheme.ts +0 -87
  201. package/src/ui/themes/defaultTheme.ts +0 -85
  202. package/src/ui/themes/index.ts +0 -10
  203. package/src/ui/themes/lightTheme.ts +0 -89
  204. package/src/ui/themes/popularThemes.ts +0 -187
  205. package/src/ui/themes/types.ts +0 -130
  206. package/src/utils/clipboard.ts +0 -48
  207. package/src/utils/debug.ts +0 -43
  208. package/src/utils/environment.ts +0 -68
  209. package/src/utils/index.ts +0 -10
File without changes
package/bin/cli.js ADDED
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Thin entry-point for the aegis-cli binary.
4
+ *
5
+ * Detects the current platform, locates the matching binary downloaded by
6
+ * scripts/download-binary.mjs (postinstall), and spawns it with the same
7
+ * arguments and environment.
8
+ *
9
+ * This file is linked by npm as `aegis` and `aegis-cli` in PATH.
10
+ */
11
+
12
+ import { spawn } from 'child_process';
13
+ import { join, dirname } from 'path';
14
+ import { fileURLToPath } from 'url';
15
+ import { existsSync } from 'fs';
16
+
17
+ const __dirname = dirname(fileURLToPath(import.meta.url));
18
+ const BIN_DIR = join(__dirname);
19
+
20
+ // Must match PLATFORM_MAP in scripts/download-binary.mjs
21
+ const PLATFORM_MAP = {
22
+ 'linux-x64': 'aegis-cli-linux-x64',
23
+ 'linux-arm64': 'aegis-cli-linux-arm64',
24
+ 'darwin-x64': 'aegis-cli-darwin-x64',
25
+ 'darwin-arm64': 'aegis-cli-darwin-arm64',
26
+ 'win32-x64': 'aegis-cli-win-x64.exe',
27
+ };
28
+
29
+ const key = `${process.platform}-${process.arch}`;
30
+ const binaryName = PLATFORM_MAP[key];
31
+
32
+ if (!binaryName) {
33
+ console.error(`Unsupported platform: ${key}`);
34
+ console.error('See https://github.com/aegisinfo/aegiscode#readme for supported platforms');
35
+ process.exit(1);
36
+ }
37
+
38
+ const binaryPath = join(BIN_DIR, binaryName);
39
+
40
+ if (!existsSync(binaryPath)) {
41
+ console.error('');
42
+ console.error(`aegis-cli binary not found at: ${binaryPath}`);
43
+ console.error('');
44
+ console.error(' This usually means the postinstall script failed to download the binary.');
45
+ console.error(' Try reinstalling:');
46
+ console.error(' npm install -g aegiscode');
47
+ console.error('');
48
+ console.error(' Or download manually from:');
49
+ console.error(' https://github.com/aegisinfo/aegiscode/releases');
50
+ console.error(' and place the binary in:');
51
+ console.error(' ' + BIN_DIR);
52
+ console.error('');
53
+ process.exit(1);
54
+ }
55
+
56
+ const child = spawn(binaryPath, process.argv.slice(2), {
57
+ stdio: 'inherit',
58
+ env: { ...process.env },
59
+ });
60
+
61
+ child.on('exit', (code, signal) => {
62
+ process.exit(code ?? (signal ? 128 + signal : 1));
63
+ });
64
+
65
+ child.on('error', (err) => {
66
+ console.error(`Failed to launch aegis-cli: ${err.message}`);
67
+ process.exit(1);
68
+ });
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "aegiscode",
3
- "version": "3.1.10",
4
- "description": "A CLI Coding Agent inspired by Claude Code - An AI-powered coding assistant that can read, write, and execute code",
3
+ "version": "3.2.0",
4
+ "description": "AEGIS CLI AI-powered coding assistant. Downloads and runs the prebuilt aegis-cli binary.",
5
5
  "type": "module",
6
- "main": "dist/main.js",
7
6
  "bin": {
8
- "aegis": "./dist/main.js",
9
- "aegis-cli": "./dist/main.js",
10
- "aegis-gui": "./gui/run-gui.cjs"
7
+ "aegis": "./bin/cli.js",
8
+ "aegis-cli": "./bin/cli.js"
11
9
  },
12
10
  "scripts": {
13
- "dev": "NODE_NO_WARNINGS=1 tsx src/main.tsx",
11
+ "postinstall": "node scripts/download-binary.mjs",
12
+ "prepublishOnly": "node scripts/download-binary.mjs",
14
13
  "build": "node esbuild.mjs",
15
- "publish:release": "node esbuild.mjs",
14
+ "build:standalone": "bash build-standalone.sh",
15
+ "dev": "NODE_NO_WARNINGS=1 tsx src/main.tsx",
16
16
  "start": "node --no-deprecation dist/main.js",
17
17
  "typecheck": "tsc --noEmit",
18
18
  "test:prompts": "tsx src/prompts/test.ts",
@@ -20,10 +20,7 @@
20
20
  "test:pipeline": "tsx src/tools/execution/test.ts",
21
21
  "test:context": "tsx src/context/test.ts",
22
22
  "test:mcp": "tsx src/mcp/test.ts",
23
- "test:store": "tsx src/store/test.ts",
24
- "gui": "node ./gui/run-gui.cjs",
25
- "obfuscate": "echo '[obfuscate] SKIPPED — open source build does not obfuscate'",
26
- "prepublishOnly": "npm run build"
23
+ "test:store": "tsx src/store/test.ts"
27
24
  },
28
25
  "keywords": [
29
26
  "cli",
@@ -49,51 +46,17 @@
49
46
  "url": "https://github.com/aegisinfo/aegiscode/issues"
50
47
  },
51
48
  "files": [
52
- "dist/main.js",
53
- "gui/run-gui.cjs",
54
- "src/**/*",
49
+ "bin/",
50
+ "scripts/",
55
51
  "README.md",
56
52
  "LICENSE"
57
53
  ],
58
54
  "engines": {
59
55
  "node": ">=22.0.0"
60
56
  },
61
- "dependencies": {
62
- "@modelcontextprotocol/sdk": "^1.25.3",
63
- "@xenova/transformers": "^2.17.2",
64
- "chalk": "^5.4.1",
65
- "dotenv": "^17.4.2",
66
- "fuse.js": "^7.4.1",
67
- "glob": "^13.0.0",
68
- "ink": "^7.0.5",
69
- "ink-text-input": "^6.0.0",
70
- "js-tiktoken": "^1.0.21",
71
- "lowlight": "^3.3.0",
72
- "minimatch": "^10.1.1",
73
- "nanoid": "^5.1.6",
74
- "openai": "^4.77.0",
75
- "react": "^19.2.7",
76
- "react-dom": "^19.2.7",
77
- "sql.js": "^1.14.1",
78
- "string-width": "^8.1.1",
79
- "uuid": "^14.0.0",
80
- "yaml": "^2.8.2",
81
- "yargs": "^17.7.2",
82
- "zod": "^3.24.2",
83
- "zod-to-json-schema": "^3.25.1",
84
- "zustand": "^5.0.14"
85
- },
86
57
  "devDependencies": {
87
- "@types/minimatch": "^6.0.0",
88
58
  "@types/node": "^22.19.19",
89
- "@types/react": "^19.2.16",
90
- "@types/react-dom": "^19.2.3",
91
- "@types/sql.js": "^1.4.11",
92
- "@types/uuid": "^11.0.0",
93
- "@types/yargs": "^17.0.33",
94
- "electron": "^42.4.1",
95
59
  "esbuild": "^0.28.0",
96
- "react-devtools-core": "^7.0.1",
97
60
  "tsx": "^4.22.4",
98
61
  "typescript": "^5.7.2"
99
62
  }
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * postinstall script — downloads the prebuilt aegis-cli binary for the current platform.
4
+ * The binary is saved to <package>/bin/ and then spawned by bin/cli.js.
5
+ *
6
+ * Requires zero external dependencies (uses only Node.js built-ins).
7
+ *
8
+ * Binary source: GitHub releases
9
+ * https://github.com/aegisinfo/aegiscode/releases/latest/download/aegis-cli-{platform}-{arch}
10
+ */
11
+
12
+ import { createWriteStream, existsSync, chmodSync, mkdirSync } from 'fs';
13
+ import { get } from 'https';
14
+ import { join, dirname } from 'path';
15
+ import { fileURLToPath } from 'url';
16
+
17
+ const __dirname = dirname(fileURLToPath(import.meta.url));
18
+ const PACKAGE_ROOT = join(__dirname, '..');
19
+ const BIN_DIR = join(PACKAGE_ROOT, 'bin');
20
+
21
+ const BASE_URL =
22
+ 'https://github.com/aegisinfo/aegiscode/releases/latest/download';
23
+
24
+ // Maps Node.js process.platform + process.arch → GitHub release asset name
25
+ const PLATFORM_MAP = {
26
+ 'linux-x64': 'aegis-cli-linux-x64',
27
+ 'linux-arm64': 'aegis-cli-linux-arm64',
28
+ 'darwin-x64': 'aegis-cli-darwin-x64',
29
+ 'darwin-arm64': 'aegis-cli-darwin-arm64',
30
+ 'win32-x64': 'aegis-cli-win-x64.exe',
31
+ };
32
+
33
+ // Fallback URLs for platforms that don't have a dedicated binary yet
34
+ const FALLBACK_MAP = {
35
+ 'linux-arm': 'aegis-cli-linux-arm64',
36
+ 'darwin': 'aegis-cli-darwin-x64',
37
+ };
38
+
39
+ // ---------------------------------------------------------------------------
40
+ // Helpers
41
+ // ---------------------------------------------------------------------------
42
+
43
+ function detectBinaryName() {
44
+ const os = process.platform;
45
+ const arch = process.arch;
46
+ const key = `${os}-${arch}`;
47
+
48
+ if (PLATFORM_MAP[key]) return PLATFORM_MAP[key];
49
+
50
+ // Try fallback (e.g. linux-arm → linux-arm64 binary if close enough)
51
+ for (const [pattern, fallback] of Object.entries(FALLBACK_MAP)) {
52
+ if (key.startsWith(pattern)) return fallback;
53
+ }
54
+
55
+ throw new Error(
56
+ `Unsupported platform: ${key}\n` +
57
+ ` Supported: ${Object.keys(PLATFORM_MAP).join(', ')}\n` +
58
+ ` You can build from source: git clone https://github.com/aegisinfo/aegiscode && cd aegiscode && npm install && npm run build`
59
+ );
60
+ }
61
+
62
+ function downloadFile(url, dest) {
63
+ return new Promise((resolve, reject) => {
64
+ const file = createWriteStream(dest);
65
+ const req = get(url, (res) => {
66
+ // Follow redirect (GitHub releases redirect to S3)
67
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
68
+ file.close();
69
+ // Avoid file-exists check on redirect target — let the stream overwrite
70
+ downloadFile(res.headers.location, dest).then(resolve).catch(reject);
71
+ return;
72
+ }
73
+
74
+ if (res.statusCode !== 200) {
75
+ file.close();
76
+ // Try to collect error body
77
+ let body = '';
78
+ res.on('data', (chunk) => (body += chunk.toString()));
79
+ res.on('end', () => {
80
+ const detail = body.trim().slice(0, 200);
81
+ reject(
82
+ new Error(`HTTP ${res.statusCode} — ${detail || 'no body'}`)
83
+ );
84
+ });
85
+ return;
86
+ }
87
+
88
+ res.pipe(file);
89
+ file.on('finish', () => {
90
+ file.close();
91
+ resolve();
92
+ });
93
+ });
94
+
95
+ req.on('error', (err) => {
96
+ file.close();
97
+ // Attempt cleanup
98
+ try { file.close(); } catch { /* ignore */ }
99
+ reject(err);
100
+ });
101
+
102
+ req.setTimeout(60_000, () => {
103
+ req.destroy();
104
+ reject(new Error('Download timed out after 60s'));
105
+ });
106
+ });
107
+ }
108
+
109
+ // ---------------------------------------------------------------------------
110
+ // Main
111
+ // ---------------------------------------------------------------------------
112
+
113
+ async function main() {
114
+ const binaryName = detectBinaryName();
115
+ const url = `${BASE_URL}/${binaryName}`;
116
+ const dest = join(BIN_DIR, binaryName);
117
+
118
+ // Check if binary already exists (reinstall / postinstall after prepublish)
119
+ if (existsSync(dest)) {
120
+ console.log(`✓ aegis-cli already installed at ${dest}`);
121
+ chmodSync(dest, 0o755);
122
+ return;
123
+ }
124
+
125
+ console.log(`⬡ Downloading aegis-cli for ${process.platform}-${process.arch}...`);
126
+
127
+ mkdirSync(BIN_DIR, { recursive: true });
128
+
129
+ try {
130
+ await downloadFile(url, dest);
131
+ chmodSync(dest, 0o755);
132
+ console.log(`✓ aegis-cli installed to ${dest}`);
133
+ } catch (err) {
134
+ console.error('');
135
+ console.error(`⚠ Failed to download aegis-cli binary: ${err.message}`);
136
+ console.error('');
137
+ console.error(' Possible causes:');
138
+ console.error(' • No binary release for your platform yet');
139
+ console.error(' • No internet connectivity');
140
+ console.error(' • GitHub releases are unavailable');
141
+ console.error('');
142
+ console.error(' Options:');
143
+ console.error(' 1. Download manually from: https://github.com/aegisinfo/aegiscode/releases');
144
+ console.error(' and place the binary in: ' + BIN_DIR);
145
+ console.error(' 2. Build from source:');
146
+ console.error(' git clone https://github.com/aegisinfo/aegiscode');
147
+ console.error(' cd aegiscode && npm install && npm run build');
148
+ console.error(' 3. Install via installer script:');
149
+ console.error(' curl -fsSL https://dl.aegiscloud.org/install.sh | bash');
150
+ console.error('');
151
+ process.exit(1);
152
+ }
153
+ }
154
+
155
+ main();