-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sh
More file actions
149 lines (129 loc) · 5.77 KB
/
init.sh
File metadata and controls
149 lines (129 loc) · 5.77 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
#!/bin/bash
# init.sh — Atlas Setup Wizard
# Run once after cloning. Walks you through filling in your CLAUDE.md and context files.
# Re-run at any time to update your configuration.
set -e
REPO_ROOT="$(cd "$(dirname "$0")" && pwd)"
CLAUDE_MD="$REPO_ROOT/CLAUDE.md"
STATE_YAML="$REPO_ROOT/context/state.yaml"
echo ""
echo "╔══════════════════════════════════════════╗"
echo "║ Atlas Setup Wizard ║"
echo "╚══════════════════════════════════════════╝"
echo ""
echo "This wizard will walk you through the initial setup."
echo "You can re-run it at any time to update your config."
echo ""
# ── Helper ───────────────────────────────────────────────────────────────────
prompt() {
local label="$1"
local default="$2"
local result
if [ -n "$default" ]; then
read -rp " $label [$default]: " result
echo "${result:-$default}"
else
read -rp " $label: " result
echo "$result"
fi
}
echo "── Step 1: Identity ─────────────────────────────────────────────"
NAME=$(prompt "Your full name")
MACHINE=$(prompt "Primary machine name (e.g. workstation, laptop, homelab)" "my-machine")
GITHUB=$(prompt "GitHub username")
JOB=$(prompt "Your job title or role")
echo ""
echo "── Step 2: Current Focus ────────────────────────────────────────"
FOCUS=$(prompt "What are you primarily focused on right now?")
echo ""
echo "── Step 3: Git Remote ───────────────────────────────────────────"
echo " Atlas needs a git remote to sync sessions across devices."
REMOTE=$(prompt "Remote URL (e.g. git@github.com:yourname/your-atlas.git)" "")
echo ""
echo "── Step 4: Hook Setup ───────────────────────────────────────────"
echo " Atlas uses Claude Code hooks for auto-commit and session sync."
echo " Hooks need to be registered in ~/.claude/settings.json."
echo ""
echo " Add the following to your ~/.claude/settings.json:"
echo ""
cat <<EOF
{
"hooks": {
"PostToolUse": [
{
"matcher": {"tool_name": "Write|Edit"},
"hooks": [{"type": "command", "command": "bash $REPO_ROOT/scripts/post-tool-use.sh"}]
}
],
"Stop": [
{
"hooks": [{"type": "command", "command": "bash $REPO_ROOT/scripts/stop-hook.sh"}]
}
]
}
}
EOF
echo ""
read -rp " Press Enter to continue once you've reviewed the hook config..."
# ── Write initial state.yaml ──────────────────────────────────────────────────
echo ""
echo "── Writing context/state.yaml ───────────────────────────────────"
DATE="$(date '+%Y-%m-%d')"
MACHINE_LOWER="$(echo "$MACHINE" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')"
cat > "$STATE_YAML" <<YAML
# context/state.yaml — Canonical System State
# Last updated: $DATE | Device: $MACHINE_LOWER
identity:
name: "$NAME"
system: "atlas"
version: "1.0.0"
machine: "$MACHINE_LOWER"
focus:
primary: "$FOCUS"
queue: []
sessions:
last_session: S000
next_session_number: 1
last_device: "$MACHINE_LOWER"
last_updated: "$DATE"
devices:
last_active: "$MACHINE_LOWER"
registered:
- "$MACHINE_LOWER"
projects:
active: []
parked: []
open_todos: []
YAML
echo " Written: context/state.yaml"
# ── Git remote ────────────────────────────────────────────────────────────────
if [ -n "$REMOTE" ]; then
echo ""
echo "── Configuring git remote ───────────────────────────────────────"
cd "$REPO_ROOT"
if git remote get-url origin &>/dev/null; then
git remote set-url origin "$REMOTE"
echo " Updated remote: origin → $REMOTE"
else
git remote add origin "$REMOTE"
echo " Added remote: origin → $REMOTE"
fi
fi
# ── Make scripts executable ───────────────────────────────────────────────────
chmod +x "$REPO_ROOT/scripts/"*.sh
echo ""
echo " Scripts marked executable."
# ── Done ──────────────────────────────────────────────────────────────────────
echo ""
echo "╔══════════════════════════════════════════╗"
echo "║ Setup Complete ║"
echo "╚══════════════════════════════════════════╝"
echo ""
echo " Next steps:"
echo " 1. Open CLAUDE.md and fill in all placeholder sections"
echo " 2. Register your hooks in ~/.claude/settings.json (shown above)"
echo " 3. Run: git add -A && git commit -m 'init: atlas setup' && git push origin main"
echo " 4. Open Claude Code in this directory: claude"
echo ""
echo " Read docs/architecture.md and docs/session-hygiene.md to understand how it works."
echo ""