-
Notifications
You must be signed in to change notification settings - Fork 836
feat: three-tier rules system #1777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Nemo4110
wants to merge
9
commits into
MoonshotAI:main
Choose a base branch
from
Nemo4110:feat/agent-rules
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4fe7b0d
feat(rules): add three-tier rules system with /rules slash command
c5837b7
docs: update changelog and slash commands for /rules feature
f2ffc0c
test(rules): add comprehensive tests for rules system
3e82acc
fix(rules): address PR review feedback on state management and priority
58369aa
test(rules): add tests for state management and priority
a8396c2
Merge branch 'main' into feat/agent-rules
Nemo4110 172415c
fix(rules): fix critical bugs from PR review
595cdeb
fix(rules): use glob instead of rglob for KaosPath compatibility
1d9f553
Merge branch 'main' into feat/agent-rules
Nemo4110 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,32 @@ | ||
| """Rules system for development guidelines and coding standards.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from kimi_cli.rules.discovery import ( | ||
| find_first_existing_dir, | ||
| get_builtin_rules_dir, | ||
| get_project_rules_dir_candidates, | ||
| get_user_rules_dir_candidates, | ||
| resolve_rules_roots, | ||
| ) | ||
| from kimi_cli.rules.injector import RulesInjector, load_active_rules | ||
| from kimi_cli.rules.models import Rule, RuleMetadata, RuleState | ||
| from kimi_cli.rules.parser import parse_rule_file | ||
| from kimi_cli.rules.registry import RulesRegistry | ||
| from kimi_cli.rules.state import RulesStateManager | ||
|
|
||
| __all__ = [ | ||
| "get_builtin_rules_dir", | ||
| "get_user_rules_dir_candidates", | ||
| "get_project_rules_dir_candidates", | ||
| "resolve_rules_roots", | ||
| "find_first_existing_dir", | ||
| "Rule", | ||
| "RuleMetadata", | ||
| "RuleState", | ||
| "parse_rule_file", | ||
| "RulesRegistry", | ||
| "RulesInjector", | ||
| "load_active_rules", | ||
| "RulesStateManager", | ||
| ] |
This file contains hidden or 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,32 @@ | ||
| --- | ||
| name: "Coding Style" | ||
| description: "General coding style guidelines for all languages" | ||
| priority: 100 | ||
| --- | ||
|
|
||
| # Coding Style Guidelines | ||
|
|
||
| ## Code Organization | ||
|
|
||
| - **Small, focused files**: Aim for 200-400 lines per file, maximum 800 lines | ||
| - **Single responsibility**: Each file/module should have one clear purpose | ||
| - **Meaningful names**: Use descriptive variable, function, and class names | ||
|
|
||
| ## Code Quality | ||
|
|
||
| - **Functions should be small**: Ideally under 50 lines | ||
| - **Avoid deep nesting**: Maximum 4 levels of indentation | ||
| - **Fail fast**: Validate inputs and preconditions early | ||
| - **No silent failures**: Always handle errors explicitly | ||
|
|
||
| ## Comments and Documentation | ||
|
|
||
| - **Self-documenting code**: Prefer clear names over comments | ||
| - **Why, not what**: Comments should explain intent, not mechanics | ||
| - **Keep comments current**: Update or remove outdated comments | ||
|
|
||
| ## General Principles | ||
|
|
||
| - **DRY (Don't Repeat Yourself)**: Extract common logic into reusable functions | ||
| - **YAGNI (You Aren't Gonna Need It)**: Don't add functionality until necessary | ||
| - **KISS (Keep It Simple, Stupid)**: Simple solutions are better than clever ones |
This file contains hidden or 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,38 @@ | ||
| --- | ||
| name: "Testing Standards" | ||
| description: "Guidelines for writing effective tests" | ||
| priority: 110 | ||
| --- | ||
|
|
||
| # Testing Standards | ||
|
|
||
| ## Test Coverage | ||
|
|
||
| - **Test critical paths**: Focus on business logic and edge cases | ||
| - **Aim for meaningful coverage**: Quality over quantity (80% is a good target) | ||
| - **Test behavior, not implementation**: Tests should verify what code does, not how | ||
|
|
||
| ## Test Structure | ||
|
|
||
| - **Arrange-Act-Assert**: Structure tests clearly | ||
| - Arrange: Set up test data and conditions | ||
| - Act: Execute the code being tested | ||
| - Assert: Verify the expected outcome | ||
|
|
||
| ## Test Naming | ||
|
|
||
| - **Descriptive names**: Test names should explain the scenario being tested | ||
| - **Pattern**: `test_<function>_<condition>_<expected_result>` | ||
| - **Example**: `test_calculate_discount_negative_price_raises_error` | ||
|
|
||
| ## Test Independence | ||
|
|
||
| - **Isolated tests**: Each test should be independent and not rely on others | ||
| - **Clean state**: Tests should clean up after themselves or use fresh fixtures | ||
| - **Deterministic**: Tests should produce the same result every time | ||
|
|
||
| ## Test Maintenance | ||
|
|
||
| - **Keep tests simple**: Test code should be simpler than production code | ||
| - **Refactor tests**: Don't be afraid to improve test code structure | ||
| - **Review test failures**: Never ignore failing tests |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.