daimyo 1.0.0__tar.gz

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.
Files changed (70) hide show
  1. daimyo-1.0.0/.gitignore +61 -0
  2. daimyo-1.0.0/LICENSE +21 -0
  3. daimyo-1.0.0/PKG-INFO +301 -0
  4. daimyo-1.0.0/README.md +262 -0
  5. daimyo-1.0.0/daimyo/__init__.py +11 -0
  6. daimyo-1.0.0/daimyo/__main__.py +205 -0
  7. daimyo-1.0.0/daimyo/application/__init__.py +1 -0
  8. daimyo-1.0.0/daimyo/application/filtering/__init__.py +5 -0
  9. daimyo-1.0.0/daimyo/application/filtering/category_filter.py +81 -0
  10. daimyo-1.0.0/daimyo/application/formatters/__init__.py +8 -0
  11. daimyo-1.0.0/daimyo/application/formatters/json_formatter.py +53 -0
  12. daimyo-1.0.0/daimyo/application/formatters/markdown_formatter.py +149 -0
  13. daimyo-1.0.0/daimyo/application/formatters/tree_builder.py +105 -0
  14. daimyo-1.0.0/daimyo/application/formatters/yaml_formatter.py +84 -0
  15. daimyo-1.0.0/daimyo/application/rule_service.py +140 -0
  16. daimyo-1.0.0/daimyo/application/scope_resolution/__init__.py +5 -0
  17. daimyo-1.0.0/daimyo/application/scope_resolution/circular_dependency_detector.py +45 -0
  18. daimyo-1.0.0/daimyo/application/scope_resolution/multi_parent_resolver.py +80 -0
  19. daimyo-1.0.0/daimyo/application/scope_resolution/parent_resolver.py +84 -0
  20. daimyo-1.0.0/daimyo/application/scope_resolution/remote_scope_fetcher.py +43 -0
  21. daimyo-1.0.0/daimyo/application/scope_resolution/scope_resolver.py +99 -0
  22. daimyo-1.0.0/daimyo/application/scope_resolution/shard_merger.py +82 -0
  23. daimyo-1.0.0/daimyo/application/scope_service.py +9 -0
  24. daimyo-1.0.0/daimyo/config/__init__.py +5 -0
  25. daimyo-1.0.0/daimyo/config/settings.py +25 -0
  26. daimyo-1.0.0/daimyo/domain/__init__.py +51 -0
  27. daimyo-1.0.0/daimyo/domain/exceptions.py +68 -0
  28. daimyo-1.0.0/daimyo/domain/models.py +296 -0
  29. daimyo-1.0.0/daimyo/domain/protocols.py +59 -0
  30. daimyo-1.0.0/daimyo/infrastructure/__init__.py +1 -0
  31. daimyo-1.0.0/daimyo/infrastructure/di/__init__.py +5 -0
  32. daimyo-1.0.0/daimyo/infrastructure/di/container.py +120 -0
  33. daimyo-1.0.0/daimyo/infrastructure/filesystem/__init__.py +12 -0
  34. daimyo-1.0.0/daimyo/infrastructure/filesystem/scope_loader.py +112 -0
  35. daimyo-1.0.0/daimyo/infrastructure/filesystem/yaml_parser.py +188 -0
  36. daimyo-1.0.0/daimyo/infrastructure/logging/__init__.py +5 -0
  37. daimyo-1.0.0/daimyo/infrastructure/logging/logger.py +73 -0
  38. daimyo-1.0.0/daimyo/infrastructure/remote/__init__.py +5 -0
  39. daimyo-1.0.0/daimyo/infrastructure/remote/remote_client.py +178 -0
  40. daimyo-1.0.0/daimyo/presentation/__init__.py +1 -0
  41. daimyo-1.0.0/daimyo/presentation/mcp/__init__.py +1 -0
  42. daimyo-1.0.0/daimyo/presentation/mcp/server.py +128 -0
  43. daimyo-1.0.0/daimyo/presentation/rest/__init__.py +1 -0
  44. daimyo-1.0.0/daimyo/presentation/rest/app.py +99 -0
  45. daimyo-1.0.0/daimyo/presentation/rest/dependencies.py +41 -0
  46. daimyo-1.0.0/daimyo/presentation/rest/models.py +68 -0
  47. daimyo-1.0.0/daimyo/presentation/rest/routers/__init__.py +1 -0
  48. daimyo-1.0.0/daimyo/presentation/rest/routers/scopes.py +279 -0
  49. daimyo-1.0.0/pyproject.toml +119 -0
  50. daimyo-1.0.0/tests/conftest.py +368 -0
  51. daimyo-1.0.0/tests/integration/__init__.py +1 -0
  52. daimyo-1.0.0/tests/integration/test_mcp_server.py +241 -0
  53. daimyo-1.0.0/tests/integration/test_rest_api.py +91 -0
  54. daimyo-1.0.0/tests/unit/__init__.py +1 -0
  55. daimyo-1.0.0/tests/unit/application/__init__.py +1 -0
  56. daimyo-1.0.0/tests/unit/application/scope_resolution/__init__.py +1 -0
  57. daimyo-1.0.0/tests/unit/application/scope_resolution/test_circular_dependency_detector.py +171 -0
  58. daimyo-1.0.0/tests/unit/application/scope_resolution/test_multi_parent_resolver.py +116 -0
  59. daimyo-1.0.0/tests/unit/application/scope_resolution/test_parent_resolver.py +423 -0
  60. daimyo-1.0.0/tests/unit/application/scope_resolution/test_remote_scope_fetcher.py +219 -0
  61. daimyo-1.0.0/tests/unit/application/scope_resolution/test_shard_merger.py +346 -0
  62. daimyo-1.0.0/tests/unit/application/test_formatters.py +93 -0
  63. daimyo-1.0.0/tests/unit/application/test_rule_service.py +178 -0
  64. daimyo-1.0.0/tests/unit/application/test_scope_resolution_service.py +408 -0
  65. daimyo-1.0.0/tests/unit/domain/__init__.py +1 -0
  66. daimyo-1.0.0/tests/unit/domain/test_models.py +293 -0
  67. daimyo-1.0.0/tests/unit/infrastructure/__init__.py +1 -0
  68. daimyo-1.0.0/tests/unit/infrastructure/test_http_remote_client.py +243 -0
  69. daimyo-1.0.0/tests/unit/infrastructure/test_yaml_parser.py +231 -0
  70. daimyo-1.0.0/tests/unit/test_cli.py +286 -0
