-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-claude.sh
More file actions
executable file
·189 lines (147 loc) · 6.6 KB
/
install-claude.sh
File metadata and controls
executable file
·189 lines (147 loc) · 6.6 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
181
182
183
184
185
186
187
188
189
#!/usr/bin/env bash
# SideNotes Claude Code Integration Installer
# This script sets up SideNotes for use with Claude Code
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Configuration
SIDENOTES_HOME="$HOME/.sidenotes"
SCRIPTS_DIR="$SIDENOTES_HOME/scripts"
NOTES_BASE_DIR="${SIDENOTES_DIR:-$HOME/Code/SideNotes}"
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo -e "${BLUE} SideNotes Claude Code Integration Installer${NC}"
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo
# Function to check if we're in a git repository
is_git_repo() {
git rev-parse --is-inside-work-tree &>/dev/null
}
# Function to get the project name
get_project_name() {
if is_git_repo; then
basename "$(git rev-parse --show-toplevel)"
else
basename "$PWD"
fi
}
# Step 1: Install SideNotes scripts for direct CLI access
echo -e "${YELLOW}Step 1: Installing SideNotes scripts...${NC}"
mkdir -p "$SCRIPTS_DIR"
# Copy scripts from the current directory
SCRIPT_SOURCE_DIR="$(cd "$(dirname "$0")" && pwd)/scripts"
if [[ ! -d "$SCRIPT_SOURCE_DIR" ]]; then
echo -e "${RED}Error: Scripts directory not found at $SCRIPT_SOURCE_DIR${NC}"
echo "Please run this installer from the side-notes repository directory."
exit 1
fi
cp -r "$SCRIPT_SOURCE_DIR"/* "$SCRIPTS_DIR/"
chmod +x "$SCRIPTS_DIR"/*.sh
echo -e "${GREEN}✓ Scripts installed to $SCRIPTS_DIR${NC}"
# Step 2: Set up Claude Code slash commands for the current project
echo -e "${YELLOW}Step 2: Setting up Claude Code slash commands...${NC}"
CLAUDE_COMMANDS_DIR=".claude/commands"
CLAUDE_SOURCE_DIR="$(cd "$(dirname "$0")" && pwd)/.claude/commands"
if [[ -d "$CLAUDE_SOURCE_DIR" ]]; then
mkdir -p "$CLAUDE_COMMANDS_DIR"
# Copy slash commands, updating paths to use the installed scripts
for cmd in "$CLAUDE_SOURCE_DIR"/*.md; do
if [[ -f "$cmd" ]]; then
filename=$(basename "$cmd")
sed "s|~/.sidenotes/scripts/|$SCRIPTS_DIR/|g" "$cmd" > "$CLAUDE_COMMANDS_DIR/$filename"
fi
done
echo -e "${GREEN}✓ Slash commands installed to $CLAUDE_COMMANDS_DIR${NC}"
else
echo -e "${YELLOW}⚠ Claude commands source not found, skipping slash commands setup${NC}"
fi
# Step 3: Initialize SideNotes for current project
echo -e "${YELLOW}Step 3: Initializing SideNotes for current project...${NC}"
PROJECT_NAME=$(get_project_name)
NOTE_DIR="$NOTES_BASE_DIR/$PROJECT_NAME"
if [[ -L "SideNotes" ]]; then
echo -e "${GREEN}✓ SideNotes already initialized for $PROJECT_NAME${NC}"
else
mkdir -p "$NOTE_DIR"
ln -s "$NOTE_DIR" "SideNotes"
echo -e "${GREEN}✓ SideNotes initialized for $PROJECT_NAME${NC}"
fi
# Step 4: Create CLAUDE.md if it doesn't exist in the current project
if [[ ! -f "CLAUDE.md" ]]; then
echo -e "${YELLOW}Step 4: Creating CLAUDE.md for Claude Code reference...${NC}"
cat > CLAUDE.md << 'EOF'
# SideNotes Configuration for Claude Code
This project uses SideNotes for persistent note-taking. The scripts are installed at `~/.sidenotes/scripts/`.
## Available Commands
You can use these scripts directly from the terminal:
- `~/.sidenotes/scripts/notes-init.sh` - Initialize notes for a project
- `~/.sidenotes/scripts/note.sh <title>` - Create a new timestamped note
- `~/.sidenotes/scripts/notes.sh` - List all notes
- `~/.sidenotes/scripts/notes-latest.sh` - Open the most recent note
- `~/.sidenotes/scripts/notes-projects.sh` - List all projects with notes
## Slash Commands
If `.claude/commands/` is set up, you can also use:
- `/note-init` - Initialize SideNotes
- `/note <title>` - Create a new note
- `/note-session` - Create/continue a session note
- `/note-list` - List notes
- `/note-context` - Add context to latest note
## Notes Location
Notes are stored in `~/Code/SideNotes/PROJECT_NAME/` and symlinked to `./SideNotes` in each project.
EOF
echo -e "${GREEN}✓ Created CLAUDE.md${NC}"
else
echo -e "${BLUE}ℹ CLAUDE.md already exists, skipping${NC}"
fi
# Step 5: Set up global git ignore (if not already done)
echo -e "${YELLOW}Step 5: Configuring Git to ignore SideNotes...${NC}"
GLOBAL_GITIGNORE="$HOME/.gitignore"
if ! grep -q "^SideNotes$" "$GLOBAL_GITIGNORE" 2>/dev/null; then
echo "SideNotes" >> "$GLOBAL_GITIGNORE"
git config --global core.excludesFile "$GLOBAL_GITIGNORE"
echo -e "${GREEN}✓ Added SideNotes to global .gitignore${NC}"
else
echo -e "${GREEN}✓ SideNotes already in global .gitignore${NC}"
fi
# Step 6: Create an initial session note
echo -e "${YELLOW}Step 6: Creating initial session note...${NC}"
SESSION_DATE=$(date +"%Y-%m-%d")
SESSION_FILE="SideNotes/${SESSION_DATE}_claude-session.md"
if [[ ! -f "$SESSION_FILE" ]]; then
BRANCH=$(git branch --show-current 2>/dev/null || echo "no-git")
cat > "$SESSION_FILE" << EOF
# Claude Session - $(date +"%Y-%m-%d")
*Started: $(date +"%Y-%m-%d %H:%M:%S")*
## Session Info
- **Branch:** $BRANCH
- **Topic:** Claude Code Integration Setup
- **Project:** $PROJECT_NAME
## Notes
### $(date +"%H:%M") - Installation Complete
SideNotes has been successfully integrated with Claude Code.
---
EOF
echo -e "${GREEN}✓ Created initial session note: $SESSION_FILE${NC}"
else
echo -e "${BLUE}ℹ Session note for today already exists${NC}"
fi
# Summary
echo
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo -e "${GREEN} Installation Complete!${NC}"
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo
echo -e "${GREEN}Claude Code can now use SideNotes through:${NC}"
echo -e " 1. Direct script calls: ${BLUE}~/.sidenotes/scripts/note.sh <title>${NC}"
echo -e " 2. Slash commands: ${BLUE}/note <title>${NC} (if .claude/commands/ is configured)"
echo
echo -e "${YELLOW}Quick Start:${NC}"
echo -e " Create a note: ${BLUE}~/.sidenotes/scripts/note.sh my-first-note${NC}"
echo -e " List notes: ${BLUE}~/.sidenotes/scripts/notes.sh${NC}"
echo
echo -e "${GREEN}Notes location:${NC} ~/Code/SideNotes/$PROJECT_NAME/"
echo -e "${GREEN}Project link:${NC} ./SideNotes"
echo