Skip to content

Commit cd696f8

Browse files
2 parents 83d1717 + f7b650e commit cd696f8

17 files changed

+347
-120
lines changed

.github/workflows/chrome-extension-ci.yml

+150-18
Original file line numberDiff line numberDiff line change
@@ -61,46 +61,178 @@ jobs:
6161
- name: Build extension
6262
run: bun run build
6363

64-
- name: Zip Extension
65-
run: zip -r chrome-extension.zip dist/
66-
6764
# Automatically increments the patch version (e.g., 1.0.0 -> 1.0.1)
6865
# and creates a release
6966
# Only increment patch version for non-major versions
7067
- name: Check existing tag
7168
id: check_tag
69+
shell: bash
7270
run: |
73-
current_version=$(node -p "require('./package.json').version")
71+
set -euo pipefail # Exit on error, undefined vars, and pipe failures
72+
73+
# Function to validate semver format
74+
# Supports standard versions (x.y.z) and pre-release versions (x.y.z-beta.n)
75+
validate_version() {
76+
local version="$1"
77+
if ! [[ "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
78+
echo "Error: Invalid version format: $version"
79+
echo "Version must be in format: x.y.z or x.y.z-pre.n"
80+
exit 1
81+
fi
82+
}
83+
84+
# Function to update version in JSON files
85+
update_json_version() {
86+
local file="$1"
87+
local cur_ver="$2"
88+
local new_ver="$3"
89+
90+
if [[ ! -f "$file" ]]; then
91+
echo "Error: File $file not found"
92+
exit 1
93+
fi
94+
95+
# Check if version field exists
96+
if ! grep -q "\"version\":" "$file"; then
97+
echo "Error: No version field found in $file"
98+
exit 1
99+
fi
100+
101+
# Backup file before modification
102+
cp "$file" "${file}.bak"
103+
104+
if ! sed -i "s/\"version\": \"$cur_ver\"/\"version\": \"$new_ver\"/" "$file"; then
105+
echo "Error: Failed to update version in $file"
106+
mv "${file}.bak" "$file" # Restore backup
107+
exit 1
108+
fi
109+
110+
rm "${file}.bak" # Remove backup if successful
111+
}
112+
113+
# Function to compare versions
114+
version_gt() {
115+
test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"
116+
}
117+
118+
# Get current version with error handling
119+
if [[ ! -f "package.json" ]]; then
120+
echo "Error: package.json not found"
121+
exit 1
122+
fi
123+
124+
if ! current_version=$(node -p "try { require('./package.json').version } catch(e) { console.error(e); process.exit(1) }" 2>/dev/null); then
125+
echo "Error: Failed to read version from package.json"
126+
exit 1
127+
fi
128+
129+
# Validate version format
130+
validate_version "$current_version"
131+
132+
# Get highest existing version with error handling
133+
if ! highest_version=$(git ls-remote --tags origin | grep "refs/tags/chrome-extension-v" | sed 's/.*chrome-extension-v//' | sort -V | tail -n 1); then
134+
echo "Warning: Failed to fetch remote tags, proceeding with caution"
135+
fi
136+
137+
# Prevent version downgrade
138+
# Note: To downgrade versions, you need to manually:
139+
# 1. Delete the higher version tag: git push origin :refs/tags/chrome-extension-v<version>
140+
# 2. Delete the corresponding GitHub release
141+
if [ ! -z "$highest_version" ] && version_gt "$highest_version" "$current_version"; then
142+
echo "Error: Version downgrade not allowed. Current: $current_version, Highest: $highest_version"
143+
exit 1
144+
fi
145+
146+
# Handle pre-release versions
147+
if [[ "$current_version" == *"-"* ]]; then
148+
echo "Pre-release version detected: $current_version"
149+
150+
# Extract base version and pre-release parts
151+
base_version=${current_version%%-*}
152+
pre_release=${current_version#*-}
153+
pre_type=${pre_release%%.*}
154+
pre_num=${pre_release#*.}
155+
156+
# Check if same pre-release version exists
157+
if git ls-remote --tags origin | grep -q "refs/tags/chrome-extension-v$current_version"; then
158+
# Increment pre-release number
159+
new_pre_num=$((pre_num + 1))
160+
new_version="${base_version}-${pre_type}.${new_pre_num}"
161+
echo "Incrementing pre-release: $current_version -> $new_version"
162+
echo "version=$new_version" >> $GITHUB_OUTPUT
163+
echo "version_changed=true" >> $GITHUB_OUTPUT
164+
else
165+
echo "Using current pre-release version: $current_version"
166+
echo "version=$current_version" >> $GITHUB_OUTPUT
167+
echo "version_changed=false" >> $GITHUB_OUTPUT
168+
fi
169+
exit 0
170+
fi
171+
172+
# Handle major versions (x.0.0)
74173
if [[ "$current_version" =~ ^[0-9]+\.0\.0$ ]]; then
75-
# Don't increment major versions (x.0.0)
76-
echo "version=$current_version" >> $GITHUB_OUTPUT
77-
echo "version_changed=false" >> $GITHUB_OUTPUT
78-
elif git ls-remote --tags origin | grep -q "refs/tags/v$current_version"; then
79-
# If tag exists and it's not a major version, increment patch
174+
echo "Major version detected: $current_version"
175+
176+
# Check if major version tag exists
177+
if git ls-remote --tags origin | grep -q "refs/tags/chrome-extension-v$current_version"; then
178+
# Increment patch version like normal
179+
new_version="${current_version%.*}.1" # x.0.0 -> x.0.1
180+
echo "Major version exists, incrementing patch: $current_version -> $new_version"
181+
echo "version=$new_version" >> $GITHUB_OUTPUT
182+
echo "version_changed=true" >> $GITHUB_OUTPUT
183+
else
184+
echo "Using new major version: $current_version"
185+
echo "version=$current_version" >> $GITHUB_OUTPUT
186+
echo "version_changed=false" >> $GITHUB_OUTPUT
187+
fi
188+
exit 0
189+
fi
190+
191+
# Check if tag exists
192+
if git ls-remote --tags origin | grep -q "refs/tags/chrome-extension-v$current_version"; then
193+
echo "Tag exists, incrementing patch version"
194+
195+
# Split version into components
80196
IFS='.' read -r major minor patch <<< "$current_version"
81197
new_version="$major.$minor.$((patch + 1))"
82-
echo "version=$new_version" >> $GITHUB_OUTPUT
83-
echo "version_changed=true" >> $GITHUB_OUTPUT
84-
# Update package.json with new version
85-
sed -i "s/\"version\": \"$current_version\"/\"version\": \"$new_version\"/" package.json
86-
# Update manifest.json with new version
87-
sed -i "s/\"version\": \"$current_version\"/\"version\": \"$new_version\"/" public/manifest.json
198+
validate_version "$new_version"
199+
200+
echo "Updating version from $current_version to $new_version"
201+
202+
# Update version in files
203+
update_json_version "package.json" "$current_version" "$new_version"
204+
update_json_version "public/manifest.json" "$current_version" "$new_version"
205+
206+
# Configure git for fork workflow
88207
git config --global user.email "github-actions[bot]@users.noreply.github.com"
89208
git config --global user.name "github-actions[bot]"
209+
210+
# Commit and push changes
90211
git add package.json public/manifest.json
91212
git commit -m "chore: bump version to $new_version [skip ci]"
92-
git push
213+
214+
if ! git push; then
215+
echo "Error: Failed to push changes"
216+
exit 1
217+
fi
218+
echo "version=$new_version" >> $GITHUB_OUTPUT
219+
echo "version_changed=true" >> $GITHUB_OUTPUT
93220
else
221+
echo "Using current version: $current_version"
94222
echo "version=$current_version" >> $GITHUB_OUTPUT
95223
echo "version_changed=false" >> $GITHUB_OUTPUT
96224
fi
225+
226+
- name: Zip Extension
227+
run: zip -r thinking-claude-chrome-extension-v${{ steps.check_tag.outputs.version }}.zip dist/
228+
97229
- name: Create Release
98230
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
99231
uses: softprops/action-gh-release@v1
100232
with:
101233
name: Chrome Extension v${{ steps.check_tag.outputs.version }}
102-
tag_name: v${{ steps.check_tag.outputs.version }}
103-
files: extensions/chrome/chrome-extension.zip
234+
tag_name: chrome-extension-v${{ steps.check_tag.outputs.version }}
235+
files: extensions/chrome/thinking-claude-chrome-extension-v${{ steps.check_tag.outputs.version }}.zip
104236
generate_release_notes: true
105237
token: ${{ secrets.GITHUB_TOKEN }}
106238
fail_on_unmatched_files: true

extensions/changelog.md

+79-11
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,112 @@
1-
## Changelog of the extensions
1+
<!-- markdownlint-disable MD024 -->
22

3-
### feat/fix/ref: - 11/27/2024 - @lumpinif
3+
# Changelog of the extensions
44

5-
#### Performance & Code Quality
5+
## feat: CSS Architecture - 12/1/2024 - @lumpinif
6+
7+
### Modular CSS Architecture Implementation
8+
9+
- Established new modular CSS architecture for better feature isolation
10+
- Introduced feature-specific CSS modules starting with thinking-block
11+
- Set up base styles directory for shared Tailwind utilities
12+
- Improved organization and maintainability of styles
13+
- Added support for future feature-specific styling needs
14+
15+
### Build System Updates
16+
17+
- Enhanced webpack configuration for CSS handling
18+
- Integrated MiniCssExtractPlugin for optimized CSS delivery
19+
- Updated manifest.json to reflect new CSS structure
20+
- Removed legacy styles.css in favor of modular approach
21+
22+
## ci: - 11/30/2024 - @lumpinif
23+
24+
### Chrome Extension CI Improvements
25+
26+
- Enhanced version management in GitHub Actions workflow
27+
- Added robust semver validation supporting x.y.z and pre-release versions
28+
- Implemented automatic patch version increment for existing versions
29+
- Added support for pre-release versions (beta) with auto-increment
30+
- Added version downgrade prevention with clear error messages
31+
- Improved error handling for file operations and git commands
32+
- Added backup mechanism for safe version updates
33+
- Enhanced logging for better debugging and transparency
34+
35+
### File Operations
36+
37+
- Added safe JSON file updates with backup mechanism
38+
- Improved handling of package.json and manifest.json version updates
39+
- Added validation for version field existence in JSON files
40+
41+
## fix: - 11/30/2024 - @lumpinif
42+
43+
### Feature Cleanup & Navigation
44+
45+
- Fixed thinking block toggle not working when navigating between pages
46+
- Improved cleanup and reinitialization of features during page navigation
47+
- Added proper cleanup for mutation observer to prevent memory leaks
48+
- Added background script for better navigation handling between pages
49+
50+
### Code Quality
51+
52+
- Removed debug console logs while keeping error logs for better production monitoring
53+
- Added [TC] prefix to error messages for better identification
54+
- Improved error handling and cleanup process
55+
56+
## feat/fix/ref: - 11/28/2024 - @lumpinif
57+
58+
### Architecture
59+
60+
- Implement feature management architecture for better extensibility
61+
- Add ExtensionManager for high-level orchestration
62+
- Create FeatureManager for feature lifecycle
63+
- Convert TCThinkingBlock to new architecture
64+
- Add configurable MutationObserverService
65+
- Remove singleton pattern usage
66+
- Improve code organization and modularity
67+
- Clear separation of concerns
68+
- Dependency injection pattern
69+
- Standardized feature lifecycle
70+
71+
## feat/fix/ref: - 11/27/2024 - @lumpinif
72+
73+
### Performance & Code Quality
674

775
- Extremely streamline code structure and implementation approach
876
- Much optimized performance
977
- Streamline and organize code for thinking-block implementation
1078

11-
#### Bug Fixes
79+
### Bug Fixes
1280

1381
- Fix flash of unstyled content (FOUC)
1482
- Fix stutter when submitting new replies
1583
- Fix FOUC and streaming issues for thinking-block implementation
1684

17-
#### UI Improvements
85+
### UI Improvements
1886

1987
- Update chevron icon with transition effect
2088

21-
#### Architecture
89+
### Architecture
2290

2391
- Implement ultimate approach with simplest and most effective implementation after experimentation
2492

25-
### fix: - 11/17/2024 - @lumpinif
93+
## fix: - 11/17/2024 - @lumpinif
2694

27-
#### Observer Management and Memory Leak Prevention
95+
### Observer Management and Memory Leak Prevention
2896

2997
- Added observer tracking using Set to manage all MutationObservers
3098
- Added cleanup on element removal to prevent dangling observers
3199
- Added global cleanup on window unload
32100
- Added observer cleanup when observed elements are removed from DOM
33101

34-
#### Code Quality
102+
### Code Quality
35103

36104
- Fixed code formatting and linting issues flagged by Biome
37105

38-
#### Development Setup
106+
### Development Setup
39107

40108
- Added .vscode settings with Biome extension recommendation
41109

42-
#### Platform Updates
110+
### Platform Updates
43111

44112
- Updated code in both Chrome and Firefox extensions

extensions/chrome/CHANGELOG.md

-35
This file was deleted.

extensions/chrome/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "thinking-claude",
3-
"version": "3.1.3",
3+
"version": "3.1.5",
44
"description": "Chrome extension for letting Claude think like a real human",
55
"type": "module",
66
"scripts": {

extensions/chrome/public/manifest.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{
22
"manifest_version": 3,
33
"name": "Thinking Claude",
4-
"version": "3.1.3",
4+
"version": "3.1.5",
55
"description": "Chrome extension for letting Claude think like a real human",
6+
"background": {
7+
"service_worker": "background.js"
8+
},
69
"content_scripts": [
710
{
811
"matches": ["https://*.claude.ai/*"],
912
"js": ["content.js"],
10-
"css": ["styles.css"]
13+
"css": ["content.css"]
1114
}
1215
],
1316
"icons": {
@@ -23,5 +26,5 @@
2326
},
2427
"default_title": "Thinking Claude"
2528
},
26-
"permissions": ["storage"]
29+
"permissions": ["storage", "webNavigation", "tabs"]
2730
}

0 commit comments

Comments
 (0)