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.
- package/bin/aegis-cli-linux-x64 +0 -0
- package/bin/cli.js +68 -0
- package/package.json +11 -48
- package/scripts/download-binary.mjs +155 -0
- 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
|
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.
|
|
4
|
-
"description": "
|
|
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": "./
|
|
9
|
-
"aegis-cli": "./
|
|
10
|
-
"aegis-gui": "./gui/run-gui.cjs"
|
|
7
|
+
"aegis": "./bin/cli.js",
|
|
8
|
+
"aegis-cli": "./bin/cli.js"
|
|
11
9
|
},
|
|
12
10
|
"scripts": {
|
|
13
|
-
"
|
|
11
|
+
"postinstall": "node scripts/download-binary.mjs",
|
|
12
|
+
"prepublishOnly": "node scripts/download-binary.mjs",
|
|
14
13
|
"build": "node esbuild.mjs",
|
|
15
|
-
"
|
|
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
|
-
"
|
|
53
|
-
"
|
|
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();
|