| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,36 +60,51 @@ trap 'rm -rf "$TEMP_DIR"' EXIT | |||
| 60 | 60 | git clone --depth 1 -q "$REPO_URL" "$TEMP_DIR" || error "Failed to clone template repository." | |
| 61 | 61 | ||
| 62 | 62 | # --- Discovery --- | |
| 63 | + # Files that are ALWAYS updated (Core Framework) | ||
| 63 | 64 | CORE_FILES=("GEMINI.md") | |
| 65 | + # Files that are ONLY created if missing (Scaffolding) | ||
| 64 | 66 | SCAFFOLD_FILES=("README.md" "TASKS.md" "CHANGELOG.md" "makefile") | |
| 67 | + # Directories that are ensured | ||
| 65 | 68 | CONTENT_DIRS=("journal" "plans" "research" "drafts") | |
| 69 | + # Files within .gemini/ that are PROTECTED (Never overwritten) | ||
| 70 | + PROTECTED_GEMINI_FILES=("settings.json" "style-guide.md") | ||
| 66 | 71 | ||
| 67 | 72 | WILL_CREATE=() | |
| 68 | 73 | WILL_UPDATE=() | |
| 74 | + WILL_PROTECT=() | ||
| 69 | 75 | ||
| 70 | - # 1. Core Framework Check | ||
| 71 | - if [[ -d ".gemini" ]]; then | ||
| 72 | - WILL_UPDATE+=(".gemini/ (core framework)") | ||
| 73 | - else | ||
| 76 | + # 1. .gemini Directory Logic | ||
| 77 | + if [[ ! -d ".gemini" ]]; then | ||
| 74 | 78 | WILL_CREATE+=(".gemini/ (core framework)") | |
| 79 | + else | ||
| 80 | + # Check for protected files | ||
| 81 | + for f in "${PROTECTED_GEMINI_FILES[@]}"; do | ||
| 82 | + if [[ -f ".gemini/$f" ]]; then | ||
| 83 | + WILL_PROTECT+=(".gemini/$f (user configuration)") | ||
| 84 | + fi | ||
| 85 | + done | ||
| 86 | + WILL_UPDATE+=(".gemini/ (hooks, scripts, core commands)") | ||
| 75 | 87 | fi | |
| 76 | 88 | ||
| 89 | + # 2. Core Files Logic (GEMINI.md) | ||
| 77 | 90 | for f in "${CORE_FILES[@]}"; do | |
| 78 | 91 | if [[ -e "$f" ]]; then | |
| 79 | - WILL_UPDATE+=("$f (core framework)") | ||
| 92 | + WILL_UPDATE+=("$f (will preserve 'Project Notes' section if possible)") | ||
| 80 | 93 | else | |
| 81 | 94 | WILL_CREATE+=("$f (core framework)") | |
| 82 | 95 | fi | |
| 83 | 96 | done | |
| 84 | 97 | ||
| 85 | - # 2. Project Scaffolding Check | ||
| 98 | + # 3. Project Scaffolding Check | ||
| 86 | 99 | for f in "${SCAFFOLD_FILES[@]}"; do | |
| 87 | 100 | if [[ ! -e "$f" ]]; then | |
| 88 | 101 | WILL_CREATE+=("$f (new scaffolding)") | |
| 102 | + else | ||
| 103 | + WILL_PROTECT+=("$f (existing project file)") | ||
| 89 | 104 | fi | |
| 90 | 105 | done | |
| 91 | 106 | ||
| 92 | - # 3. Content Directories Check | ||
| 107 | + # 4. Content Directories Check | ||
| 93 | 108 | for d in "${CONTENT_DIRS[@]}"; do | |
| 94 | 109 | if [[ ! -d "$d" ]]; then | |
| 95 | 110 | WILL_CREATE+=("$d/ (new content directory)") | |
@@ -104,10 +119,15 @@ if [[ ${#WILL_CREATE[@]} -gt 0 ]]; then | |||
| 104 | 119 | fi | |
| 105 | 120 | ||
| 106 | 121 | if [[ ${#WILL_UPDATE[@]} -gt 0 ]]; then | |
| 107 | - echo -e "\033[1;34mExisting files/folders to update (core framework):\033[0m" | ||
| 122 | + echo -e "\033[1;34mExisting files to update:\033[0m" | ||
| 108 | 123 | for f in "${WILL_UPDATE[@]}"; do echo " ~ $f"; done | |
| 109 | 124 | fi | |
| 110 | 125 | ||
| 126 | + if [[ ${#WILL_PROTECT[@]} -gt 0 ]]; then | ||
| 127 | + echo -e "\033[1;35mFiles to preserve (will NOT be modified):\033[0m" | ||
| 128 | + for f in "${WILL_PROTECT[@]}"; do echo " # $f"; done | ||
| 129 | + fi | ||
| 130 | + | ||
| 111 | 131 | echo "" | |
| 112 | 132 | confirm "Do you want to proceed with these changes?" | |
| 113 | 133 | ||
@@ -119,13 +139,40 @@ fi | |||
| 119 | 139 | ||
| 120 | 140 | echo "🛠️ Applying changes..." | |
| 121 | 141 | ||
| 122 | - # 1. Update .gemini (non-destructive for user files) | ||
| 142 | + # 1. Update .gemini (Surgical Update) | ||
| 123 | 143 | mkdir -p .gemini | |
| 124 | - cp -r "$TEMP_DIR/.gemini/." .gemini/ | ||
| 144 | + # Copy subdirectories one by one, preserving protected files | ||
| 145 | + for subdir in agents commands hooks scripts; do | ||
| 146 | + if [[ -d "$TEMP_DIR/.gemini/$subdir" ]]; then | ||
| 147 | + mkdir -p ".gemini/$subdir" | ||
| 148 | + cp -r "$TEMP_DIR/.gemini/$subdir/." ".gemini/$subdir/" | ||
| 149 | + fi | ||
| 150 | + done | ||
| 125 | 151 | ||
| 126 | - # 2. Update Core Files (Always) | ||
| 152 | + # Restore protected files if they existed in temp (preventing accidental overwrite if cp -r was used) | ||
| 153 | + for f in "${PROTECTED_GEMINI_FILES[@]}"; do | ||
| 154 | + if [[ -f "$TEMP_DIR/.gemini/$f" && ! -f ".gemini/$f" ]]; then | ||
| 155 | + cp "$TEMP_DIR/.gemini/$f" ".gemini/$f" | ||
| 156 | + fi | ||
| 157 | + done | ||
| 158 | + | ||
| 159 | + # 2. Update Core Files with preservation | ||
| 127 | 160 | for f in "${CORE_FILES[@]}"; do | |
| 128 | - cp "$TEMP_DIR/$f" . | ||
| 161 | + if [[ "$f" == "GEMINI.md" && -f "GEMINI.md" ]]; then | ||
| 162 | + # Try to preserve the section after "## Project Notes" | ||
| 163 | + # We take the header and core mandates from TEMP, and append the user's notes | ||
| 164 | + NOTES_START=$(grep -n "## Project Notes" GEMINI.md | cut -d: -f1 || echo "") | ||
| 165 | + if [[ -n "$NOTES_START" ]]; then | ||
| 166 | + TEMP_CORE=$(sed "/## Project Notes/q" "$TEMP_DIR/GEMINI.md") | ||
| 167 | + USER_NOTES=$(sed "1,$NOTES_START d" GEMINI.md) | ||
| 168 | + echo "$TEMP_CORE" > GEMINI.md | ||
| 169 | + echo "$USER_NOTES" >> GEMINI.md | ||
| 170 | + else | ||
| 171 | + cp "$TEMP_DIR/$f" . | ||
| 172 | + fi | ||
| 173 | + else | ||
| 174 | + cp "$TEMP_DIR/$f" . | ||
| 175 | + fi | ||
| 129 | 176 | done | |
| 130 | 177 | ||
| 131 | 178 | # 3. Create Scaffolding Files (Only if missing) | |
@@ -144,21 +191,22 @@ for d in "${CONTENT_DIRS[@]}"; do | |||
| 144 | 191 | done | |
| 145 | 192 | ||
| 146 | 193 | # 5. Journal Entry | |
| 147 | - TODAY=$(date +%Y-%m-%d) | ||
| 148 | - mkdir -p journal | ||
| 149 | - JOURNAL_FILE="journal/$TODAY.md" | ||
| 150 | - if [[ ! -f "$JOURNAL_FILE" ]]; then | ||
| 151 | - echo "# $TODAY" > "$JOURNAL_FILE" | ||
| 152 | - fi | ||
| 153 | - | ||
| 154 | 194 | if $IS_UPDATE; then | |
| 155 | - echo -e "\n## Gemini CLI Update\n- Updated framework to version $VERSION." >> "$JOURNAL_FILE" | ||
| 195 | + MSG="Updated Gemini CLI framework to version $VERSION." | ||
| 156 | 196 | COMMIT_MSG="chore: update Gemini CLI framework to v$VERSION" | |
| 157 | 197 | else | |
| 158 | - echo -e "\n## Gemini CLI Integration\n- Integrated Gemini CLI framework v$VERSION." >> "$JOURNAL_FILE" | ||
| 198 | + MSG="Integrated Gemini CLI framework version $VERSION." | ||
| 159 | 199 | COMMIT_MSG="feat: integrate Gemini CLI framework v$VERSION" | |
| 160 | 200 | fi | |
| 161 | 201 | ||
| 202 | + # Use the project's journal script if it exists | ||
| 203 | + if [[ -f ".gemini/scripts/journal.py" ]]; then | ||
| 204 | + python3 .gemini/scripts/journal.py "$MSG" | ||
| 205 | + else | ||
| 206 | + TODAY=$(date +%Y-%m-%d) | ||
| 207 | + echo -e "\n## Gemini CLI Integration\n- $MSG" >> "journal/$TODAY.md" | ||
| 208 | + fi | ||
| 209 | + | ||
| 162 | 210 | # --- Post-Install --- | |
| 163 | 211 | git add . | |
| 164 | 212 | git commit -m "$COMMIT_MSG" -q | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,3 +6,4 @@ | |||
| 6 | 6 | [2026-03-20T08:35:07] - Testing the pre-commit hook by modifying README.md | |
| 7 | 7 | [2026-03-20T08:37:07] - feat(hooks): add pre-commit hook installation check to welcome script | |
| 8 | 8 | [2026-03-20T08:38:31] - chore(release): version 0.16.0 | |
| 9 | + [2026-03-20T08:41:47] - feat(docs): improve install.sh with safe update logic and preservation of user notes | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments