File size: 9,402 Bytes
3d50167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# Contributing to Virtual Kimi

Thank you for your interest in contributing to Virtual Kimi! This document provides guidelines and information for contributors.

## Table of Contents

- [Code of Conduct](#code-of-conduct)
- [Getting Started](#getting-started)
- [Development Setup](#development-setup)
- [Contribution Guidelines](#contribution-guidelines)
- [Project Structure](#project-structure)
- [Coding Standards](#coding-standards)
- [Testing](#testing)
- [Pull Request Process](#pull-request-process)
- [Issue Reporting](#issue-reporting)

## Code of Conduct

We are committed to providing a welcoming and inclusive environment for all contributors. Please be respectful and constructive in all interactions.

### Expected Behavior

- Use welcoming and inclusive language
- Be respectful of differing viewpoints and experiences
- Gracefully accept constructive criticism
- Focus on what is best for the community
- Show empathy towards other community members

## Getting Started

### Prerequisites

- Modern web browser (Chrome, Edge, Firefox recommended)
- Basic knowledge of JavaScript, HTML, and CSS
- Git for version control
- Text editor or IDE of your choice

### First Contribution

1. Fork the repository
2. Clone your fork locally
3. Create a new branch for your feature/fix
4. Make your changes
5. Test thoroughly
6. Submit a pull request

## Development Setup

### Local Environment

```bash

# Clone the repository

git clone https://github.com/virtualkimi/virtual-kimi.git

cd virtual-kimi



# Open in browser

# Option 1: Direct file access

open index.html



# Option 2: Local server (recommended)

python -m http.server 8000

# Navigate to http://localhost:8000

```

### Development Tools

- **Browser DevTools**: For debugging and testing
- **Live Server**: For hot reload during development
- **Lighthouse**: For performance auditing
- **Accessibility tools**: For ensuring inclusive design

## Contribution Guidelines

### Types of Contributions

- **Bug fixes**: Resolve existing issues
- **Feature additions**: New functionality
- **Performance improvements**: Optimization and efficiency
- **Documentation**: Improve guides and comments
- **Localization**: Translation and internationalization
- **Plugin development**: Extend functionality
- **Testing**: Add or improve test coverage

### Before You Start

1. Check existing issues and pull requests
2. Open an issue to discuss major changes
3. Ensure your idea aligns with the project goals
4. Consider the impact on existing functionality

## Project Structure

### Core Files

```

β”œβ”€β”€ index.html              # Main application

β”œβ”€β”€ kimi-script.js          # Primary initialization

β”œβ”€β”€ kimi-database.js        # Data persistence

β”œβ”€β”€ kimi-llm-manager.js     # AI integration

β”œβ”€β”€ kimi-emotion-system.js  # Emotion analysis

β”œβ”€β”€ kimi-memory-system.js   # Memory management

β”œβ”€β”€ kimi-voices.js          # Speech synthesis

β”œβ”€β”€ kimi-appearance.js      # Theme management

└── kimi-utils.js           # Utility functions

```

### Module Dependencies

- **Core System**: Database β†’ Security β†’ Config
- **AI System**: LLM Manager β†’ Emotion System β†’ Memory System
- **UI System**: Appearance β†’ Utils β†’ Module functions
- **Localization**: i18n β†’ All user-facing modules

### Adding New Features

#### New Memory Categories

```javascript

// In kimi-memory-system.js

const newCategory = {

    name: "custom_category",

    icon: "fas fa-custom-icon",

    keywords: ["keyword1", "keyword2"],

    confidence: 0.7

};



// Add to MEMORY_CATEGORIES constant

```

#### New Themes

```javascript

// Create plugin in kimi-plugins/custom-theme/

// manifest.json

{

    "name": "Custom Theme",

    "version": "1.0.0",

    "type": "theme",

    "style": "theme.css",

    "enabled": true

}

```

#### New AI Models

```javascript

// In kimi-llm-manager.js

"custom/model-id": {

    name: "Custom Model",

    provider: "Custom Provider",

    type: "openrouter",

    contextWindow: 8000,

    pricing: { input: 0.1, output: 0.2 },

    strengths: ["Custom", "Feature"]

}

```

## Coding Standards

### JavaScript Style

- Use ES6+ features and modern syntax
- Prefer `const` and `let` over `var`
- Use meaningful variable and function names in English
- Follow camelCase for variables and functions
- Use PascalCase for classes and constructors

### Code Organization

- Keep functions focused and single-purpose
- Use async/await for asynchronous operations
- Handle errors gracefully with try/catch blocks
- Add JSDoc comments for complex functions
- Group related functionality in modules

### Example Code Style

```javascript

/**

 * Analyzes user input for emotional content and updates personality traits

 * @param {string} text - User input text

 * @param {string} emotion - Detected emotion type

 * @returns {Promise<Object>} Updated personality traits

 */

async function updatePersonalityFromEmotion(text, emotion) {

    try {

        // Validate input

        if (!text || typeof text !== "string") {

            throw new Error("Invalid input text");

        }



        // Process emotion

        const traits = await this.processEmotionalContent(text, emotion);



        // Update database

        await this.db.setPersonalityBatch(traits);



        return traits;

    } catch (error) {

        console.error("Error updating personality:", error);

        throw error;

    }

}

```

### CSS Guidelines

- Use CSS custom properties (variables) for theming
- Follow BEM methodology for class naming
- Ensure responsive design principles
- Maintain accessibility standards
- Use semantic HTML elements

### HTML Standards

- Use semantic HTML5 elements
- Include proper ARIA labels for accessibility
- Ensure proper heading hierarchy
- Add meaningful alt text for images
- Validate markup regularly

## Testing

### Manual Testing Checklist

- [ ] Application loads without errors
- [ ] All core features function correctly
- [ ] Voice recognition works (in supported browsers)
- [ ] Memory system stores and retrieves data
- [ ] Theme switching works properly
- [ ] Responsive design on mobile devices
- [ ] Cross-browser compatibility
- [ ] Accessibility with keyboard navigation

### Browser Testing

Test in the following browsers:

- Chrome (latest 2 versions)
- Edge (latest 2 versions)
- Firefox (latest 2 versions)
- Safari (latest version, if possible)

### Performance Testing

- Check loading times
- Monitor memory usage
- Test with large conversation histories
- Verify smooth animations
- Ensure responsive UI interactions

## Pull Request Process

### Before Submitting

1. **Test thoroughly**: Ensure your changes work as expected
2. **Check compatibility**: Test across different browsers
3. **Update documentation**: Modify README.md if needed
4. **Clean up code**: Remove debugging code and comments
5. **Commit messages**: Use clear, descriptive commit messages

### PR Template

```markdown

## Description



Brief description of changes made.



## Type of Change



- [ ] Bug fix

- [ ] New feature

- [ ] Performance improvement

- [ ] Documentation update

- [ ] Other: **\_**



## Testing



- [ ] Tested in Chrome

- [ ] Tested in Edge

- [ ] Tested in Firefox

- [ ] Tested on mobile

- [ ] No errors in console



## Screenshots (if applicable)



Add screenshots of UI changes.



## Additional Notes



Any additional context or considerations.

```

### Review Process

1. Maintainers review code for quality and functionality
2. Feedback provided through PR comments
3. Make requested changes and push updates
4. Final approval and merge

## Issue Reporting

### Bug Reports

Include the following information:

- Browser and version
- Operating system
- Steps to reproduce
- Expected behavior
- Actual behavior
- Console errors (if any)
- Screenshots (if applicable)

### Feature Requests

- Clear description of the feature
- Use case and benefits
- Possible implementation approach
- Any relevant examples or mockups

### Issue Labels

- `bug`: Something isn't working
- `enhancement`: New feature or improvement
- `documentation`: Documentation updates
- `good first issue`: Good for newcomers
- `help wanted`: Community assistance needed
- `plugin`: Related to plugin system
- `accessibility`: Accessibility improvements

## Development Tips

### Performance Optimization

- Minimize DOM manipulations
- Use event delegation for dynamic content
- Implement proper cleanup for event listeners
- Optimize database queries with batch operations

### Accessibility

- Test with keyboard navigation
- Verify screen reader compatibility
- Ensure sufficient color contrast
- Add appropriate ARIA labels

## Community

### Getting Help

- Open an issue for technical questions
- Check existing documentation first
- Be specific about your problem or question

### Communication

- Be respectful and professional
- Provide context and details
- Be patient with response times
- Help others when possible

Thank you for contributing to Virtual Kimi! Your efforts help create a better AI companion experience for everyone.