-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: consitent changelog * feat: trial * feat(gitguard): update docs * feat(gitguard): update docs * feat(gitguard): update docs * feat(gitguard): update docs * feat(gitguard): update docs * update docs * update documentation * update documentation * fff * fff * fff * feat(TOREMOVE): fff * fff * fff * fff * fff * fff * feat: initial gitguard setup * feat(gitguard): initial gitguard setup * feat(gitguard): fallback api and local api via ollama * feat: more gitguard improv * feat(gitguard): more gitguard improv * feat(gitguard): new PR * feat(gitguard): ai * feat(gitguard): add multi-AI suggestions and token count logging * feat(gitguard): tiktoken * feat(gitguard): integrate tiktoken for commit message generation * feat(gitguard): add commit cohesion analysis and enhanced installation script * feat(publisher): enable source maps in tsconfig * feat(gitguard): enhance installation and analysis functionalities
- Loading branch information
1 parent
fdb2a3a
commit c27dafd
Showing
30 changed files
with
1,781 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test | ||
TEST | ||
TEST | ||
TEST | ||
TEST | ||
TEST | ||
TEST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
test | ||
test | ||
test | ||
test | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { PackageContext } from '@siteed/publisher'; | ||
import { exec } from '@siteed/publisher'; | ||
|
||
export async function preRelease(context: PackageContext): Promise<void> { | ||
// Run tests | ||
await exec('{{packageManager}} test', { cwd: context.path }); | ||
|
||
// Run type checking | ||
await exec('{{packageManager}} typecheck', { cwd: context.path }); | ||
|
||
// Build the package | ||
await exec('{{packageManager}} build', { cwd: context.path }); | ||
} | ||
|
||
export async function postRelease(context: PackageContext): Promise<void> { | ||
// Clean up build artifacts | ||
await exec('{{packageManager}} clean', { cwd: context.path }); | ||
|
||
// Run any post-release notifications or integrations | ||
console.log(`Successfully released ${context.name}@${context.newVersion}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## [Unreleased] | ||
|
||
[unreleased]: https://github.com/owner/repo/tree/HEAD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# @siteed/gitguard | ||
|
||
A smart git assistant that improves commit quality using AI. It analyzes your changes, suggests meaningful commit messages, and helps maintain a clean git history in both standard and monorepo projects. | ||
|
||
## Core Features | ||
|
||
- 🤖 **Smart Git Wrapper** | ||
- Intercepts git commits to suggest improvements | ||
- Preserves existing git workflow | ||
- Zero config needed for basic usage | ||
- Automatic repository structure detection | ||
|
||
- 🔍 **Intelligent Change Analysis** | ||
- Parses and categorizes git diffs | ||
- Groups related changes | ||
- Detects breaking changes | ||
- Creates meaningful summaries | ||
|
||
- 📦 **Monorepo Support** | ||
- Automatic package detection | ||
- Smart commit splitting | ||
- Dependency-aware commit ordering | ||
- Scope suggestions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# GitGuard | ||
|
||
A smart Git commit hook that helps maintain high-quality, consistent commit messages using AI. | ||
|
||
## Installation | ||
|
||
### Quick Install (Recommended) | ||
```bash | ||
curl -sSL https://raw.githubusercontent.com/deeeed/universe/main/packages/gitguard/install.sh | CURL_INSTALL=1 bash | ||
``` | ||
|
||
### Development Install | ||
If you're working on GitGuard itself: | ||
```bash | ||
git clone https://github.com/deeeed/universe.git | ||
cd universe | ||
yarn install | ||
cd packages/gitguard | ||
./install.sh | ||
``` | ||
|
||
## Configuration | ||
|
||
1. Create a configuration file (optional): | ||
- Global: `~/.gitguard/config.json` | ||
- Project: `.gitguard/config.json` | ||
|
||
2. Set up environment variables (optional): | ||
- `AZURE_OPENAI_API_KEY` - for Azure OpenAI integration | ||
- `GITGUARD_USE_AI=1` - to enable AI suggestions | ||
- `GITGUARD_DEBUG=1` - to enable debug logging | ||
|
||
For more information, visit the [GitGuard documentation](https://deeeed.github.io/universe/packages/gitguard). | ||
|
||
## Features | ||
|
||
- 🎯 **Automatic Scope Detection**: Automatically detects the package scope based on changed files | ||
- 🤖 **Multi-Provider AI Suggestions**: Offers intelligent commit message suggestions using: | ||
- Azure OpenAI (with fallback model support) | ||
- Local Ollama models | ||
- 📦 **Monorepo Awareness**: Detects changes across multiple packages and suggests appropriate formatting | ||
- ✨ **Conventional Commits**: Enforces conventional commit format (`type(scope): description`) | ||
- 🔍 **Change Analysis**: Analyzes file changes to suggest appropriate commit types | ||
- 🚨 **Multi-Package Warning**: Alerts when changes span multiple packages, encouraging atomic commits | ||
|
||
## How It Works | ||
|
||
1. When you create a commit, the hook analyzes your staged changes | ||
2. If changes span multiple packages, it warns you and suggests splitting the commit | ||
3. You can request AI suggestions, which will provide 3 different commit message options with explanations | ||
4. If you skip AI suggestions or prefer manual input, it helps format your message with the correct scope and type | ||
5. For multi-package changes, it automatically adds an "Affected packages" section | ||
|
||
## Example Usage | ||
|
||
```bash | ||
# Regular commit | ||
git commit -m "update login form" | ||
# GitGuard will transform to: feat(auth): update login form | ||
|
||
# Multi-package changes | ||
git commit -m "update theme colors" | ||
# GitGuard will warn about multiple packages and suggest: | ||
# style(design-system): update theme colors | ||
# | ||
# Affected packages: | ||
# - @siteed/design-system | ||
# - @siteed/mobile-components | ||
``` | ||
|
||
## Configuration | ||
|
||
GitGuard can be configured using: | ||
- Global config: `~/.gitguard/config.json` | ||
- Local repo config: `.gitguard/config.json` | ||
- Environment variables | ||
|
||
### Configuration Options | ||
|
||
```json | ||
{ | ||
"auto_mode": false, // Skip prompts and use automatic formatting | ||
"use_ai": false, // Enable/disable AI suggestions by default | ||
"ai_provider": "azure", // AI provider to use ("azure" or "ollama") | ||
|
||
// Azure OpenAI Configuration | ||
"azure_endpoint": "", // Azure OpenAI endpoint | ||
"azure_deployment": "", // Primary Azure OpenAI deployment name | ||
"azure_fallback_deployment": "", // Fallback model if primary fails | ||
"azure_api_version": "", // Azure OpenAI API version | ||
|
||
// Ollama Configuration | ||
"ollama_host": "http://localhost:11434", // Ollama API host | ||
"ollama_model": "codellama", // Ollama model to use | ||
|
||
"debug": false // Enable debug logging | ||
} | ||
``` | ||
|
||
### Environment Variables | ||
|
||
- `GITGUARD_AUTO`: Enable automatic mode (1/true/yes) | ||
- `GITGUARD_USE_AI`: Enable AI suggestions (1/true/yes) | ||
- `GITGUARD_AI_PROVIDER`: AI provider to use ("azure" or "ollama") | ||
|
||
Azure OpenAI Variables: | ||
- `AZURE_OPENAI_ENDPOINT`: Azure OpenAI endpoint | ||
- `AZURE_OPENAI_API_KEY`: Azure OpenAI API key | ||
- `AZURE_OPENAI_DEPLOYMENT`: Azure OpenAI deployment name | ||
- `AZURE_OPENAI_API_VERSION`: Azure OpenAI API version | ||
|
||
Ollama Variables: | ||
- `OLLAMA_HOST`: Ollama API host | ||
- `OLLAMA_MODEL`: Ollama model to use | ||
|
||
Debug Variables: | ||
- `GITGUARD_DEBUG`: Enable debug logging (1/true/yes) | ||
|
||
### AI Provider Configuration | ||
|
||
#### Azure OpenAI | ||
GitGuard supports Azure OpenAI with fallback model capability. If the primary model fails (e.g., rate limits), it will automatically try the fallback model. | ||
|
||
```json | ||
{ | ||
"ai_provider": "azure", | ||
"azure_deployment": "gpt-4", | ||
"azure_fallback_deployment": "gpt-35-turbo" | ||
} | ||
``` | ||
|
||
#### Ollama | ||
For local AI processing, GitGuard supports Ollama. Make sure Ollama is running. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
|
||
# Exit on any error | ||
set -e | ||
|
||
# Colors for output | ||
GREEN='\033[0;32m' | ||
YELLOW='\033[1;33m' | ||
RED='\033[0;31m' | ||
NC='\033[0m' # No Color | ||
|
||
# Find git root directory | ||
GIT_ROOT=$(git rev-parse --show-toplevel) | ||
if [ $? -ne 0 ]; then | ||
echo -e "${RED}❌ Error: Not in a git repository${NC}" | ||
exit 1 | ||
fi | ||
|
||
# List of sample files and directories to remove | ||
SAMPLE_PATHS=( | ||
"packages/ui/src/Button.tsx" | ||
"packages/ui/tests/Button.test.tsx" | ||
"packages/ui/package.json" | ||
"packages/core/src/utils.ts" | ||
"packages/core/package.json" | ||
"docs/README.md" | ||
) | ||
|
||
# Remove sample files | ||
for path in "${SAMPLE_PATHS[@]}"; do | ||
full_path="$GIT_ROOT/$path" | ||
if [ -f "$full_path" ]; then | ||
rm "$full_path" | ||
echo "Removed: $path" | ||
fi | ||
done | ||
|
||
# Clean up empty directories | ||
SAMPLE_DIRS=( | ||
"packages/ui/src" | ||
"packages/ui/tests" | ||
"packages/ui" | ||
"packages/core/src" | ||
"packages/core" | ||
"docs" | ||
) | ||
|
||
for dir in "${SAMPLE_DIRS[@]}"; do | ||
full_dir="$GIT_ROOT/$dir" | ||
if [ -d "$full_dir" ] && [ -z "$(ls -A $full_dir)" ]; then | ||
rmdir "$full_dir" | ||
echo "Removed empty directory: $dir" | ||
fi | ||
done | ||
|
||
echo -e "${GREEN}✅ Sample files cleaned up successfully!${NC}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
|
||
# Exit on any error | ||
set -e | ||
|
||
# Colors for output | ||
GREEN='\033[0;32m' | ||
YELLOW='\033[1;33m' | ||
RED='\033[0;31m' | ||
NC='\033[0m' # No Color | ||
|
||
# Find git root directory | ||
GIT_ROOT=$(git rev-parse --show-toplevel) | ||
if [ $? -ne 0 ]; then | ||
echo -e "${RED}❌ Error: Not in a git repository${NC}" | ||
exit 1 | ||
fi | ||
|
||
# Create sample directories | ||
mkdir -p "$GIT_ROOT/packages/ui/src" | ||
mkdir -p "$GIT_ROOT/packages/ui/tests" | ||
mkdir -p "$GIT_ROOT/packages/core/src" | ||
mkdir -p "$GIT_ROOT/docs" | ||
|
||
# Create sample files | ||
cat > "$GIT_ROOT/packages/ui/package.json" << 'EOF' | ||
{ | ||
"name": "@project/ui", | ||
"version": "1.0.0" | ||
} | ||
EOF | ||
|
||
# Note the use of 'EOFBUTTON' to avoid confusion with backticks | ||
cat > "$GIT_ROOT/packages/ui/src/Button.tsx" << 'EOFBUTTON' | ||
import styled from 'styled-components'; | ||
export const Button = styled.button` | ||
background: blue; | ||
color: white; | ||
`; | ||
EOFBUTTON | ||
|
||
cat > "$GIT_ROOT/packages/ui/tests/Button.test.tsx" << 'EOF' | ||
import { render } from '@testing-library/react'; | ||
import { Button } from '../src/Button'; | ||
describe('Button', () => { | ||
it('renders correctly', () => { | ||
const { container } = render(<Button>Test</Button>); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); | ||
EOF | ||
|
||
cat > "$GIT_ROOT/packages/core/package.json" << 'EOF' | ||
{ | ||
"name": "@project/core", | ||
"version": "1.0.0" | ||
} | ||
EOF | ||
|
||
cat > "$GIT_ROOT/packages/core/src/utils.ts" << 'EOF' | ||
export function formatDate(date: Date): string { | ||
return date.toISOString(); | ||
} | ||
EOF | ||
|
||
cat > "$GIT_ROOT/docs/README.md" << 'EOF' | ||
# Project Documentation | ||
This is a sample documentation file. | ||
EOF | ||
|
||
echo -e "${GREEN}✅ Sample files created successfully!${NC}" | ||
echo -e "${YELLOW}Try creating commits with changes in different files to test GitGuard:${NC}" | ||
echo "- UI component changes (packages/ui/src/Button.tsx)" | ||
echo "- Test file changes (packages/ui/tests/Button.test.tsx)" | ||
echo "- Core utility changes (packages/core/src/utils.ts)" | ||
echo "- Documentation changes (docs/README.md)" |
Oops, something went wrong.