berget 1.3.1 → 1.4.0

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.
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const vitest_1 = require("vitest");
13
+ const commander_1 = require("commander");
14
+ const chat_1 = require("../../src/commands/chat");
15
+ const chat_service_1 = require("../../src/services/chat-service");
16
+ const default_api_key_1 = require("../../src/utils/default-api-key");
17
+ // Mock dependencies
18
+ vitest_1.vi.mock('../../src/services/chat-service');
19
+ vitest_1.vi.mock('../../src/utils/default-api-key');
20
+ vitest_1.vi.mock('readline', () => ({
21
+ createInterface: vitest_1.vi.fn(() => ({
22
+ question: vitest_1.vi.fn(),
23
+ close: vitest_1.vi.fn()
24
+ }))
25
+ }));
26
+ (0, vitest_1.describe)('Chat Commands', () => {
27
+ let program;
28
+ let mockChatService;
29
+ let mockDefaultApiKeyManager;
30
+ (0, vitest_1.beforeEach)(() => {
31
+ program = new commander_1.Command();
32
+ // Mock ChatService
33
+ mockChatService = {
34
+ createCompletion: vitest_1.vi.fn(),
35
+ listModels: vitest_1.vi.fn()
36
+ };
37
+ vitest_1.vi.mocked(chat_service_1.ChatService.getInstance).mockReturnValue(mockChatService);
38
+ // Mock DefaultApiKeyManager
39
+ mockDefaultApiKeyManager = {
40
+ getDefaultApiKeyData: vitest_1.vi.fn(),
41
+ promptForDefaultApiKey: vitest_1.vi.fn()
42
+ };
43
+ vitest_1.vi.mocked(default_api_key_1.DefaultApiKeyManager.getInstance).mockReturnValue(mockDefaultApiKeyManager);
44
+ (0, chat_1.registerChatCommands)(program);
45
+ });
46
+ (0, vitest_1.afterEach)(() => {
47
+ vitest_1.vi.clearAllMocks();
48
+ });
49
+ (0, vitest_1.describe)('chat run command', () => {
50
+ (0, vitest_1.it)('should use openai/gpt-oss as default model', () => {
51
+ const chatCommand = program.commands.find(cmd => cmd.name() === 'chat');
52
+ const runCommand = chatCommand === null || chatCommand === void 0 ? void 0 : chatCommand.commands.find(cmd => cmd.name() === 'run');
53
+ (0, vitest_1.expect)(runCommand).toBeDefined();
54
+ // Check the help text which contains the default model
55
+ const helpText = runCommand === null || runCommand === void 0 ? void 0 : runCommand.helpInformation();
56
+ (0, vitest_1.expect)(helpText).toContain('openai/gpt-oss');
57
+ });
58
+ (0, vitest_1.it)('should have streaming enabled by default', () => {
59
+ const chatCommand = program.commands.find(cmd => cmd.name() === 'chat');
60
+ const runCommand = chatCommand === null || chatCommand === void 0 ? void 0 : chatCommand.commands.find(cmd => cmd.name() === 'run');
61
+ (0, vitest_1.expect)(runCommand).toBeDefined();
62
+ // Check that the option is --no-stream (meaning streaming is default)
63
+ const streamOption = runCommand === null || runCommand === void 0 ? void 0 : runCommand.options.find(opt => opt.long === '--no-stream');
64
+ (0, vitest_1.expect)(streamOption).toBeDefined();
65
+ (0, vitest_1.expect)(streamOption === null || streamOption === void 0 ? void 0 : streamOption.description).toContain('Disable streaming');
66
+ });
67
+ (0, vitest_1.it)('should create completion with correct default options', () => __awaiter(void 0, void 0, void 0, function* () {
68
+ // Mock API key
69
+ process.env.BERGET_API_KEY = 'test-key';
70
+ // Mock successful completion
71
+ mockChatService.createCompletion.mockResolvedValue({
72
+ choices: [{
73
+ message: { content: 'Test response' }
74
+ }]
75
+ });
76
+ // This would normally test the actual command execution
77
+ // but since it involves readline interaction, we just verify
78
+ // that the service would be called with correct defaults
79
+ (0, vitest_1.expect)(mockChatService.createCompletion).not.toHaveBeenCalled();
80
+ // Clean up
81
+ delete process.env.BERGET_API_KEY;
82
+ }));
83
+ });
84
+ (0, vitest_1.describe)('chat list command', () => {
85
+ (0, vitest_1.it)('should list available models', () => __awaiter(void 0, void 0, void 0, function* () {
86
+ const mockModels = {
87
+ data: [
88
+ {
89
+ id: 'gpt-oss',
90
+ owned_by: 'openai',
91
+ active: true,
92
+ capabilities: {
93
+ vision: false,
94
+ function_calling: true,
95
+ json_mode: true
96
+ }
97
+ }
98
+ ]
99
+ };
100
+ mockChatService.listModels.mockResolvedValue(mockModels);
101
+ const chatCommand = program.commands.find(cmd => cmd.name() === 'chat');
102
+ const listCommand = chatCommand === null || chatCommand === void 0 ? void 0 : chatCommand.commands.find(cmd => cmd.name() === 'list');
103
+ (0, vitest_1.expect)(listCommand).toBeDefined();
104
+ (0, vitest_1.expect)(listCommand === null || listCommand === void 0 ? void 0 : listCommand.description()).toBe('List available chat models');
105
+ }));
106
+ });
107
+ });
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config_1 = require("vitest/config");
4
+ exports.default = (0, config_1.defineConfig)({
5
+ test: {
6
+ globals: true,
7
+ environment: 'node',
8
+ },
9
+ });
@@ -0,0 +1,95 @@
1
+ # Berget CLI Examples
2
+
3
+ This folder contains practical examples of how you can use Berget CLI for various automation tasks.
4
+
5
+ ## Scripts
6
+
7
+ ### smart-commit.sh
8
+ Automatic generation of conventional commit messages based on git diff.
9
+
10
+ ```bash
11
+ # Make the script executable
12
+ chmod +x examples/smart-commit.sh
13
+
14
+ # Use it
15
+ git add .
16
+ ./examples/smart-commit.sh
17
+ ```
18
+
19
+ ### ai-review.sh
20
+ AI-driven code review that analyzes files for quality, bugs, and security aspects.
21
+
22
+ ```bash
23
+ # Make the script executable
24
+ chmod +x examples/ai-review.sh
25
+
26
+ # Review a file
27
+ ./examples/ai-review.sh src/main.js
28
+ ```
29
+
30
+ ### security-check.sh
31
+ Security review of git commits that blocks commits with critical security risks.
32
+
33
+ ```bash
34
+ # Make the script executable
35
+ chmod +x examples/security-check.sh
36
+
37
+ # Run security check
38
+ git add .
39
+ ./examples/security-check.sh
40
+ ```
41
+
42
+ ## Installation
43
+
44
+ To use these scripts:
45
+
46
+ 1. Copy them to your `~/bin` folder or another location in your PATH
47
+ 2. Make them executable with `chmod +x`
48
+ 3. Make sure you have Berget CLI installed and configured
49
+
50
+ ```bash
51
+ # Copy to ~/bin
52
+ cp examples/*.sh ~/bin/
53
+
54
+ # Make them executable
55
+ chmod +x ~/bin/smart-commit.sh ~/bin/ai-review.sh ~/bin/security-check.sh
56
+ ```
57
+
58
+ ## Global Security Hook
59
+
60
+ For maximum security, you can install a global git hook that automatically runs security checks before every push:
61
+
62
+ ```bash
63
+ # Install the global security hook
64
+ chmod +x examples/install-global-security-hook.sh
65
+ ./examples/install-global-security-hook.sh
66
+ ```
67
+
68
+ This will:
69
+ - Create a global pre-push hook that runs on all repositories
70
+ - Automatically analyze commits for security vulnerabilities using OWASP Top 20
71
+ - Block pushes with critical security issues
72
+ - Warn about medium-risk issues and allow you to choose
73
+
74
+ The hook will run automatically before every `git push`. To bypass it temporarily (not recommended):
75
+ ```bash
76
+ git push --no-verify
77
+ ```
78
+
79
+ ## Git Aliases
80
+
81
+ You can also add these as git aliases:
82
+
83
+ ```bash
84
+ git config --global alias.ai-commit '!~/bin/smart-commit.sh'
85
+ git config --global alias.ai-review '!~/bin/ai-review.sh'
86
+ git config --global alias.security-check '!~/bin/security-check.sh'
87
+ ```
88
+
89
+ Then you can use:
90
+
91
+ ```bash
92
+ git ai-commit
93
+ git ai-review src/main.js
94
+ git security-check
95
+ ```
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+ # AI code review using Berget AI
3
+ # Usage: ./ai-review.sh <filename>
4
+ set -e
5
+
6
+ if [[ $# -eq 0 ]]; then
7
+ echo "Usage: ai-review <file>"
8
+ exit 1
9
+ fi
10
+
11
+ FILE="$1"
12
+
13
+ if [[ ! -f "$FILE" ]]; then
14
+ echo "Error: File '$FILE' does not exist"
15
+ exit 1
16
+ fi
17
+
18
+ echo "🔍 Reviewing $FILE with AI..."
19
+ echo "================================"
20
+
21
+ cat "$FILE" | npx berget chat run openai/gpt-oss "
22
+ Review this code and provide feedback on:
23
+ 1. Code quality and readability
24
+ 2. Potential bugs or issues
25
+ 3. Performance improvements
26
+ 4. Best practices
27
+ 5. Security aspects
28
+
29
+ Provide concrete suggestions for improvements:
30
+ "
@@ -0,0 +1,170 @@
1
+ #!/bin/bash
2
+ # Install global git security hook
3
+ # This script sets up a global pre-push hook that runs security checks on all repositories
4
+
5
+ set -e
6
+
7
+ echo "🔧 Installing global git security hook..."
8
+
9
+ # Create global git hooks directory
10
+ GLOBAL_HOOKS_DIR="$HOME/.git-hooks"
11
+ mkdir -p "$GLOBAL_HOOKS_DIR"
12
+
13
+ # Create the pre-push hook
14
+ cat > "$GLOBAL_HOOKS_DIR/pre-push" << 'EOF'
15
+ #!/bin/bash
16
+ # Global pre-push security hook using Berget AI
17
+ # This hook runs automatically before every git push
18
+
19
+ set -e
20
+
21
+ # Colors for output
22
+ RED='\033[0;31m'
23
+ GREEN='\033[0;32m'
24
+ YELLOW='\033[1;33m'
25
+ BLUE='\033[0;34m'
26
+ NC='\033[0m' # No Color
27
+
28
+ echo -e "${BLUE}🔒 Running security check before push...${NC}"
29
+
30
+ # Check if we're in a git repository
31
+ if ! git rev-parse --git-dir > /dev/null 2>&1; then
32
+ echo -e "${RED}Error: Not in a git repository${NC}"
33
+ exit 1
34
+ fi
35
+
36
+ # Check if there are any commits to push
37
+ if [[ -z $(git log @{u}.. --oneline 2>/dev/null) ]]; then
38
+ echo -e "${GREEN}✅ No new commits to push${NC}"
39
+ exit 0
40
+ fi
41
+
42
+ # Get the diff of commits being pushed
43
+ DIFF=$(git diff @{u}.. 2>/dev/null || git diff HEAD~1)
44
+
45
+ if [[ -z "$DIFF" ]]; then
46
+ echo -e "${GREEN}✅ No changes to analyze${NC}"
47
+ exit 0
48
+ fi
49
+
50
+ echo -e "${BLUE}Analyzing security risks in commits being pushed...${NC}"
51
+
52
+ # Check if Berget CLI is available
53
+ if ! command -v npx > /dev/null 2>&1; then
54
+ echo -e "${YELLOW}⚠️ npx not found. Skipping security check.${NC}"
55
+ echo -e "${YELLOW}Install Node.js and npm to enable security checks.${NC}"
56
+ exit 0
57
+ fi
58
+
59
+ # Run security analysis
60
+ SECURITY_REPORT=$(echo "$DIFF" | npx berget chat run openai/gpt-oss "
61
+ Analyze this git diff for security vulnerabilities using OWASP Top 20 Code Review recommendations:
62
+
63
+ **OWASP Top 20 Security Categories to Check:**
64
+
65
+ 1. **A01 - Broken Access Control**: Authorization bypasses, privilege escalation, insecure direct object references
66
+ 2. **A02 - Cryptographic Failures**: Weak encryption, hardcoded keys, insecure random number generation, plain text storage
67
+ 3. **A03 - Injection**: SQL injection, NoSQL injection, command injection, LDAP injection, XSS
68
+ 4. **A04 - Insecure Design**: Missing security controls, threat modeling gaps, insecure architecture patterns
69
+ 5. **A05 - Security Misconfiguration**: Default credentials, unnecessary features enabled, verbose error messages
70
+ 6. **A06 - Vulnerable Components**: Outdated dependencies, known vulnerable libraries, unpatched components
71
+ 7. **A07 - Authentication Failures**: Weak passwords, session management flaws, credential stuffing vulnerabilities
72
+ 8. **A08 - Software Integrity Failures**: Unsigned code, insecure CI/CD pipelines, auto-update without verification
73
+ 9. **A09 - Logging Failures**: Insufficient logging, sensitive data in logs, log injection
74
+ 10. **A10 - Server-Side Request Forgery**: SSRF vulnerabilities, unvalidated URLs, internal service access
75
+
76
+ **Additional Critical Areas:**
77
+ 11. **Input Validation**: Insufficient sanitization, buffer overflows, format string vulnerabilities
78
+ 12. **Output Encoding**: XSS prevention, content type validation, encoding bypasses
79
+ 13. **File Operations**: Path traversal, file upload vulnerabilities, insecure file permissions
80
+ 14. **Network Security**: Insecure protocols, certificate validation, CSRF protection
81
+ 15. **Session Management**: Session fixation, insecure cookies, session timeout issues
82
+ 16. **Error Handling**: Information disclosure, stack traces in production, verbose error messages
83
+ 17. **Business Logic**: Race conditions, workflow bypasses, price manipulation
84
+ 18. **API Security**: Rate limiting, input validation, authentication on all endpoints
85
+ 19. **Mobile Security**: Insecure data storage, weak encryption, certificate pinning
86
+ 20. **Cloud Security**: Misconfigured permissions, exposed storage, insecure defaults
87
+
88
+ **Assessment Criteria:**
89
+ - 🟢 SAFE: No security risks identified according to OWASP guidelines
90
+ - 🟡 WARNING: Minor security risks that should be addressed (OWASP Medium risk)
91
+ - 🔴 CRITICAL: Serious security risks that MUST be addressed immediately (OWASP High/Critical risk)
92
+
93
+ **Required Response Format:**
94
+ **SECURITY ASSESSMENT: [🟢/🟡/🔴] [SAFE/WARNING/CRITICAL]**
95
+
96
+ **OWASP CATEGORIES AFFECTED:**
97
+ - [List specific OWASP categories if any vulnerabilities found]
98
+
99
+ **IDENTIFIED RISKS:**
100
+ - [List specific vulnerabilities with OWASP category references]
101
+
102
+ **RECOMMENDATIONS:**
103
+ - [Concrete remediation steps following OWASP secure coding practices]
104
+
105
+ **COMPLIANCE NOTES:**
106
+ - [Any additional security considerations or compliance requirements]
107
+
108
+ Diff to analyze:
109
+ \`\`\`diff
110
+ $DIFF
111
+ \`\`\`
112
+ " 2>/dev/null)
113
+
114
+ if [[ $? -ne 0 ]] || [[ -z "$SECURITY_REPORT" ]]; then
115
+ echo -e "${YELLOW}⚠️ Security analysis failed or unavailable. Proceeding with push.${NC}"
116
+ echo -e "${YELLOW}Make sure you have BERGET_API_KEY set or are logged in with 'npx berget auth login'${NC}"
117
+ exit 0
118
+ fi
119
+
120
+ echo "$SECURITY_REPORT"
121
+ echo ""
122
+
123
+ # Extract security level from report
124
+ if echo "$SECURITY_REPORT" | grep -q "🔴.*CRITICAL"; then
125
+ echo -e "${RED}❌ CRITICAL security risks identified!${NC}"
126
+ echo -e "${RED}Push blocked. Address security issues before pushing.${NC}"
127
+ echo ""
128
+ echo -e "${YELLOW}To bypass this check (NOT RECOMMENDED):${NC}"
129
+ echo -e "${YELLOW}git push --no-verify${NC}"
130
+ exit 1
131
+ elif echo "$SECURITY_REPORT" | grep -q "🟡.*WARNING"; then
132
+ echo -e "${YELLOW}⚠️ Security warnings identified.${NC}"
133
+ read -p "Do you want to continue with push despite warnings? (y/N): " -n 1 -r
134
+ echo
135
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
136
+ echo -e "${YELLOW}Push cancelled. Address security issues first.${NC}"
137
+ echo ""
138
+ echo -e "${YELLOW}To bypass this check (NOT RECOMMENDED):${NC}"
139
+ echo -e "${YELLOW}git push --no-verify${NC}"
140
+ exit 1
141
+ fi
142
+ elif echo "$SECURITY_REPORT" | grep -q "🟢.*SAFE"; then
143
+ echo -e "${GREEN}✅ No security risks identified. Safe to push!${NC}"
144
+ else
145
+ echo -e "${YELLOW}⚠️ Could not determine security status. Proceeding with caution.${NC}"
146
+ fi
147
+
148
+ echo -e "${GREEN}Security check complete. Proceeding with push...${NC}"
149
+ EOF
150
+
151
+ # Make the hook executable
152
+ chmod +x "$GLOBAL_HOOKS_DIR/pre-push"
153
+
154
+ # Configure git to use the global hooks directory
155
+ git config --global core.hooksPath "$GLOBAL_HOOKS_DIR"
156
+
157
+ echo -e "${GREEN}✅ Global security hook installed successfully!${NC}"
158
+ echo ""
159
+ echo -e "${BLUE}The security hook will now run automatically before every 'git push' in all repositories.${NC}"
160
+ echo ""
161
+ echo -e "${YELLOW}Requirements:${NC}"
162
+ echo -e " • Node.js and npm installed"
163
+ echo -e " • Berget CLI configured (npx berget auth login or BERGET_API_KEY set)"
164
+ echo ""
165
+ echo -e "${YELLOW}To disable the hook temporarily:${NC}"
166
+ echo -e " git push --no-verify"
167
+ echo ""
168
+ echo -e "${YELLOW}To uninstall the global hook:${NC}"
169
+ echo -e " git config --global --unset core.hooksPath"
170
+ echo -e " rm -rf $GLOBAL_HOOKS_DIR"
@@ -0,0 +1,102 @@
1
+ #!/bin/bash
2
+ # Security check for git commits using Berget AI
3
+ # Usage: ./security-check.sh
4
+ set -e
5
+
6
+ echo "🔒 Security review of commits..."
7
+ echo "===================================="
8
+
9
+ # Check if there are staged changes
10
+ if [[ -z $(git diff --cached) ]]; then
11
+ echo "No staged changes found. Run 'git add' first."
12
+ exit 1
13
+ fi
14
+
15
+ # Get diff for security review
16
+ DIFF=$(git diff --cached)
17
+
18
+ echo "Analyzing security risks in staged changes..."
19
+
20
+ SECURITY_REPORT=$(echo "$DIFF" | npx berget chat run openai/gpt-oss "
21
+ Analyze this git diff for security vulnerabilities using OWASP Top 20 Code Review recommendations:
22
+
23
+ **OWASP Top 20 Security Categories to Check:**
24
+
25
+ 1. **A01 - Broken Access Control**: Authorization bypasses, privilege escalation, insecure direct object references
26
+ 2. **A02 - Cryptographic Failures**: Weak encryption, hardcoded keys, insecure random number generation, plain text storage
27
+ 3. **A03 - Injection**: SQL injection, NoSQL injection, command injection, LDAP injection, XSS
28
+ 4. **A04 - Insecure Design**: Missing security controls, threat modeling gaps, insecure architecture patterns
29
+ 5. **A05 - Security Misconfiguration**: Default credentials, unnecessary features enabled, verbose error messages
30
+ 6. **A06 - Vulnerable Components**: Outdated dependencies, known vulnerable libraries, unpatched components
31
+ 7. **A07 - Authentication Failures**: Weak passwords, session management flaws, credential stuffing vulnerabilities
32
+ 8. **A08 - Software Integrity Failures**: Unsigned code, insecure CI/CD pipelines, auto-update without verification
33
+ 9. **A09 - Logging Failures**: Insufficient logging, sensitive data in logs, log injection
34
+ 10. **A10 - Server-Side Request Forgery**: SSRF vulnerabilities, unvalidated URLs, internal service access
35
+
36
+ **Additional Critical Areas:**
37
+ 11. **Input Validation**: Insufficient sanitization, buffer overflows, format string vulnerabilities
38
+ 12. **Output Encoding**: XSS prevention, content type validation, encoding bypasses
39
+ 13. **File Operations**: Path traversal, file upload vulnerabilities, insecure file permissions
40
+ 14. **Network Security**: Insecure protocols, certificate validation, CSRF protection
41
+ 15. **Session Management**: Session fixation, insecure cookies, session timeout issues
42
+ 16. **Error Handling**: Information disclosure, stack traces in production, verbose error messages
43
+ 17. **Business Logic**: Race conditions, workflow bypasses, price manipulation
44
+ 18. **API Security**: Rate limiting, input validation, authentication on all endpoints
45
+ 19. **Mobile Security**: Insecure data storage, weak encryption, certificate pinning
46
+ 20. **Cloud Security**: Misconfigured permissions, exposed storage, insecure defaults
47
+
48
+ **Assessment Criteria:**
49
+ - 🟢 SAFE: No security risks identified according to OWASP guidelines
50
+ - 🟡 WARNING: Minor security risks that should be addressed (OWASP Medium risk)
51
+ - 🔴 CRITICAL: Serious security risks that MUST be addressed immediately (OWASP High/Critical risk)
52
+
53
+ **Required Response Format:**
54
+ **SECURITY ASSESSMENT: [🟢/🟡/🔴] [SAFE/WARNING/CRITICAL]**
55
+
56
+ **OWASP CATEGORIES AFFECTED:**
57
+ - [List specific OWASP categories if any vulnerabilities found]
58
+
59
+ **IDENTIFIED RISKS:**
60
+ - [List specific vulnerabilities with OWASP category references]
61
+
62
+ **RECOMMENDATIONS:**
63
+ - [Concrete remediation steps following OWASP secure coding practices]
64
+
65
+ **COMPLIANCE NOTES:**
66
+ - [Any additional security considerations or compliance requirements]
67
+
68
+ Diff to analyze:
69
+ \`\`\`diff
70
+ $DIFF
71
+ \`\`\`
72
+ ")
73
+
74
+ echo "$SECURITY_REPORT"
75
+ echo ""
76
+
77
+ # Extract security level from report
78
+ if echo "$SECURITY_REPORT" | grep -q "🔴.*CRITICAL"; then
79
+ echo "❌ CRITICAL security risks identified!"
80
+ echo "Commit blocked. Address security issues before continuing."
81
+ exit 1
82
+ elif echo "$SECURITY_REPORT" | grep -q "🟡.*WARNING"; then
83
+ echo "⚠️ Security warnings identified."
84
+ read -p "Do you want to continue with commit despite warnings? (y/N): " -n 1 -r
85
+ echo
86
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
87
+ echo "Commit cancelled. Address security issues first."
88
+ exit 1
89
+ fi
90
+ elif echo "$SECURITY_REPORT" | grep -q "🟢.*SAFE"; then
91
+ echo "✅ No security risks identified. Safe to continue!"
92
+ else
93
+ echo "⚠️ Could not determine security status. Review manually."
94
+ read -p "Do you want to continue with commit? (y/N): " -n 1 -r
95
+ echo
96
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
97
+ echo "Commit cancelled."
98
+ exit 1
99
+ fi
100
+ fi
101
+
102
+ echo "Security review complete. You can now run 'git commit'."
@@ -0,0 +1,26 @@
1
+ #!/bin/bash
2
+ # Smart commit generator using Berget AI
3
+ # Usage: ./smart-commit.sh
4
+ set -e
5
+
6
+ # Check if there are staged changes
7
+ if [[ -z $(git diff --cached) ]]; then
8
+ echo "No staged changes found. Run 'git add' first."
9
+ exit 1
10
+ fi
11
+
12
+ # Generate commit message
13
+ COMMIT_MSG=$(git diff --cached | npx berget chat run openai/gpt-oss "Generate a conventional commit message for this staged diff. Reply with only the commit message, nothing else:")
14
+
15
+ echo "Suggested commit message:"
16
+ echo " $COMMIT_MSG"
17
+ echo
18
+
19
+ read -p "Do you want to use this message? (y/N): " -n 1 -r
20
+ echo
21
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
22
+ git commit -m "$COMMIT_MSG"
23
+ echo "✅ Commit created!"
24
+ else
25
+ echo "❌ Commit cancelled"
26
+ fi
package/package.json CHANGED
@@ -1,17 +1,22 @@
1
1
  {
2
2
  "name": "berget",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "berget": "dist/index.js"
7
7
  },
8
8
  "private": false,
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
9
12
  "scripts": {
10
13
  "start": "node --import tsx ./index.ts --local",
11
14
  "login": "node --import tsx ./index.ts --local auth login",
12
15
  "logout": "node --import tsx ./index.ts --local auth logout",
13
16
  "whoami": "node --import tsx ./index.ts --local auth whoami",
14
17
  "build": "tsc",
18
+ "test": "vitest",
19
+ "test:run": "vitest run",
15
20
  "prepublishOnly": "npm run build",
16
21
  "generate-types": "openapi-typescript https://api.berget.ai/openapi.json -o src/types/api.d.ts"
17
22
  },
@@ -23,7 +28,8 @@
23
28
  "@types/marked-terminal": "^6.1.1",
24
29
  "@types/node": "^20.11.20",
25
30
  "tsx": "^4.19.3",
26
- "typescript": "^5.3.3"
31
+ "typescript": "^5.3.3",
32
+ "vitest": "^1.0.0"
27
33
  },
28
34
  "dependencies": {
29
35
  "chalk": "^4.1.2",