Skip to content

Commit 20e9a30

Browse files
committed
feat: add add-gemini.sh script for existing repo integration
1 parent 2c4dde4 commit 20e9a30

3 files changed

Lines changed: 176 additions & 0 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ If you prefer a manual setup:
4444
2. Delete `README.md`, `CHANGELOG.md`, and `journal/*.md` to get a fresh history.
4545
3. Run `gemini /scaffold` to start a new project.
4646

47+
## 📥 Integration (Existing Projects)
48+
49+
To add this framework to an existing Git repository, run:
50+
51+
```bash
52+
curl -fsSL https://raw.githubusercontent.com/apiad/starter/main/add-gemini.sh | bash
53+
```
54+
55+
This script will:
56+
1. **Check** for a clean working tree.
57+
2. **Prompt** for permission before overwriting any existing core files.
58+
3. **Extract** the `.gemini/` configuration and framework files.
59+
4. **Create** a first integration commit.
60+
4761
## 🧠 The Core Philosophy
4862

4963
This repository is a heavily customized and oppinionanted Gemini CLI agent, ready to be used in any situation. In this framework, the AI agent is not just a "code generator" or a "copilot". It is a **Senior Architect and Critical Thinking Partner**:

add-gemini.sh

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# --- Configuration ---
5+
REPO_URL="https://github.com/apiad/starter.git"
6+
VERSION="0.9.0"
7+
8+
# --- Functions ---
9+
banner() {
10+
echo -e "\033[1;34m"
11+
echo " ____ _ _ "
12+
echo " / ___| ___ _ __ ___(_)_ __ (_)"
13+
echo "| | _ / _ \ '_ ` _ \ | '_ \| |"
14+
echo "| |_| | __/ | | | | | | | | | |"
15+
echo " \____|\___|_| |_| |_|_|_| |_|_|"
16+
echo -e "\033[0m"
17+
echo -e "\033[1;32m Gemini CLI Integration v$VERSION\033[0m"
18+
echo "------------------------------------------"
19+
}
20+
21+
error() {
22+
echo -e "\033[0;31m❌ Error: $1\033[0m" >&2
23+
exit 1
24+
}
25+
26+
confirm() {
27+
echo -n "$1 [y/N]: "
28+
read CONFIRM < /dev/tty
29+
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
30+
error "Aborted by user."
31+
fi
32+
}
33+
34+
# --- Check Prerequisites ---
35+
for cmd in git node; do
36+
if ! command -v "$cmd" >/dev/null 2>&1; then
37+
error "$cmd is not installed. Please install it and try again."
38+
fi
39+
done
40+
41+
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
42+
error "Not a git repository. This script must be run inside an existing git repository."
43+
fi
44+
45+
if [[ -n $(git status --porcelain) ]]; then
46+
error "Working tree is not clean. Please commit or stash your changes before running this script."
47+
fi
48+
49+
# --- Inputs ---
50+
banner
51+
52+
# --- Conflict Check ---
53+
CONFLICTS=()
54+
FILES_TO_EXTRACT=(
55+
".gemini/"
56+
"GEMINI.md"
57+
"TASKS.md"
58+
"CHANGELOG.md"
59+
"makefile"
60+
"journal/"
61+
"plans/"
62+
"research/"
63+
"drafts/"
64+
)
65+
66+
for f in "${FILES_TO_EXTRACT[@]}"; do
67+
if [[ -e "$f" ]]; then
68+
CONFLICTS+=("$f")
69+
fi
70+
done
71+
72+
if [[ ${#CONFLICTS[@]} -gt 0 ]]; then
73+
echo -e "\033[0;33m⚠️ Warning: The following files/folders already exist:\033[0m"
74+
for c in "${CONFLICTS[@]}"; do
75+
echo " - $c"
76+
done
77+
confirm "Do you want to overwrite them and proceed with the integration?"
78+
fi
79+
80+
# --- Execution ---
81+
echo "🚀 Integrating Gemini CLI framework..."
82+
83+
TEMP_DIR=$(mktemp -d)
84+
trap 'rm -rf "$TEMP_DIR"' EXIT
85+
86+
# Clone the template to temp
87+
git clone --depth 1 -q "$REPO_URL" "$TEMP_DIR" || error "Failed to clone template repository."
88+
89+
# Copy core files
90+
cp -r "$TEMP_DIR/.gemini" .
91+
cp "$TEMP_DIR/GEMINI.md" .
92+
93+
# Handle other files/folders
94+
for f in TASKS.md CHANGELOG.md makefile journal plans research drafts; do
95+
if [[ -d "$TEMP_DIR/$f" ]]; then
96+
mkdir -p "$f"
97+
# Copy .gitkeep files if they exist
98+
find "$TEMP_DIR/$f" -name ".gitkeep" -exec cp {} "$f/" \; 2>/dev/null || true
99+
else
100+
cp "$TEMP_DIR/$f" .
101+
fi
102+
done
103+
104+
# Reset TASKS.md and CHANGELOG.md to clean state
105+
cat <<EOF > TASKS.md
106+
# Tasks
107+
108+
Legend:
109+
110+
- [ ] Todo
111+
- [/] In Progress (@user)
112+
- [x] Done
113+
114+
---
115+
116+
## Active Tasks
117+
- [ ] Initialize the project goals.
118+
119+
---
120+
121+
## Archive
122+
EOF
123+
124+
cat <<EOF > CHANGELOG.md
125+
# Changelog
126+
127+
All notable changes to this project will be documented in this file.
128+
129+
## [Unreleased]
130+
- Integrated Gemini CLI framework.
131+
EOF
132+
133+
# Clear content directories but preserve .gitkeep
134+
for dir in journal plans research drafts; do
135+
if [[ -d "$dir" ]]; then
136+
find "$dir" -maxdepth 1 -type f ! -name ".gitkeep" -delete
137+
touch "$dir/.gitkeep"
138+
fi
139+
done
140+
141+
# Create first journal entry
142+
TODAY=$(date +%Y-%m-%d)
143+
cat <<EOF > "journal/$TODAY.md"
144+
# $TODAY - Gemini CLI Integration
145+
146+
Integrated the Gemini CLI framework into this repository.
147+
EOF
148+
149+
# --- Post-Install ---
150+
git add .
151+
git commit -m "feat: integrate Gemini CLI framework" -q
152+
153+
echo "✅ Gemini CLI framework integrated successfully!"
154+
echo "🚀 Starting Gemini CLI..."
155+
156+
# Run the gemini CLI
157+
if command -v gemini >/dev/null 2>&1; then
158+
exec gemini
159+
else
160+
echo "⚠️ 'gemini' command not found. Please ensure the Gemini CLI is installed and in your PATH."
161+
fi

journal/2026-03-03.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
- Refined `scaffold` and `revise` command instructions for better clarity and consistency.
55
- Implemented the `install.sh` scaffolding script to automate project bootstrapping from the `apiad/starter` template.
66
- Added a professional ASCII banner to the `install.sh` script for improved UX, now including the version (v0.9.0).
7+
- Implemented the `add-gemini.sh` script for integrating the framework into existing repositories.

0 commit comments

Comments
 (0)