neon_sakura 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.ai-reviewer/README.md +182 -0
- data/.ai-reviewer/ai-reviewer.sh +56 -0
- data/.ai-reviewer/build-system-prompt.sh +136 -0
- data/.ai-reviewer/extract-claude-sections.sh +32 -0
- data/.ai-reviewer/test-ai-reviewer.sh +40 -0
- data/.ai-reviewer-config.yml +190 -0
- data/.github/dependabot.yml +12 -0
- data/.github/settings.yml +70 -0
- data/.github/workflows/ai-pr-review-on-comment.yml +384 -0
- data/.github/workflows/ai-pr-review.yml +328 -0
- data/.github/workflows/license-check.yml +78 -0
- data/.github/workflows/lint.yml +79 -0
- data/.github/workflows/security.yml +131 -0
- data/.github/workflows/semgrep.yml +26 -0
- data/.github/workflows/test.yml +44 -0
- data/.gitignore +75 -0
- data/.rubocop.yml +33 -0
- data/.ruby-version +1 -0
- data/.simplecov +14 -0
- data/.stylelintignore +10 -0
- data/.stylelintrc.json +37 -0
- data/AGENTS.md +51 -0
- data/CHANGELOG.md +568 -0
- data/CLAUDE.md +632 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +327 -0
- data/LICENSE +21 -0
- data/README.md +1209 -0
- data/Rakefile +25 -0
- data/app/assets/images/cherry_blossom.svg +1525 -0
- data/app/assets/images/cherry_blossom_tree.png +0 -0
- data/app/assets/images/prysm-icon.png +0 -0
- data/app/assets/stylesheets/base.css +29 -0
- data/app/assets/stylesheets/components.css +1652 -0
- data/app/assets/stylesheets/forms.css +152 -0
- data/app/assets/stylesheets/loading.css +145 -0
- data/app/assets/stylesheets/neon_sakura.css +40 -0
- data/app/assets/stylesheets/pagy-tailwind.css +120 -0
- data/app/assets/stylesheets/theme-default.css +40 -0
- data/app/assets/stylesheets/theme-green.css +84 -0
- data/app/assets/stylesheets/theme-purple.css +94 -0
- data/app/assets/stylesheets/theme-red.css +84 -0
- data/app/assets/stylesheets/utility-borders.css +29 -0
- data/app/assets/stylesheets/utility-colors.css +185 -0
- data/app/assets/stylesheets/utility-effects.css +123 -0
- data/app/assets/stylesheets/utility-gradients.css +158 -0
- data/app/assets/stylesheets/utility-layout.css +132 -0
- data/app/assets/stylesheets/utility-reset.css +13 -0
- data/app/assets/stylesheets/utility-responsive.css +145 -0
- data/app/assets/stylesheets/utility-sizing.css +99 -0
- data/app/assets/stylesheets/utility-spacing.css +174 -0
- data/app/assets/stylesheets/utility-typography.css +97 -0
- data/app/controllers/errors_controller.rb +120 -0
- data/app/controllers/style_guide_controller.rb +117 -0
- data/app/helpers/errors_helper.rb +12 -0
- data/app/helpers/neon_sakura/navbar_helper.rb +43 -0
- data/app/helpers/style_guide_helper.rb +36 -0
- data/app/javascript/neon_sakura/dropdown.js +22 -0
- data/app/javascript/neon_sakura/navbar.js +71 -0
- data/app/javascript/neon_sakura/theme_switcher.js +187 -0
- data/app/views/errors/show.html.erb +105 -0
- data/app/views/layouts/error.html.erb +19 -0
- data/app/views/layouts/mission_control/jobs/_application_selection.html.erb +14 -0
- data/app/views/layouts/mission_control/jobs/_navigation.html.erb +21 -0
- data/app/views/layouts/mission_control/jobs/application.html.erb +453 -0
- data/app/views/layouts/style_guide.html.erb +416 -0
- data/app/views/shared/_file_upload.html.erb +184 -0
- data/app/views/shared/_footer.html.erb +23 -0
- data/app/views/shared/_header.html.erb +42 -0
- data/app/views/shared/_navbar.html.erb +306 -0
- data/app/views/shared/_profile_image_selector.html.erb +165 -0
- data/app/views/shared/_theme_switcher.html.erb +64 -0
- data/app/views/shared/icons/_adjustments.html.erb +10 -0
- data/app/views/shared/icons/_alert_circle.html.erb +3 -0
- data/app/views/shared/icons/_alert_triangle.html.erb +3 -0
- data/app/views/shared/icons/_archive.html.erb +3 -0
- data/app/views/shared/icons/_arrow_down.html.erb +3 -0
- data/app/views/shared/icons/_arrow_left.html.erb +3 -0
- data/app/views/shared/icons/_arrow_up.html.erb +3 -0
- data/app/views/shared/icons/_arrows_pointing_in.html.erb +10 -0
- data/app/views/shared/icons/_arrows_pointing_out.html.erb +10 -0
- data/app/views/shared/icons/_artemis_logo.html.erb +26 -0
- data/app/views/shared/icons/_auth_banner.html.erb +1 -0
- data/app/views/shared/icons/_bars.html.erb +10 -0
- data/app/views/shared/icons/_bell.html.erb +3 -0
- data/app/views/shared/icons/_book.html.erb +3 -0
- data/app/views/shared/icons/_bookmark.html.erb +3 -0
- data/app/views/shared/icons/_box.html.erb +3 -0
- data/app/views/shared/icons/_brain.html.erb +3 -0
- data/app/views/shared/icons/_briefcase.html.erb +3 -0
- data/app/views/shared/icons/_calendar.html.erb +3 -0
- data/app/views/shared/icons/_camera.html.erb +4 -0
- data/app/views/shared/icons/_chart_bar.html.erb +3 -0
- data/app/views/shared/icons/_chart_line.html.erb +10 -0
- data/app/views/shared/icons/_chart_pie.html.erb +11 -0
- data/app/views/shared/icons/_chat.html.erb +3 -0
- data/app/views/shared/icons/_check.html.erb +3 -0
- data/app/views/shared/icons/_check_circle.html.erb +3 -0
- data/app/views/shared/icons/_cherry_blossom.html.erb +1516 -0
- data/app/views/shared/icons/_cherry_blossom_silhouette.html.erb +1016 -0
- data/app/views/shared/icons/_cherry_blossom_single_flower.html.erb +1125 -0
- data/app/views/shared/icons/_cherry_blossom_tree.html.erb +159 -0
- data/app/views/shared/icons/_chevron_down.html.erb +3 -0
- data/app/views/shared/icons/_chevron_right.html.erb +9 -0
- data/app/views/shared/icons/_clipboard.html.erb +3 -0
- data/app/views/shared/icons/_clock.html.erb +3 -0
- data/app/views/shared/icons/_close.html.erb +3 -0
- data/app/views/shared/icons/_cog.html.erb +4 -0
- data/app/views/shared/icons/_crop.html.erb +10 -0
- data/app/views/shared/icons/_crown.html.erb +3 -0
- data/app/views/shared/icons/_disc.html.erb +3 -0
- data/app/views/shared/icons/_download.html.erb +3 -0
- data/app/views/shared/icons/_dragonfly.html.erb +58 -0
- data/app/views/shared/icons/_duplicate.html.erb +4 -0
- data/app/views/shared/icons/_edit.html.erb +3 -0
- data/app/views/shared/icons/_envelope.html.erb +3 -0
- data/app/views/shared/icons/_eraser.html.erb +10 -0
- data/app/views/shared/icons/_external_link.html.erb +3 -0
- data/app/views/shared/icons/_eye.html.erb +4 -0
- data/app/views/shared/icons/_file_csv.html.erb +10 -0
- data/app/views/shared/icons/_file_export.html.erb +10 -0
- data/app/views/shared/icons/_file_image.html.erb +10 -0
- data/app/views/shared/icons/_file_import.html.erb +10 -0
- data/app/views/shared/icons/_file_question.html.erb +6 -0
- data/app/views/shared/icons/_film.html.erb +3 -0
- data/app/views/shared/icons/_filter.html.erb +3 -0
- data/app/views/shared/icons/_folder.html.erb +3 -0
- data/app/views/shared/icons/_folder_open.html.erb +3 -0
- data/app/views/shared/icons/_folder_plus.html.erb +3 -0
- data/app/views/shared/icons/_globe.html.erb +3 -0
- data/app/views/shared/icons/_google.html.erb +11 -0
- data/app/views/shared/icons/_heart.html.erb +3 -0
- data/app/views/shared/icons/_heart_broken.html.erb +11 -0
- data/app/views/shared/icons/_heart_pulse.html.erb +4 -0
- data/app/views/shared/icons/_history.html.erb +11 -0
- data/app/views/shared/icons/_home.html.erb +10 -0
- data/app/views/shared/icons/_image.html.erb +3 -0
- data/app/views/shared/icons/_inbox.html.erb +3 -0
- data/app/views/shared/icons/_info_circle.html.erb +10 -0
- data/app/views/shared/icons/_key.html.erb +3 -0
- data/app/views/shared/icons/_layers.html.erb +10 -0
- data/app/views/shared/icons/_lightbulb.html.erb +10 -0
- data/app/views/shared/icons/_lightning.html.erb +3 -0
- data/app/views/shared/icons/_list.html.erb +3 -0
- data/app/views/shared/icons/_lock.html.erb +3 -0
- data/app/views/shared/icons/_logout.html.erb +3 -0
- data/app/views/shared/icons/_magazine.html.erb +3 -0
- data/app/views/shared/icons/_magic.html.erb +3 -0
- data/app/views/shared/icons/_minus.html.erb +10 -0
- data/app/views/shared/icons/_mobile.html.erb +10 -0
- data/app/views/shared/icons/_moon.html.erb +3 -0
- data/app/views/shared/icons/_network.html.erb +10 -0
- data/app/views/shared/icons/_new_item_banner.html.erb +1 -0
- data/app/views/shared/icons/_ouroboros.html.erb +24 -0
- data/app/views/shared/icons/_package.html.erb +3 -0
- data/app/views/shared/icons/_palette.html.erb +3 -0
- data/app/views/shared/icons/_paper_plane.html.erb +10 -0
- data/app/views/shared/icons/_photo.html.erb +10 -0
- data/app/views/shared/icons/_play.html.erb +4 -0
- data/app/views/shared/icons/_plus.html.erb +3 -0
- data/app/views/shared/icons/_pocket.html.erb +11 -0
- data/app/views/shared/icons/_prysm-icon.html.erb +34 -0
- data/app/views/shared/icons/_prysm.html.erb +13 -0
- data/app/views/shared/icons/_pushbullet-1.html.erb +29 -0
- data/app/views/shared/icons/_pushbullet-2.html.erb +2 -0
- data/app/views/shared/icons/_puzzle.html.erb +10 -0
- data/app/views/shared/icons/_qrcode.html.erb +3 -0
- data/app/views/shared/icons/_question.html.erb +3 -0
- data/app/views/shared/icons/_receipt.html.erb +10 -0
- data/app/views/shared/icons/_redo.html.erb +3 -0
- data/app/views/shared/icons/_refresh.html.erb +3 -0
- data/app/views/shared/icons/_rocket.html.erb +10 -0
- data/app/views/shared/icons/_rss.html.erb +3 -0
- data/app/views/shared/icons/_save.html.erb +3 -0
- data/app/views/shared/icons/_search.html.erb +3 -0
- data/app/views/shared/icons/_search_minus.html.erb +10 -0
- data/app/views/shared/icons/_search_plus.html.erb +10 -0
- data/app/views/shared/icons/_server_error.html.erb +6 -0
- data/app/views/shared/icons/_share.html.erb +3 -0
- data/app/views/shared/icons/_shield_check.html.erb +3 -0
- data/app/views/shared/icons/_sign_in.html.erb +3 -0
- data/app/views/shared/icons/_spinner.html.erb +4 -0
- data/app/views/shared/icons/_star.html.erb +3 -0
- data/app/views/shared/icons/_store.html.erb +10 -0
- data/app/views/shared/icons/_sun.html.erb +3 -0
- data/app/views/shared/icons/_sync.html.erb +3 -0
- data/app/views/shared/icons/_table.html.erb +3 -0
- data/app/views/shared/icons/_tag.html.erb +3 -0
- data/app/views/shared/icons/_tags.html.erb +11 -0
- data/app/views/shared/icons/_tools.html.erb +4 -0
- data/app/views/shared/icons/_trash.html.erb +3 -0
- data/app/views/shared/icons/_undo.html.erb +3 -0
- data/app/views/shared/icons/_unlock.html.erb +3 -0
- data/app/views/shared/icons/_upload.html.erb +3 -0
- data/app/views/shared/icons/_user.html.erb +3 -0
- data/app/views/shared/icons/_user_circle.html.erb +10 -0
- data/app/views/shared/icons/_user_plus.html.erb +10 -0
- data/app/views/shared/icons/_video.html.erb +3 -0
- data/app/views/shared/icons/_wrench.html.erb +11 -0
- data/app/views/style_guide/index.html.erb +77 -0
- data/app/views/style_guide/sections/_alerts.html.erb +114 -0
- data/app/views/style_guide/sections/_badges.html.erb +78 -0
- data/app/views/style_guide/sections/_buttons.html.erb +130 -0
- data/app/views/style_guide/sections/_cards.html.erb +84 -0
- data/app/views/style_guide/sections/_colors.html.erb +106 -0
- data/app/views/style_guide/sections/_file_upload.html.erb +135 -0
- data/app/views/style_guide/sections/_forms.html.erb +129 -0
- data/app/views/style_guide/sections/_gradients.html.erb +253 -0
- data/app/views/style_guide/sections/_header.html.erb +12 -0
- data/app/views/style_guide/sections/_icons.html.erb +55 -0
- data/app/views/style_guide/sections/_images.html.erb +40 -0
- data/app/views/style_guide/sections/_loading.html.erb +242 -0
- data/app/views/style_guide/sections/_pagination.html.erb +212 -0
- data/app/views/style_guide/sections/_profile_components.html.erb +203 -0
- data/app/views/style_guide/sections/_theme_switcher.html.erb +72 -0
- data/app/views/style_guide/sections/_typography.html.erb +65 -0
- data/bin/ai-optimize-claude-md +540 -0
- data/bin/ai-review-local +345 -0
- data/bin/ai-security-review +585 -0
- data/bin/brakeman +9 -0
- data/bin/install-hooks +57 -0
- data/bin/rake +7 -0
- data/bin/rubocop +10 -0
- data/bin/verify_setup.rb +31 -0
- data/config/brakeman.ignore +28 -0
- data/config/initializers/neon_sakura.rb +15 -0
- data/config/license_overrides.yml +13 -0
- data/config/routes.rb +21 -0
- data/config/theme_mappings.yml +61 -0
- data/docs/PRYSM_ASSETS.md +210 -0
- data/docs/plans/extract_ai_reviewer_plan.md +151 -0
- data/docs/plans/neon_sakura_gem_plan.md +138 -0
- data/lib/neon_sakura/configuration.rb +94 -0
- data/lib/neon_sakura/engine.rb +48 -0
- data/lib/neon_sakura/icon_helper.rb +54 -0
- data/lib/neon_sakura/profile_helper.rb +24 -0
- data/lib/neon_sakura/stylesheet_helper.rb +40 -0
- data/lib/neon_sakura/theme_helper.rb +63 -0
- data/lib/neon_sakura/theme_importer.rb +112 -0
- data/lib/neon_sakura/version.rb +5 -0
- data/lib/neon_sakura.rb +13 -0
- data/neon_sakura.gemspec +50 -0
- data/package.json +18 -0
- data/scripts/git-hooks/post-merge +132 -0
- data/scripts/git-hooks/pre-commit +123 -0
- data/scripts/git-hooks/pre-push +127 -0
- data/scripts/license-check.rb +587 -0
- data/settings.local.json +12 -0
- data/yarn.lock +778 -0
- metadata +503 -0
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# AI-powered CLAUDE.md optimization
|
|
3
|
+
# Analyzes and suggests improvements to reduce token usage while maintaining clarity
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# bin/ai-optimize-claude-md [OPTIONS] [BASE_BRANCH] [OLLAMA_URL]
|
|
7
|
+
# bin/ai-optimize-claude-md --help | -h
|
|
8
|
+
#
|
|
9
|
+
# Options:
|
|
10
|
+
# -m, --model MODEL Specify the model to use (default: codestral:latest)
|
|
11
|
+
# -i, --interactive Interactively select model from available models
|
|
12
|
+
# -o, --output FILE Output file for optimized version (default: CLAUDE.md.optimized)
|
|
13
|
+
# -d, --diff Show changes to CLAUDE.md between branches (no optimization)
|
|
14
|
+
# --apply Apply changes directly to CLAUDE.md (creates backup)
|
|
15
|
+
# --help, -h Show this help message
|
|
16
|
+
#
|
|
17
|
+
# Arguments:
|
|
18
|
+
# BASE_BRANCH - Branch to compare CLAUDE.md against (optional, for -d mode)
|
|
19
|
+
# OLLAMA_URL - Ollama server URL (default: $OLLAMA_URL env var or http://localhost:11434)
|
|
20
|
+
#
|
|
21
|
+
# Examples:
|
|
22
|
+
# bin/ai-optimize-claude-md # Optimize current CLAUDE.md
|
|
23
|
+
# bin/ai-optimize-claude-md -d main # Show CLAUDE.md changes vs main
|
|
24
|
+
# bin/ai-optimize-claude-md -i # Interactively select model
|
|
25
|
+
# bin/ai-optimize-claude-md -o custom.md # Save to custom file
|
|
26
|
+
# bin/ai-optimize-claude-md --apply # Apply changes to CLAUDE.md (with backup)
|
|
27
|
+
|
|
28
|
+
# Load shared library
|
|
29
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
30
|
+
if [ -f "$SCRIPT_DIR/../lib/ai-script-base.sh" ]; then
|
|
31
|
+
# shellcheck source=../lib/ai-script-base.sh
|
|
32
|
+
source "$SCRIPT_DIR/../lib/ai-script-base.sh"
|
|
33
|
+
else
|
|
34
|
+
echo "Error: Shared library not found at $SCRIPT_DIR/../lib/ai-script-base.sh"
|
|
35
|
+
exit 1
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
# Show help
|
|
39
|
+
show_help() {
|
|
40
|
+
cat << EOF
|
|
41
|
+
AI CLAUDE.md Optimizer - Reduce token usage while maintaining clarity
|
|
42
|
+
|
|
43
|
+
USAGE:
|
|
44
|
+
bin/ai-optimize-claude-md [OPTIONS] [BASE_BRANCH] [OLLAMA_URL]
|
|
45
|
+
bin/ai-optimize-claude-md --help | -h
|
|
46
|
+
|
|
47
|
+
OPTIONS:
|
|
48
|
+
-m, --model MODEL Specify the model to use (default: codestral:latest)
|
|
49
|
+
-i, --interactive Interactively select model from available models
|
|
50
|
+
-o, --output FILE Output file for optimized version (default: CLAUDE.md.optimized)
|
|
51
|
+
-d, --diff Show CLAUDE.md changes between branches (no optimization)
|
|
52
|
+
--apply Apply changes directly to CLAUDE.md (creates backup)
|
|
53
|
+
--help, -h Show this help message
|
|
54
|
+
|
|
55
|
+
ARGUMENTS:
|
|
56
|
+
BASE_BRANCH Branch to compare CLAUDE.md against (required for -d mode)
|
|
57
|
+
OLLAMA_URL Ollama server URL (default: \$OLLAMA_URL env var or http://localhost:11434)
|
|
58
|
+
|
|
59
|
+
EXAMPLES:
|
|
60
|
+
# Optimize current CLAUDE.md
|
|
61
|
+
bin/ai-optimize-claude-md
|
|
62
|
+
|
|
63
|
+
# Show changes to CLAUDE.md between current branch and main
|
|
64
|
+
bin/ai-optimize-claude-md -d main
|
|
65
|
+
|
|
66
|
+
# Review CLAUDE.md changes with AI analysis
|
|
67
|
+
bin/ai-optimize-claude-md -d develop -m llama3:latest
|
|
68
|
+
|
|
69
|
+
# Interactively select model
|
|
70
|
+
bin/ai-optimize-claude-md -i
|
|
71
|
+
|
|
72
|
+
# Use specific model
|
|
73
|
+
bin/ai-optimize-claude-md -m llama3:latest
|
|
74
|
+
|
|
75
|
+
# Save to custom file
|
|
76
|
+
bin/ai-optimize-claude-md -o custom.md
|
|
77
|
+
|
|
78
|
+
# Apply changes directly (with backup)
|
|
79
|
+
bin/ai-optimize-claude-md --apply
|
|
80
|
+
|
|
81
|
+
# Use remote Ollama server
|
|
82
|
+
bin/ai-optimize-claude-md main http://server:11434
|
|
83
|
+
|
|
84
|
+
WHAT IT DOES:
|
|
85
|
+
- Analyzes CLAUDE.md for redundancy and verbosity
|
|
86
|
+
- Suggests more concise wording
|
|
87
|
+
- Identifies duplicate information
|
|
88
|
+
- Recommends better organization
|
|
89
|
+
- Estimates token savings
|
|
90
|
+
- Maintains all critical information
|
|
91
|
+
|
|
92
|
+
REQUIREMENTS:
|
|
93
|
+
- Ollama installed and running (https://ollama.ai)
|
|
94
|
+
- At least one model pulled (e.g., ollama pull codestral:latest)
|
|
95
|
+
- CLAUDE.md file in current directory (or in compared branch for -d mode)
|
|
96
|
+
|
|
97
|
+
ENVIRONMENT VARIABLES:
|
|
98
|
+
OLLAMA_URL Ollama server URL (overridden by command line argument)
|
|
99
|
+
Example: export OLLAMA_URL=http://192.168.1.100:11434
|
|
100
|
+
|
|
101
|
+
OUTPUT:
|
|
102
|
+
- Optimization suggestions: docs/ai-reviews/claude-md-optimization-YYYYMMDD-HHMMSS.md
|
|
103
|
+
- Optimized version: CLAUDE.md.optimized (or specified file)
|
|
104
|
+
- Backup (if --apply): CLAUDE.md.backup-YYYYMMDD-HHMMSS
|
|
105
|
+
- Diff analysis (with -d): docs/ai-reviews/claude-md-diff-YYYYMMDD-HHMMSS.md
|
|
106
|
+
|
|
107
|
+
MORE INFO:
|
|
108
|
+
See docs/AI_PR_REVIEWER.md for full documentation
|
|
109
|
+
EOF
|
|
110
|
+
exit 0
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
# Parse options
|
|
114
|
+
INTERACTIVE_MODE=false
|
|
115
|
+
DIFF_MODE=false
|
|
116
|
+
MODEL_NAME="codestral:latest"
|
|
117
|
+
OUTPUT_FILE="CLAUDE.md.optimized"
|
|
118
|
+
APPLY_CHANGES=false
|
|
119
|
+
BASE_BRANCH=""
|
|
120
|
+
OLLAMA_URL=""
|
|
121
|
+
|
|
122
|
+
while [[ $# -gt 0 ]]; do
|
|
123
|
+
case $1 in
|
|
124
|
+
--help|-h)
|
|
125
|
+
show_help
|
|
126
|
+
;;
|
|
127
|
+
-i|--interactive)
|
|
128
|
+
INTERACTIVE_MODE=true
|
|
129
|
+
shift
|
|
130
|
+
;;
|
|
131
|
+
-d|--diff)
|
|
132
|
+
DIFF_MODE=true
|
|
133
|
+
shift
|
|
134
|
+
;;
|
|
135
|
+
-m|--model)
|
|
136
|
+
if [ -z "${2:-}" ]; then
|
|
137
|
+
log_error "Option -m/--model requires a model name"
|
|
138
|
+
exit 1
|
|
139
|
+
fi
|
|
140
|
+
MODEL_NAME="$2"
|
|
141
|
+
shift 2
|
|
142
|
+
;;
|
|
143
|
+
-o|--output)
|
|
144
|
+
if [ -z "${2:-}" ]; then
|
|
145
|
+
log_error "Option -o/--output requires a file path"
|
|
146
|
+
exit 1
|
|
147
|
+
fi
|
|
148
|
+
OUTPUT_FILE="$2"
|
|
149
|
+
shift 2
|
|
150
|
+
;;
|
|
151
|
+
--apply)
|
|
152
|
+
APPLY_CHANGES=true
|
|
153
|
+
shift
|
|
154
|
+
;;
|
|
155
|
+
*)
|
|
156
|
+
# Positional arguments
|
|
157
|
+
if [ -z "$BASE_BRANCH" ]; then
|
|
158
|
+
BASE_BRANCH="$1"
|
|
159
|
+
elif [ -z "$OLLAMA_URL" ]; then
|
|
160
|
+
OLLAMA_URL="$1"
|
|
161
|
+
else
|
|
162
|
+
log_error "Unknown argument: $1"
|
|
163
|
+
echo "Run 'bin/ai-optimize-claude-md --help' for usage information"
|
|
164
|
+
exit 1
|
|
165
|
+
fi
|
|
166
|
+
shift
|
|
167
|
+
;;
|
|
168
|
+
esac
|
|
169
|
+
done
|
|
170
|
+
|
|
171
|
+
# Set defaults
|
|
172
|
+
OLLAMA_URL=$(get_ollama_url "$OLLAMA_URL")
|
|
173
|
+
|
|
174
|
+
# Validate diff mode requirements
|
|
175
|
+
if [ "$DIFF_MODE" = true ] && [ -z "$BASE_BRANCH" ]; then
|
|
176
|
+
log_error "Diff mode (-d) requires a base branch to compare against"
|
|
177
|
+
echo "Example: bin/ai-optimize-claude-md -d main"
|
|
178
|
+
exit 1
|
|
179
|
+
fi
|
|
180
|
+
|
|
181
|
+
# Create temp directory
|
|
182
|
+
TEMP_DIR=$(create_temp_dir)
|
|
183
|
+
|
|
184
|
+
if [ "$DIFF_MODE" = true ]; then
|
|
185
|
+
log_info "Starting CLAUDE.md diff analysis..."
|
|
186
|
+
log_info "Comparing against: ${CYAN}$BASE_BRANCH${NC}"
|
|
187
|
+
else
|
|
188
|
+
log_info "Starting CLAUDE.md optimization analysis..."
|
|
189
|
+
fi
|
|
190
|
+
log_info "Ollama server: ${CYAN}$OLLAMA_URL${NC}"
|
|
191
|
+
echo ""
|
|
192
|
+
|
|
193
|
+
# Check if Ollama is accessible
|
|
194
|
+
check_ollama_server "$OLLAMA_URL" || exit 1
|
|
195
|
+
echo ""
|
|
196
|
+
|
|
197
|
+
# Interactive model selection if requested
|
|
198
|
+
if [ "$INTERACTIVE_MODE" = true ]; then
|
|
199
|
+
MODEL_NAME=$(select_ollama_model "$OLLAMA_URL" "$MODEL_NAME")
|
|
200
|
+
echo ""
|
|
201
|
+
log_info "Selected model: ${CYAN}$MODEL_NAME${NC}"
|
|
202
|
+
echo ""
|
|
203
|
+
fi
|
|
204
|
+
|
|
205
|
+
# Ensure model is available
|
|
206
|
+
ensure_ollama_model "$OLLAMA_URL" "$MODEL_NAME" || exit 1
|
|
207
|
+
echo ""
|
|
208
|
+
|
|
209
|
+
# ============================================================================
|
|
210
|
+
# Read and Analyze CLAUDE.md
|
|
211
|
+
# ============================================================================
|
|
212
|
+
|
|
213
|
+
log_section "📊 Analyzing CLAUDE.md"
|
|
214
|
+
|
|
215
|
+
if [ "$DIFF_MODE" = true ]; then
|
|
216
|
+
# Diff mode: compare CLAUDE.md between branches
|
|
217
|
+
log_info "Getting CLAUDE.md diff between branches..."
|
|
218
|
+
|
|
219
|
+
CURRENT_BRANCH=$(get_current_branch)
|
|
220
|
+
|
|
221
|
+
# Get diff for CLAUDE.md
|
|
222
|
+
CLAUDE_DIFF=$(git diff "$BASE_BRANCH...HEAD" -- CLAUDE.md 2>/dev/null || git diff "$BASE_BRANCH..HEAD" -- CLAUDE.md 2>/dev/null || echo "")
|
|
223
|
+
|
|
224
|
+
if [ -z "$CLAUDE_DIFF" ]; then
|
|
225
|
+
log_warning "No changes to CLAUDE.md between $BASE_BRANCH and $CURRENT_BRANCH"
|
|
226
|
+
exit 0
|
|
227
|
+
fi
|
|
228
|
+
|
|
229
|
+
DIFF_LENGTH=${#CLAUDE_DIFF}
|
|
230
|
+
DIFF_LINES=$(echo "$CLAUDE_DIFF" | wc -l | tr -d ' ')
|
|
231
|
+
log_success "CLAUDE.md diff generated ($DIFF_LINES lines, $DIFF_LENGTH chars)"
|
|
232
|
+
|
|
233
|
+
# Get current version
|
|
234
|
+
CLAUDE_CONTENT=$(cat CLAUDE.md 2>/dev/null || echo "CLAUDE.md not found in current branch")
|
|
235
|
+
CLAUDE_LENGTH=${#CLAUDE_CONTENT}
|
|
236
|
+
|
|
237
|
+
echo ""
|
|
238
|
+
else
|
|
239
|
+
# Optimization mode: analyze current CLAUDE.md
|
|
240
|
+
if [ ! -f "CLAUDE.md" ]; then
|
|
241
|
+
log_error "CLAUDE.md not found in current directory"
|
|
242
|
+
exit 1
|
|
243
|
+
fi
|
|
244
|
+
|
|
245
|
+
log_info "Reading CLAUDE.md..."
|
|
246
|
+
CLAUDE_CONTENT=$(cat CLAUDE.md)
|
|
247
|
+
CLAUDE_LENGTH=${#CLAUDE_CONTENT}
|
|
248
|
+
CLAUDE_LINES=$(echo "$CLAUDE_CONTENT" | wc -l | tr -d ' ')
|
|
249
|
+
log_success "CLAUDE.md loaded ($CLAUDE_LINES lines, $CLAUDE_LENGTH chars)"
|
|
250
|
+
echo ""
|
|
251
|
+
fi
|
|
252
|
+
|
|
253
|
+
# ============================================================================
|
|
254
|
+
# Build Optimization-Focused System Prompt
|
|
255
|
+
# ============================================================================
|
|
256
|
+
|
|
257
|
+
log_info "Building system prompt..."
|
|
258
|
+
|
|
259
|
+
if [ "$DIFF_MODE" = true ]; then
|
|
260
|
+
SYSTEM_PROMPT=$(cat <<'SYSEND'
|
|
261
|
+
You are an expert technical writer reviewing changes to project documentation (CLAUDE.md).
|
|
262
|
+
|
|
263
|
+
**Your Task:**
|
|
264
|
+
Analyze the changes made to CLAUDE.md between two branches and provide:
|
|
265
|
+
1. Summary of what changed and why
|
|
266
|
+
2. Assessment of whether changes improve or degrade the documentation
|
|
267
|
+
3. Recommendations for improvement
|
|
268
|
+
4. Token impact analysis (did changes increase/decrease token usage?)
|
|
269
|
+
|
|
270
|
+
**Focus Areas:**
|
|
271
|
+
- Clarity and conciseness of new/modified content
|
|
272
|
+
- Organization and structure changes
|
|
273
|
+
- Addition or removal of important information
|
|
274
|
+
- Impact on token usage
|
|
275
|
+
- Consistency with existing style
|
|
276
|
+
- Potential redundancy or verbosity
|
|
277
|
+
|
|
278
|
+
**Output Format:**
|
|
279
|
+
|
|
280
|
+
## Summary
|
|
281
|
+
[Brief description of changes made]
|
|
282
|
+
|
|
283
|
+
## Changes Analysis
|
|
284
|
+
[Detailed breakdown of key changes]
|
|
285
|
+
|
|
286
|
+
## Quality Assessment
|
|
287
|
+
[Are changes an improvement? Any concerns?]
|
|
288
|
+
|
|
289
|
+
## Token Impact
|
|
290
|
+
[Did changes increase/decrease token usage? By how much?]
|
|
291
|
+
|
|
292
|
+
## Recommendations
|
|
293
|
+
[Specific suggestions for improvement, if any]
|
|
294
|
+
|
|
295
|
+
**Guidelines:**
|
|
296
|
+
- Be CONSTRUCTIVE and SPECIFIC
|
|
297
|
+
- Focus on significant changes, not minor edits
|
|
298
|
+
- Provide actionable feedback
|
|
299
|
+
- Consider both content quality and token efficiency
|
|
300
|
+
SYSEND
|
|
301
|
+
)
|
|
302
|
+
else
|
|
303
|
+
SYSTEM_PROMPT=$(cat <<'SYSEND'
|
|
304
|
+
You are an expert technical writer and AI prompt engineer specializing in optimizing documentation for LLM token efficiency.
|
|
305
|
+
|
|
306
|
+
**Your Task:**
|
|
307
|
+
Analyze CLAUDE.md and provide an optimized version that:
|
|
308
|
+
1. Reduces token usage by 20-40% while maintaining ALL critical information
|
|
309
|
+
2. Eliminates redundancy and verbosity
|
|
310
|
+
3. Uses more concise language and formatting
|
|
311
|
+
4. Improves organization for better LLM comprehension
|
|
312
|
+
5. Maintains all essential technical details and instructions
|
|
313
|
+
|
|
314
|
+
**Optimization Strategies:**
|
|
315
|
+
|
|
316
|
+
1. **Eliminate Redundancy:**
|
|
317
|
+
- Remove repeated information
|
|
318
|
+
- Consolidate similar sections
|
|
319
|
+
- Use references instead of duplication
|
|
320
|
+
|
|
321
|
+
2. **Concise Language:**
|
|
322
|
+
- Replace verbose phrases with concise equivalents
|
|
323
|
+
- Use bullet points instead of paragraphs where appropriate
|
|
324
|
+
- Remove filler words and unnecessary explanations
|
|
325
|
+
|
|
326
|
+
3. **Efficient Formatting:**
|
|
327
|
+
- Use tables for structured data
|
|
328
|
+
- Use code blocks only when necessary
|
|
329
|
+
- Use shorter section names
|
|
330
|
+
- Use abbreviations for commonly repeated terms (define once)
|
|
331
|
+
|
|
332
|
+
4. **Better Organization:**
|
|
333
|
+
- Group related information
|
|
334
|
+
- Use clear hierarchy
|
|
335
|
+
- Front-load most important information
|
|
336
|
+
- Move less critical details to appendices
|
|
337
|
+
|
|
338
|
+
5. **Smart Compression:**
|
|
339
|
+
- Combine examples where possible
|
|
340
|
+
- Use "e.g." instead of listing all examples
|
|
341
|
+
- Reference external docs for detailed info
|
|
342
|
+
- Use "See X" for cross-references
|
|
343
|
+
|
|
344
|
+
**IMPORTANT:**
|
|
345
|
+
- DO NOT remove critical technical information
|
|
346
|
+
- DO NOT change code examples significantly
|
|
347
|
+
- DO NOT remove security guidelines
|
|
348
|
+
- DO maintain the same level of detail, just more concisely
|
|
349
|
+
|
|
350
|
+
**Output Format:**
|
|
351
|
+
|
|
352
|
+
## Analysis Summary
|
|
353
|
+
- Current size: [lines, characters, estimated tokens]
|
|
354
|
+
- Optimization opportunities: [brief list]
|
|
355
|
+
- Estimated savings: [X% reduction]
|
|
356
|
+
|
|
357
|
+
## Optimization Recommendations
|
|
358
|
+
[Numbered list of specific changes to make, with examples]
|
|
359
|
+
|
|
360
|
+
## Optimized CLAUDE.md
|
|
361
|
+
[Full optimized version between these markers:]
|
|
362
|
+
```markdown
|
|
363
|
+
[OPTIMIZED_START]
|
|
364
|
+
[... full optimized content ...]
|
|
365
|
+
[OPTIMIZED_END]
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
## Token Savings Breakdown
|
|
369
|
+
- Section 1: X tokens saved
|
|
370
|
+
- Section 2: Y tokens saved
|
|
371
|
+
- Total: Z tokens saved (~XX% reduction)
|
|
372
|
+
|
|
373
|
+
**Guidelines:**
|
|
374
|
+
- Be AGGRESSIVE with optimization but PRESERVE all critical info
|
|
375
|
+
- Aim for 20-40% reduction in length
|
|
376
|
+
- Maintain readability and clarity
|
|
377
|
+
- Keep the same structure but make it tighter
|
|
378
|
+
SYSEND
|
|
379
|
+
)
|
|
380
|
+
fi
|
|
381
|
+
|
|
382
|
+
log_success "System prompt built"
|
|
383
|
+
echo ""
|
|
384
|
+
|
|
385
|
+
# ============================================================================
|
|
386
|
+
# Build User Prompt
|
|
387
|
+
# ============================================================================
|
|
388
|
+
|
|
389
|
+
log_info "Building analysis prompt..."
|
|
390
|
+
|
|
391
|
+
if [ "$DIFF_MODE" = true ]; then
|
|
392
|
+
USER_PROMPT=$(cat <<USEREND
|
|
393
|
+
Please analyze the following changes to CLAUDE.md.
|
|
394
|
+
|
|
395
|
+
**Branch Comparison:** $CURRENT_BRANCH vs $BASE_BRANCH
|
|
396
|
+
|
|
397
|
+
**Changes to CLAUDE.md:**
|
|
398
|
+
\`\`\`diff
|
|
399
|
+
$CLAUDE_DIFF
|
|
400
|
+
\`\`\`
|
|
401
|
+
|
|
402
|
+
**Current CLAUDE.md (for context):**
|
|
403
|
+
\`\`\`markdown
|
|
404
|
+
${CLAUDE_CONTENT:0:5000}
|
|
405
|
+
... (truncated for brevity)
|
|
406
|
+
\`\`\`
|
|
407
|
+
|
|
408
|
+
Please provide a thorough analysis of these changes.
|
|
409
|
+
USEREND
|
|
410
|
+
)
|
|
411
|
+
else
|
|
412
|
+
USER_PROMPT=$(cat <<USEREND
|
|
413
|
+
Please analyze and optimize the following CLAUDE.md file.
|
|
414
|
+
|
|
415
|
+
Current statistics:
|
|
416
|
+
- Lines: $CLAUDE_LINES
|
|
417
|
+
- Characters: $CLAUDE_LENGTH
|
|
418
|
+
- Estimated tokens: ~$((CLAUDE_LENGTH / 4))
|
|
419
|
+
|
|
420
|
+
# Current CLAUDE.md Content
|
|
421
|
+
|
|
422
|
+
\`\`\`markdown
|
|
423
|
+
$CLAUDE_CONTENT
|
|
424
|
+
\`\`\`
|
|
425
|
+
|
|
426
|
+
Please provide an optimized version that reduces token usage by 20-40% while maintaining all critical information.
|
|
427
|
+
USEREND
|
|
428
|
+
)
|
|
429
|
+
fi
|
|
430
|
+
|
|
431
|
+
log_success "Analysis prompt built"
|
|
432
|
+
echo ""
|
|
433
|
+
|
|
434
|
+
# ============================================================================
|
|
435
|
+
# Call Ollama API for Optimization
|
|
436
|
+
# ============================================================================
|
|
437
|
+
|
|
438
|
+
log_info "Calling Ollama API for optimization analysis..."
|
|
439
|
+
echo -e "${CYAN}This may take a few minutes (large document)...${NC}"
|
|
440
|
+
echo ""
|
|
441
|
+
|
|
442
|
+
# Use more tokens for this analysis since we need a full rewrite
|
|
443
|
+
# num_ctx: 16384 (large context for full document)
|
|
444
|
+
# num_predict: 4000 (large output for optimized version)
|
|
445
|
+
RESULT=$(call_ollama_chat "$OLLAMA_URL" "$MODEL_NAME" "$SYSTEM_PROMPT" "$USER_PROMPT" 16384 4000)
|
|
446
|
+
|
|
447
|
+
# ============================================================================
|
|
448
|
+
# Process Results
|
|
449
|
+
# ============================================================================
|
|
450
|
+
|
|
451
|
+
if [ "$DIFF_MODE" = true ]; then
|
|
452
|
+
# Diff mode: save analysis only
|
|
453
|
+
log_info "Processing diff analysis..."
|
|
454
|
+
|
|
455
|
+
ANALYSIS_FILE=$(save_review "$RESULT" "docs/ai-reviews" "claude-md-diff")
|
|
456
|
+
|
|
457
|
+
log_success "Diff analysis saved to: ${CYAN}$ANALYSIS_FILE${NC}"
|
|
458
|
+
echo ""
|
|
459
|
+
|
|
460
|
+
# Display the analysis
|
|
461
|
+
ADDITIONAL_INFO="${CYAN}Branch:${NC} $CURRENT_BRANCH vs $BASE_BRANCH
|
|
462
|
+
${CYAN}Changes:${NC} $DIFF_LINES lines, $DIFF_LENGTH chars"
|
|
463
|
+
|
|
464
|
+
display_review "$RESULT" "CLAUDE.md Diff Analysis" "$MODEL_NAME" "$ADDITIONAL_INFO"
|
|
465
|
+
|
|
466
|
+
log_success "Diff analysis complete!"
|
|
467
|
+
exit 0
|
|
468
|
+
fi
|
|
469
|
+
|
|
470
|
+
# ============================================================================
|
|
471
|
+
# Extract Optimized Version (Optimization Mode Only)
|
|
472
|
+
# ============================================================================
|
|
473
|
+
|
|
474
|
+
log_info "Extracting optimized version..."
|
|
475
|
+
|
|
476
|
+
# Try to extract the optimized content between markers
|
|
477
|
+
OPTIMIZED_CONTENT=$(echo "$RESULT" | sed -n '/\[OPTIMIZED_START\]/,/\[OPTIMIZED_END\]/p' | sed '1d;$d')
|
|
478
|
+
|
|
479
|
+
if [ -z "$OPTIMIZED_CONTENT" ]; then
|
|
480
|
+
log_warning "Could not extract optimized content from markers, using full response"
|
|
481
|
+
OPTIMIZED_CONTENT="$RESULT"
|
|
482
|
+
fi
|
|
483
|
+
|
|
484
|
+
# Save the optimized version
|
|
485
|
+
echo "$OPTIMIZED_CONTENT" > "$OUTPUT_FILE"
|
|
486
|
+
OPTIMIZED_LENGTH=${#OPTIMIZED_CONTENT}
|
|
487
|
+
OPTIMIZED_LINES=$(echo "$OPTIMIZED_CONTENT" | wc -l | tr -d ' ')
|
|
488
|
+
log_success "Optimized version saved to: ${CYAN}$OUTPUT_FILE${NC}"
|
|
489
|
+
|
|
490
|
+
# Calculate savings
|
|
491
|
+
CHAR_SAVINGS=$((CLAUDE_LENGTH - OPTIMIZED_LENGTH))
|
|
492
|
+
PERCENT_SAVINGS=$((CHAR_SAVINGS * 100 / CLAUDE_LENGTH))
|
|
493
|
+
|
|
494
|
+
echo ""
|
|
495
|
+
log_info "Optimization Results:"
|
|
496
|
+
echo -e " ${CYAN}Original:${NC} $CLAUDE_LINES lines, $CLAUDE_LENGTH chars, ~$((CLAUDE_LENGTH / 4)) tokens"
|
|
497
|
+
echo -e " ${CYAN}Optimized:${NC} $OPTIMIZED_LINES lines, $OPTIMIZED_LENGTH chars, ~$((OPTIMIZED_LENGTH / 4)) tokens"
|
|
498
|
+
echo -e " ${GREEN}Savings:${NC} $((CLAUDE_LINES - OPTIMIZED_LINES)) lines, $CHAR_SAVINGS chars, ~$((CHAR_SAVINGS / 4)) tokens (${PERCENT_SAVINGS}%)"
|
|
499
|
+
echo ""
|
|
500
|
+
|
|
501
|
+
# Display the full analysis
|
|
502
|
+
ADDITIONAL_INFO="${CYAN}Original:${NC} $CLAUDE_LINES lines, $CLAUDE_LENGTH chars
|
|
503
|
+
${CYAN}Optimized:${NC} $OPTIMIZED_LINES lines, $OPTIMIZED_LENGTH chars
|
|
504
|
+
${CYAN}Savings:${NC} ${PERCENT_SAVINGS}% reduction"
|
|
505
|
+
|
|
506
|
+
display_review "$RESULT" "CLAUDE.md Optimization Analysis" "$MODEL_NAME" "$ADDITIONAL_INFO"
|
|
507
|
+
|
|
508
|
+
# Save analysis to file
|
|
509
|
+
ANALYSIS_FILE=$(save_review "$RESULT" "docs/ai-reviews" "claude-md-optimization")
|
|
510
|
+
log_success "Analysis saved to: ${CYAN}$ANALYSIS_FILE${NC}"
|
|
511
|
+
echo ""
|
|
512
|
+
|
|
513
|
+
# Apply changes if requested
|
|
514
|
+
if [ "$APPLY_CHANGES" = true ]; then
|
|
515
|
+
log_info "Applying changes to CLAUDE.md..."
|
|
516
|
+
|
|
517
|
+
# Create backup
|
|
518
|
+
BACKUP_FILE="CLAUDE.md.backup-$(date +%Y%m%d-%H%M%S)"
|
|
519
|
+
cp CLAUDE.md "$BACKUP_FILE"
|
|
520
|
+
log_success "Backup created: ${CYAN}$BACKUP_FILE${NC}"
|
|
521
|
+
|
|
522
|
+
# Apply changes
|
|
523
|
+
cp "$OUTPUT_FILE" CLAUDE.md
|
|
524
|
+
log_success "Changes applied to CLAUDE.md"
|
|
525
|
+
|
|
526
|
+
echo ""
|
|
527
|
+
log_warning "Please review the changes carefully before committing!"
|
|
528
|
+
log_info "Original backed up to: $BACKUP_FILE"
|
|
529
|
+
log_info "You can restore with: cp $BACKUP_FILE CLAUDE.md"
|
|
530
|
+
fi
|
|
531
|
+
|
|
532
|
+
echo ""
|
|
533
|
+
log_success "Optimization complete!"
|
|
534
|
+
log_info "Review the optimized version at: ${CYAN}$OUTPUT_FILE${NC}"
|
|
535
|
+
|
|
536
|
+
if [ "$APPLY_CHANGES" != true ]; then
|
|
537
|
+
log_info "To apply changes: bin/ai-optimize-claude-md --apply"
|
|
538
|
+
fi
|
|
539
|
+
|
|
540
|
+
exit 0
|