@@ -0,0 +1,61 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+ MANIFEST
23
+
24
+ # Virtual environments
25
+ venv/
26
+ ENV/
27
+ env/
28
+ .venv
29
+
30
+ # IDEs
31
+ .vscode/
32
+ .idea/
33
+ *.swp
34
+ *.swo
35
+ *~
36
+
37
+ # Testing
38
+ .pytest_cache/
39
+ .coverage
40
+ htmlcov/
41
+ .tox/
42
+
43
+ # Logs
44
+ logs/
45
+ *.log
46
+
47
+ # Configuration secrets
48
+ config/.secrets.toml
49
+ .secrets.toml
50
+
51
+ # OS
52
+ .DS_Store
53
+ Thumbs.db
54
+
55
+ # Hatch
56
+ .hatch/
57
+
58
+ # Type checking
59
+ .mypy_cache/
60
+ .dmypy.json
61
+ dmypy.json
daimyo-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jesús Alonso Abad
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
daimyo-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,301 @@
1
+ Metadata-Version: 2.4
2
+ Name: daimyo
3
+ Version: 1.0.0
4
+ Summary: Rules server for agents with REST and MCP interfaces
5
+ Project-URL: Homepage, https://gitlab.com/Kencho1/daimyo
6
+ Project-URL: Repository, https://gitlab.com/Kencho1/daimyo
7
+ Project-URL: Issues, https://gitlab.com/Kencho1/daimyo/-/issues
8
+ Project-URL: Changelog, https://gitlab.com/Kencho1/daimyo/-/blob/main/CHANGELOG.md
9
+ Author: Jesús Alonso Abad
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: cachetools~=5.3
22
+ Requires-Dist: dynaconf~=3.2
23
+ Requires-Dist: fastapi~=0.104
24
+ Requires-Dist: fastmcp~=0.2
25
+ Requires-Dist: httpx~=0.25
26
+ Requires-Dist: loguru~=0.7
27
+ Requires-Dist: pydantic~=2.5
28
+ Requires-Dist: pyyaml~=6.0
29
+ Requires-Dist: typer~=0.9
30
+ Requires-Dist: uvicorn[standard]~=0.24
31
+ Provides-Extra: dev
32
+ Requires-Dist: mypy~=1.7; extra == 'dev'
33
+ Requires-Dist: pytest-asyncio~=0.21; extra == 'dev'
34
+ Requires-Dist: pytest-cov~=4.1; extra == 'dev'
35
+ Requires-Dist: pytest-httpx~=0.27; extra == 'dev'
36
+ Requires-Dist: pytest~=7.4; extra == 'dev'
37
+ Requires-Dist: ruff~=0.1; extra == 'dev'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # Daimyo - Rules Server for Agents
41
+
42
+ A Python server providing rules to AI agents through REST and MCP interfaces. Supports scope-based rules with inheritance, categories for filtering, and server federation for distributed rule management.
43
+
44
+ ## Features
45
+
46
+ - **Multiple Interfaces**: REST API, MCP (Model Context Protocol), and CLI
47
+ - **Scope Inheritance**: Single and multiple parent inheritance with priority-based conflict resolution
48
+ - **Rule Types**: Commandments (MUST) and Suggestions (SHOULD)
49
+ - **Categories**: Organize rules into hierarchical categories for selective retrieval
50
+ - **Server Federation**: Distribute scopes across multiple servers with automatic merging
51
+ - **Multiple Formats**: Output as YAML, JSON, or Markdown
52
+ - **Clean Architecture**: Domain-driven design with clear separation of concerns
53
+
54
+ ## Installation
55
+
56
+ ```bash
57
+ pip install daimyo
58
+ ```
59
+
60
+ Or install from source:
61
+
62
+ ```bash
63
+ git clone https://gitlab.com/Kencho1/daimyo.git
64
+ cd daimyo
65
+ pip install -e .
66
+ ```
67
+
68
+ ## Quick Start
69
+
70
+ ### 1. Set Up Your Rules
71
+
72
+ ```bash
73
+ cp -r example-daimyo-rules daimyo-rules
74
+ ```
75
+
76
+ ### 2. Start the Server
77
+
78
+ ```bash
79
+ daimyo serve
80
+ ```
81
+
82
+ ### 3. Access the API
83
+
84
+ Visit http://localhost:8000/docs for interactive API documentation.
85
+
86
+ ```bash
87
+ curl http://localhost:8000/api/v1/scopes/python-general/rules
88
+ ```
89
+
90
+ ## Core Concepts
91
+
92
+ ### Scopes
93
+
94
+ Scopes represent organizational contexts (company, team, project). Each scope is a directory containing:
95
+
96
+ - `metadata.yml` - Scope configuration and parent references
97
+ - `commandments.yml` - Mandatory rules (MUST)
98
+ - `suggestions.yml` - Recommended rules (SHOULD)
99
+
100
+ ```text
101
+ daimyo-rules/
102
+ ├── python-general/
103
+ │ ├── metadata.yml
104
+ │ ├── commandments.yml
105
+ │ └── suggestions.yml
106
+ └── team-backend/
107
+ ├── metadata.yml
108
+ ├── commandments.yml
109
+ └── suggestions.yml
110
+ ```
111
+
112
+ ### Metadata Format
113
+
114
+ ```yaml
115
+ name: scope-name
116
+ description: Human-readable description
117
+ parents:
118
+ - parent-scope-1
119
+ - parent-scope-2
120
+ tags:
121
+ team: backend
122
+ language: python
123
+ ```
124
+
125
+ **Fields:**
126
+
127
+ - `name`: Scope identifier (must match directory name)
128
+ - `description`: Human-readable description
129
+ - `parents`: List of parent scopes (first = highest priority)
130
+ - `tags`: Key-value pairs for categorization
131
+
132
+ ### Categories
133
+
134
+ Categories are hierarchical subdivisions within rules:
135
+
136
+ ```yaml
137
+ python.web.testing:
138
+ when: When testing web interfaces
139
+ ruleset:
140
+ - Use playwright for acceptance tests
141
+ - Use pytest fixtures for test setup
142
+ ```
143
+
144
+ ### Rule Types
145
+
146
+ **Commandments (MUST)**: Mandatory rules that accumulate through inheritance
147
+
148
+ **Suggestions (SHOULD)**: Recommended rules that can be overridden or appended with `+` prefix
149
+
150
+ ## Usage
151
+
152
+ ### REST API
153
+
154
+ Start the server:
155
+
156
+ ```bash
157
+ daimyo serve
158
+ daimyo serve --host 0.0.0.0 --port 8080
159
+ ```
160
+
161
+ Get rules:
162
+
163
+ ```bash
164
+ curl http://localhost:8000/api/v1/scopes/python-general/rules
165
+
166
+ curl -H "Accept: application/json" \
167
+ http://localhost:8000/api/v1/scopes/python-general/rules
168
+
169
+ curl -H "Accept: text/markdown" \
170
+ http://localhost:8000/api/v1/scopes/python-general/rules
171
+ ```
172
+
173
+ Filter by categories:
174
+
175
+ ```bash
176
+ curl "http://localhost:8000/api/v1/scopes/team-backend/rules?categories=python.web,python.testing"
177
+ ```
178
+
179
+ ### MCP Server
180
+
181
+ Start the MCP server:
182
+
183
+ ```bash
184
+ daimyo mcp
185
+ daimyo mcp --transport sse
186
+ ```
187
+
188
+ Available tools:
189
+
190
+ - `get_rules(scope_name, categories?)` - Get formatted rules
191
+ - `list_scopes()` - List available scopes
192
+ - `apply_scope_rules(scope_name, categories?)` - Get prompt template with rules
193
+
194
+ ### CLI Commands
195
+
196
+ ```bash
197
+ daimyo list-scopes
198
+ daimyo show python-general
199
+ daimyo --version
200
+ ```
201
+
202
+ ## Configuration
203
+
204
+ Configuration is managed via `config/settings.toml` or environment variables:
205
+
206
+ ```toml
207
+ [default]
208
+ rules_path = "./daimyo-rules"
209
+ console_log_level = "WARNING"
210
+ file_log_level = "INFO"
211
+ max_inheritance_depth = 10
212
+ master_server_url = ""
213
+ remote_timeout_seconds = 5
214
+ rest_port = 8000
215
+ ```
216
+
217
+ Override with environment variables:
218
+
219
+ ```bash
220
+ export DAIMYO_RULES_PATH="/custom/rules/path"
221
+ export DAIMYO_MASTER_SERVER_URL="http://master.example.com:8000"
222
+ export DAIMYO_CONSOLE_LOG_LEVEL="DEBUG"
223
+ ```
224
+
225
+ ## Examples
226
+
227
+ The `example-daimyo-rules/` directory contains working examples:
228
+
229
+ ### python-general
230
+
231
+ Base Python development rules with categories for core practices, testing, security, and documentation.
232
+
233
+ ### python-fastapi
234
+
235
+ FastAPI framework rules extending `python-general` with routing, async patterns, and performance optimization.
236
+
237
+ ### team-backend
238
+
239
+ Backend team rules extending `python-general` with REST API patterns, database access, and deployment considerations.
240
+
241
+ ### project-api
242
+
243
+ Demonstrates multiple parent inheritance with `parents: [team-backend, python-fastapi]`:
244
+
245
+ - Combines team-specific and technology-specific rules
246
+ - Shows priority-based conflict resolution
247
+ - Uses `+` prefix to append to parent rules
248
+
249
+ ## Advanced Topics
250
+
251
+ ### Multiple Parent Inheritance
252
+
253
+ ```yaml
254
+ parents:
255
+ - high-priority
256
+ - low-priority
257
+ ```
258
+
259
+ **Commandments**: All rules from all parents are combined (additive)
260
+
261
+ **Suggestions**: First parent wins in conflicts; use `+` prefix to append instead of replace
262
+
263
+ ### Server Federation
264
+
265
+ Configure a master server for distributed scope management:
266
+
267
+ ```bash
268
+ export DAIMYO_MASTER_SERVER_URL="http://master.example.com:8000"
269
+ ```
270
+
271
+ The system will:
272
+
273
+ 1. Look for scopes locally
274
+ 2. Look for scopes on the master server
275
+ 3. Merge both if found in both locations (local extends remote)
276
+
277
+ ### Scope Sharding
278
+
279
+ The same scope name can exist on both master server and locally. When both exist, they are merged with the remote version as the base and the local version extending it.
280
+
281
+ ## Development
282
+
283
+ ### Running Tests
284
+
285
+ ```bash
286
+ pip install -e ".[dev]"
287
+ pytest
288
+ pytest --cov=daimyo
289
+ ```
290
+
291
+ ### Code Quality
292
+
293
+ ```bash
294
+ mypy daimyo
295
+ ruff check daimyo
296
+ ruff format daimyo
297
+ ```
298
+
299
+ ## License
300
+
301
+ MIT
daimyo-1.0.0/README.md ADDED
@@ -0,0 +1,262 @@
1
+ # Daimyo - Rules Server for Agents
2
+
3
+ A Python server providing rules to AI agents through REST and MCP interfaces. Supports scope-based rules with inheritance, categories for filtering, and server federation for distributed rule management.
4
+
5
+ ## Features
6
+
7
+ - **Multiple Interfaces**: REST API, MCP (Model Context Protocol), and CLI
8
+ - **Scope Inheritance**: Single and multiple parent inheritance with priority-based conflict resolution
9
+ - **Rule Types**: Commandments (MUST) and Suggestions (SHOULD)
10
+ - **Categories**: Organize rules into hierarchical categories for selective retrieval
11
+ - **Server Federation**: Distribute scopes across multiple servers with automatic merging
12
+ - **Multiple Formats**: Output as YAML, JSON, or Markdown
13
+ - **Clean Architecture**: Domain-driven design with clear separation of concerns
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install daimyo
19
+ ```
20
+
21
+ Or install from source:
22
+
23
+ ```bash
24
+ git clone https://gitlab.com/Kencho1/daimyo.git
25
+ cd daimyo
26
+ pip install -e .
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ ### 1. Set Up Your Rules
32
+
33
+ ```bash
34
+ cp -r example-daimyo-rules daimyo-rules
35
+ ```
36
+
37
+ ### 2. Start the Server
38
+
39
+ ```bash
40
+ daimyo serve
41
+ ```
42
+
43
+ ### 3. Access the API
44
+
45
+ Visit http://localhost:8000/docs for interactive API documentation.
46
+
47
+ ```bash
48
+ curl http://localhost:8000/api/v1/scopes/python-general/rules
49
+ ```
50
+
51
+ ## Core Concepts
52
+
53
+ ### Scopes
54
+
55
+ Scopes represent organizational contexts (company, team, project). Each scope is a directory containing:
56
+
57
+ - `metadata.yml` - Scope configuration and parent references
58
+ - `commandments.yml` - Mandatory rules (MUST)
59
+ - `suggestions.yml` - Recommended rules (SHOULD)
60
+
61
+ ```text
62
+ daimyo-rules/
63
+ ├── python-general/
64
+ │ ├── metadata.yml
65
+ │ ├── commandments.yml
66
+ │ └── suggestions.yml
67
+ └── team-backend/
68
+ ├── metadata.yml
69
+ ├── commandments.yml
70
+ └── suggestions.yml
71
+ ```
72
+
73
+ ### Metadata Format
74
+
75
+ ```yaml
76
+ name: scope-name
77
+ description: Human-readable description
78
+ parents:
79
+ - parent-scope-1
80
+ - parent-scope-2
81
+ tags:
82
+ team: backend
83
+ language: python
84
+ ```
85
+
86
+ **Fields:**
87
+
88
+ - `name`: Scope identifier (must match directory name)
89
+ - `description`: Human-readable description
90
+ - `parents`: List of parent scopes (first = highest priority)
91
+ - `tags`: Key-value pairs for categorization
92
+
93
+ ### Categories
94
+
95
+ Categories are hierarchical subdivisions within rules:
96
+
97
+ ```yaml
98
+ python.web.testing:
99
+ when: When testing web interfaces
100
+ ruleset:
101
+ - Use playwright for acceptance tests
102
+ - Use pytest fixtures for test setup
103
+ ```
104
+
105
+ ### Rule Types
106
+
107
+ **Commandments (MUST)**: Mandatory rules that accumulate through inheritance
108
+
109
+ **Suggestions (SHOULD)**: Recommended rules that can be overridden or appended with `+` prefix
110
+
111
+ ## Usage
112
+
113
+ ### REST API
114
+
115
+ Start the server:
116
+
117
+ ```bash
118
+ daimyo serve
119
+ daimyo serve --host 0.0.0.0 --port 8080
120
+ ```
121
+
122
+ Get rules:
123
+
124
+ ```bash
125
+ curl http://localhost:8000/api/v1/scopes/python-general/rules
126
+
127
+ curl -H "Accept: application/json" \
128
+ http://localhost:8000/api/v1/scopes/python-general/rules
129
+
130
+ curl -H "Accept: text/markdown" \
131
+ http://localhost:8000/api/v1/scopes/python-general/rules
132
+ ```
133
+
134
+ Filter by categories:
135
+
136
+ ```bash
137
+ curl "http://localhost:8000/api/v1/scopes/team-backend/rules?categories=python.web,python.testing"
138
+ ```
139
+
140
+ ### MCP Server
141
+
142
+ Start the MCP server:
143
+
144
+ ```bash
145
+ daimyo mcp
146
+ daimyo mcp --transport sse
147
+ ```
148
+
149
+ Available tools:
150
+
151
+ - `get_rules(scope_name, categories?)` - Get formatted rules
152
+ - `list_scopes()` - List available scopes
153
+ - `apply_scope_rules(scope_name, categories?)` - Get prompt template with rules
154
+
155
+ ### CLI Commands
156
+
157
+ ```bash
158
+ daimyo list-scopes
159
+ daimyo show python-general
160
+ daimyo --version
161
+ ```
162
+
163
+ ## Configuration
164
+
165
+ Configuration is managed via `config/settings.toml` or environment variables:
166
+
167
+ ```toml
168
+ [default]
169
+ rules_path = "./daimyo-rules"
170
+ console_log_level = "WARNING"
171
+ file_log_level = "INFO"
172
+ max_inheritance_depth = 10
173
+ master_server_url = ""
174
+ remote_timeout_seconds = 5
175
+ rest_port = 8000
176
+ ```
177
+
178
+ Override with environment variables:
179
+
180
+ ```bash
181
+ export DAIMYO_RULES_PATH="/custom/rules/path"
182
+ export DAIMYO_MASTER_SERVER_URL="http://master.example.com:8000"
183
+ export DAIMYO_CONSOLE_LOG_LEVEL="DEBUG"
184
+ ```
185
+
186
+ ## Examples
187
+
188
+ The `example-daimyo-rules/` directory contains working examples:
189
+
190
+ ### python-general
191
+
192
+ Base Python development rules with categories for core practices, testing, security, and documentation.
193
+
194
+ ### python-fastapi
195
+
196
+ FastAPI framework rules extending `python-general` with routing, async patterns, and performance optimization.
197
+
198
+ ### team-backend
199
+
200
+ Backend team rules extending `python-general` with REST API patterns, database access, and deployment considerations.
201
+
202
+ ### project-api
203
+
204
+ Demonstrates multiple parent inheritance with `parents: [team-backend, python-fastapi]`:
205
+
206
+ - Combines team-specific and technology-specific rules
207
+ - Shows priority-based conflict resolution
208
+ - Uses `+` prefix to append to parent rules
209
+
210
+ ## Advanced Topics
211
+
212
+ ### Multiple Parent Inheritance
213
+
214
+ ```yaml
215
+ parents:
216
+ - high-priority
217
+ - low-priority
218
+ ```
219
+
220
+ **Commandments**: All rules from all parents are combined (additive)
221
+
222
+ **Suggestions**: First parent wins in conflicts; use `+` prefix to append instead of replace
223
+
224
+ ### Server Federation
225
+
226
+ Configure a master server for distributed scope management:
227
+
228
+ ```bash
229
+ export DAIMYO_MASTER_SERVER_URL="http://master.example.com:8000"
230
+ ```
231
+
232
+ The system will:
233
+
234
+ 1. Look for scopes locally
235
+ 2. Look for scopes on the master server
236
+ 3. Merge both if found in both locations (local extends remote)
237
+
238
+ ### Scope Sharding
239
+
240
+ The same scope name can exist on both master server and locally. When both exist, they are merged with the remote version as the base and the local version extending it.
241
+
242
+ ## Development
243
+
244
+ ### Running Tests
245
+
246
+ ```bash
247
+ pip install -e ".[dev]"
248
+ pytest
249
+ pytest --cov=daimyo
250
+ ```
251
+
252
+ ### Code Quality
253
+
254
+ ```bash
255
+ mypy daimyo
256
+ ruff check daimyo
257
+ ruff format daimyo
258
+ ```
259
+
260
+ ## License
261
+
262
+ MIT
@@ -0,0 +1,11 @@
1
+ """
2
+ Daimyo - Rules Server for Agents
3
+
4
+ A Python server providing rules to agents through REST and MCP interfaces.
5
+ Supports scope-based rules with inheritance, categories for filtering,
6
+ and server federation for distributed rule management.
7
+ """
8
+
9
+ __version__ = "1.0.0"
10
+
11
+ __all__ = ["__version__"]