Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
cyxcode/install at add-error-stack · code3hr/cyxcode · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
code3hr
/
cyxcode
Public
forked from
anomalyco/opencode
Notifications
You must be signed in to change notification settings
Fork
1
Star
19
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
add-error-stack
Breadcrumbs
cyxcode
/
install
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
188 lines (160 loc) · 5.12 KB
add-error-stack
Breadcrumbs
cyxcode
/
install
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
188 lines (160 loc) · 5.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!
/usr/bin/env bash
set
-euo pipefail
APP=opencode
RED=
'
\033[0;31m
'
GREEN=
'
\033[0;32m
'
YELLOW=
'
\033[1;33m
'
ORANGE=
'
\033[38;2;255;140;0m
'
NC=
'
\033[0m
'
#
No Color
requested_version=
${VERSION
:-
}
os=
$(
uname -s
|
tr
'
[:upper:]
'
'
[:lower:]
'
)
if
[[
"
$os
"
==
"
darwin
"
]]
;
then
os=
"
darwin
"
fi
arch=
$(
uname -m
)
if
[[
"
$arch
"
==
"
aarch64
"
]]
;
then
arch=
"
arm64
"
elif
[[
"
$arch
"
==
"
x86_64
"
]]
;
then
arch=
"
x64
"
fi
filename=
"
$APP
-
$os
-
$arch
.zip
"
case
"
$filename
"
in
*
"
-linux-
"
*
)
[[
"
$arch
"
==
"
x64
"
||
"
$arch
"
==
"
arm64
"
]]
||
exit
1
;;
*
"
-darwin-
"
*
)
[[
"
$arch
"
==
"
x64
"
||
"
$arch
"
==
"
arm64
"
]]
||
exit
1
;;
*
"
-windows-
"
*
)
[[
"
$arch
"
==
"
x64
"
]]
||
exit
1
;;
*
)
echo
-e
"
${RED}
Unsupported OS/Arch:
$os
/
$arch
${NC}
"
exit
1
;;
esac
INSTALL_DIR=
$HOME
/.opencode/bin
mkdir -p
"
$INSTALL_DIR
"
if
[
-z
"
$requested_version
"
]
;
then
url=
"
https://github.com/sst/opencode/releases/latest/download/
$filename
"
specific_version=
$(
curl -s https://api.github.com/repos/sst/opencode/releases/latest
|
awk -F
'
"
'
'
/"tag_name": "/ {gsub(/^v/, "", $4); print $4}
'
)
if
[[
$?
-ne
0
||
-z
"
$specific_version
"
]]
;
then
echo
-e
"
${RED}
Failed to fetch version information
${NC}
"
exit
1
fi
else
url=
"
https://github.com/sst/opencode/releases/download/v
${requested_version}
/
$filename
"
specific_version=
$requested_version
fi
print_message
() {
local
level=
$1
local
message=
$2
local
color=
"
"
case
$level
in
info) color=
"
${GREEN}
"
;;
warning) color=
"
${YELLOW}
"
;;
error) color=
"
${RED}
"
;;
esac
echo
-e
"
${color}${message}${NC}
"
}
check_version
() {
if
command
-v opencode
>
/dev/null
2>&1
;
then
opencode_path=
$(
which opencode
)
#
# TODO: check if version is installed
#
installed_version=$(opencode version)
installed_version=
"
0.0.1
"
installed_version=
$(
echo
$installed_version
|
awk
'
{print $2}
'
)
if
[[
"
$installed_version
"
!=
"
$specific_version
"
]]
;
then
print_message info
"
Installed version:
${YELLOW}
$installed_version
.
"
else
print_message info
"
Version
${YELLOW}
$specific_version
${GREEN}
already installed
"
exit
0
fi
fi
}
download_and_install
() {
print_message info
"
Downloading
${ORANGE}
opencode
${GREEN}
version:
${YELLOW}
$specific_version
${GREEN}
...
"
mkdir -p opencodetmp
&&
cd
opencodetmp
curl -# -L -o
"
$filename
"
"
$url
"
unzip -q
"
$filename
"
mv opencode
"
$INSTALL_DIR
"
cd
..
&&
rm -rf opencodetmp
}
check_version
download_and_install
add_to_path
() {
local
config_file=
$1
local
command=
$2
if
grep -Fxq
"
$command
"
"
$config_file
"
;
then
print_message info
"
Command already exists in
$config_file
, skipping write.
"
elif
[[
-w
$config_file
]]
;
then
echo
-e
"
\n# opencode
"
>>
"
$config_file
"
echo
"
$command
"
>>
"
$config_file
"
print_message info
"
Successfully added
${ORANGE}
opencode
${GREEN}
to
\$
PATH in
$config_file
"
else
print_message warning
"
Manually add the directory to
$config_file
(or similar):
"
print_message info
"
$command
"
fi
}
XDG_CONFIG_HOME=
${XDG_CONFIG_HOME
:-
$HOME
/
.config}
current_shell=
$(
basename
"
$SHELL
"
)
case
$current_shell
in
fish)
config_files=
"
$HOME
/.config/fish/config.fish
"
;;
zsh)
config_files=
"
$HOME
/.zshrc
$HOME
/.zshenv
$XDG_CONFIG_HOME
/zsh/.zshrc
$XDG_CONFIG_HOME
/zsh/.zshenv
"
;;
bash)
config_files=
"
$HOME
/.bashrc
$HOME
/.bash_profile
$HOME
/.profile
$XDG_CONFIG_HOME
/bash/.bashrc
$XDG_CONFIG_HOME
/bash/.bash_profile
"
;;
ash)
config_files=
"
$HOME
/.ashrc
$HOME
/.profile /etc/profile
"
;;
sh)
config_files=
"
$HOME
/.ashrc
$HOME
/.profile /etc/profile
"
;;
*
)
#
Default case if none of the above matches
config_files=
"
$HOME
/.bashrc
$HOME
/.bash_profile
$XDG_CONFIG_HOME
/bash/.bashrc
$XDG_CONFIG_HOME
/bash/.bash_profile
"
;;
esac
config_file=
"
"
for
file
in
$config_files
;
do
if
[[
-f
$file
]]
;
then
config_file=
$file
break
fi
done
if
[[
-z
$config_file
]]
;
then
print_message error
"
No config file found for
$current_shell
. Checked files:
${config_files[@]}
"
exit
1
fi
if
[[
"
:
$PATH
:
"
!=
*
"
:
$INSTALL_DIR
:
"
*
]]
;
then
case
$current_shell
in
fish)
add_to_path
"
$config_file
"
"
fish_add_path
$INSTALL_DIR
"
;;
zsh)
add_to_path
"
$config_file
"
"
export PATH=
$INSTALL_DIR
:
\$
PATH
"
;;
bash)
add_to_path
"
$config_file
"
"
export PATH=
$INSTALL_DIR
:
\$
PATH
"
;;
ash)
add_to_path
"
$config_file
"
"
export PATH=
$INSTALL_DIR
:
\$
PATH
"
;;
sh)
add_to_path
"
$config_file
"
"
export PATH=
$INSTALL_DIR
:
\$
PATH
"
;;
*
)
export
PATH=
$INSTALL_DIR
:
$PATH
print_message warning
"
Manually add the directory to
$config_file
(or similar):
"
print_message info
"
export PATH=
$INSTALL_DIR
:
\$
PATH
"
;;
esac
fi
if
[
-n
"
${GITHUB_ACTIONS-}
"
]
&&
[
"
${GITHUB_ACTIONS}
"
==
"
true
"
]
;
then
echo
"
$INSTALL_DIR
"
>>
$GITHUB_PATH
print_message info
"
Added
$INSTALL_DIR
to
\$
GITHUB_PATH
"
fi
You can’t perform that action at this time.