-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·180 lines (162 loc) · 6.92 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·180 lines (162 loc) · 6.92 KB
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
#!/usr/bin/env bash
# install.sh — one-shot atom installer.
#
# Designed for the curl-pipe-bash UX:
#
# curl -fsSL https://raw.githubusercontent.com/machbuilds/atom/main/install.sh | bash
#
# Clones the atom repo to ~/.atom/atom/, then installs every CLI
# globally (`atom`, `atom-setup`, `nucleus`, `learnings`, `model-race`).
# Idempotent: if ~/.atom/atom/ already exists, recommends `atom upgrade`
# and exits without touching anything.
#
# Env overrides (used for tests; users do not normally set these):
# ATOM_HOME base dir for the install (default ~/.atom)
# ATOM_GIT_URL upstream repo to clone from
# (default https://github.com/machbuilds/atom.git)
# ATOM_BRANCH branch/tag to check out (default: repo default)
set -e
DEFAULT_GIT_URL="https://github.com/machbuilds/atom.git"
GIT_URL="${ATOM_GIT_URL:-$DEFAULT_GIT_URL}"
ATOM_HOME_DIR="${ATOM_HOME:-$HOME/.atom}"
TARGET="$ATOM_HOME_DIR/atom"
BRANCH="${ATOM_BRANCH:-}"
CLIS=(atom atom-setup nucleus learnings model-race atom-update-check)
# ─── pre-flight ─────────────────────────────────────────────────────
if ! command -v git > /dev/null 2>&1; then
echo "Error: git not found on PATH." >&2
echo "atom requires git. Install it and re-run." >&2
exit 1
fi
if ! command -v node > /dev/null 2>&1; then
echo "Error: node not found on PATH." >&2
echo "atom requires Node.js 18+. Install from https://nodejs.org and re-run." >&2
exit 1
fi
if ! command -v npm > /dev/null 2>&1; then
echo "Error: npm not found on PATH." >&2
echo "npm ships with Node.js. Reinstall Node from https://nodejs.org and re-run." >&2
exit 1
fi
NODE_MAJOR=$(node -p "process.versions.node.split('.')[0]")
if [ "$NODE_MAJOR" -lt 18 ]; then
echo "Error: Node $(node -v) is too old. atom requires Node 18 or newer." >&2
exit 1
fi
# ─── idempotency ────────────────────────────────────────────────────
if [ -d "$TARGET" ]; then
echo ""
echo "atom is already installed at $TARGET."
echo ""
if [ -d "$TARGET/.git" ]; then
echo "To upgrade to the latest release:"
echo " atom upgrade"
else
echo "That directory exists but does not look like an atom checkout (no .git)."
echo "Inspect it, then remove it and re-run this installer if you want a fresh install:"
echo " rm -rf $TARGET"
fi
echo ""
exit 0
fi
# ─── clone ──────────────────────────────────────────────────────────
echo ""
echo "Installing atom to $TARGET..."
echo ""
mkdir -p "$ATOM_HOME_DIR"
CLONE_ARGS=(clone --quiet)
if [ -n "$BRANCH" ]; then
CLONE_ARGS+=(--branch "$BRANCH")
fi
CLONE_ARGS+=("$GIT_URL" "$TARGET")
if ! git "${CLONE_ARGS[@]}"; then
echo "" >&2
echo "Error: git clone failed." >&2
echo "Tried: git ${CLONE_ARGS[*]}" >&2
echo "Check your network or git config, then re-run." >&2
exit 1
fi
echo " → cloned to $TARGET"
echo ""
# ─── install CLIs ───────────────────────────────────────────────────
for cli in "${CLIS[@]}"; do
CLI_DIR="$TARGET/bin/$cli"
if [ ! -d "$CLI_DIR" ]; then
printf " → %-12s no bin/, skipping (atom layout drift?)\n" "$cli"
continue
fi
printf " → %-12s " "$cli"
if ! (cd "$CLI_DIR" && npm install > /tmp/atom-install-$cli.log 2>&1); then
echo "FAILED"
echo "" >&2
echo "npm install (deps) for $cli failed. Last 10 lines of output:" >&2
tail -10 /tmp/atom-install-$cli.log >&2
exit 1
fi
if (cd "$CLI_DIR" && npm install -g . >> /tmp/atom-install-$cli.log 2>&1); then
echo "ok"
else
echo "FAILED"
echo "" >&2
echo "npm install -g for $cli failed. Last 10 lines of output:" >&2
tail -10 /tmp/atom-install-$cli.log >&2
echo "" >&2
echo "Common cause: EACCES on global install. Either re-run with sudo," >&2
echo "or set up an npm prefix in your home dir:" >&2
echo " https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally" >&2
exit 1
fi
done
# ─── PATH check ─────────────────────────────────────────────────────
# If npm's global bin isn't on PATH, the install "succeeded" but the
# user can't run anything. Catch this and point them at the fix.
MISSING=()
for cli in "${CLIS[@]}"; do
if ! command -v "$cli" > /dev/null 2>&1; then
MISSING+=("$cli")
fi
done
if [ ${#MISSING[@]} -gt 0 ]; then
echo "" >&2
echo "Installed, but these CLIs are not on your PATH yet: ${MISSING[*]}" >&2
echo "Run 'npm config get prefix' and make sure that prefix's bin/ is in PATH." >&2
echo "Then open a new shell and run 'atom --help' to verify." >&2
exit 1
fi
# ─── global Claude skills ───────────────────────────────────────────
# Symlink each skill in $TARGET/skills/ into ~/.claude/skills/ so it's
# invocable from any Claude session. Symlinks (not copies) into the git
# checkout mean `atom upgrade`'s git pull refreshes them for free.
# Best-effort: a skill link failing must not fail the whole install.
SKILLS_SRC="$TARGET/skills"
CLAUDE_SKILLS_DIR="$HOME/.claude/skills"
if [ -d "$SKILLS_SRC" ]; then
for skill_path in "$SKILLS_SRC"/*/; do
[ -d "$skill_path" ] || continue
skill_name="$(basename "$skill_path")"
dest="$CLAUDE_SKILLS_DIR/$skill_name"
mkdir -p "$CLAUDE_SKILLS_DIR"
if [ -L "$dest" ]; then
# Existing symlink — repoint it (idempotent across reinstalls).
ln -sfn "${skill_path%/}" "$dest"
printf " → skill %-12s linked\n" "$skill_name"
elif [ -e "$dest" ]; then
# A real file/dir the user owns — never clobber it.
printf " → skill %-12s skipped (\$HOME/.claude/skills/%s exists, not a link)\n" "$skill_name" "$skill_name"
else
ln -sfn "${skill_path%/}" "$dest"
printf " → skill %-12s linked\n" "$skill_name"
fi
done
fi
# ─── success ────────────────────────────────────────────────────────
echo ""
echo "✓ atom installed. Run \`atom-setup new <project-name>\` to start your first project."
echo ""
echo "Quick reference:"
echo " atom --help see every atom command"
echo " atom-setup new my-project scaffold a new project"
echo " /atom-new bootstrap a project from inside Claude"
echo " atom upgrade update atom in place"
echo " nucleus init one-time setup for your session memory"
echo ""