bugyo-prjmeta 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.
@@ -0,0 +1,62 @@
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
+ .daimyo/config/.secrets.toml
49
+ config/.secrets.toml
50
+ .secrets.toml
51
+
52
+ # OS
53
+ .DS_Store
54
+ Thumbs.db
55
+
56
+ # Hatch
57
+ .hatch/
58
+
59
+ # Type checking
60
+ .mypy_cache/
61
+ .dmypy.json
62
+ dmypy.json
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 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.
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: bugyo-prjmeta
3
+ Version: 1.0.0
4
+ Summary: Project metadata plugin for Daimyo - provides .project-metadata.yml content for templates
5
+ Project-URL: Homepage, https://gitlab.com/Kencho1/daimyo
6
+ Project-URL: Documentation, https://gitlab.com/Kencho1/daimyo/-/blob/main/plugins/bugyo-prjmeta/README.md
7
+ Project-URL: Repository, https://gitlab.com/Kencho1/daimyo
8
+ Project-URL: Issues, https://gitlab.com/Kencho1/daimyo/-/issues
9
+ Author: Jesús Alonso Abad
10
+ License: MIT License
11
+
12
+ Copyright (c) 2026 Jesús Alonso Abad
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ License-File: LICENSE
32
+ Keywords: daimyo,jinja2,metadata,plugin,project,templates
33
+ Classifier: Development Status :: 5 - Production/Stable
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: OS Independent
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Programming Language :: Python :: 3.13
41
+ Classifier: Programming Language :: Python :: 3.14
42
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
43
+ Classifier: Typing :: Typed
44
+ Requires-Python: >=3.11
45
+ Requires-Dist: daimyo>=1.4.0
46
+ Requires-Dist: pyyaml~=6.0
47
+ Description-Content-Type: text/markdown
48
+
49
+ # bugyo-prjmeta
50
+
51
+ Project metadata plugin for Daimyo - provides `.project-metadata.yml` content for Jinja2 templates.
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ pip install bugyo-prjmeta
57
+ ```
58
+
59
+ ## Requirements
60
+
61
+ - Python >= 3.11
62
+ - daimyo >= 1.4.0
63
+ - pyyaml ~= 6.0
64
+
65
+ ## Features
66
+
67
+ ### Context Variables
68
+
69
+ The `prjmeta.context` plugin provides the following template variable:
70
+
71
+ | Variable | Type | Description |
72
+ |----------|------|-------------|
73
+ | `project_metadata` | dict | Full contents of `.project-metadata.yml` in the project root |
74
+
75
+ ## Configuration
76
+
77
+ Enable the plugin in your `.daimyo/config/settings.toml`:
78
+
79
+ ```toml
80
+ # Enable all project metadata plugins
81
+ enabled_plugins = ["prjmeta.*"]
82
+
83
+ # Or enable the specific context plugin
84
+ enabled_plugins = ["prjmeta.context"]
85
+ ```
86
+
87
+ ## Usage
88
+
89
+ ### Template Examples
90
+
91
+ #### Conditional Rules Based on Project Metadata
92
+
93
+ ```yaml
94
+ project.language:
95
+ when: Language-specific guidelines
96
+ ruleset:
97
+ - "{% if project_metadata.get('language') == 'python' %}Use uv for dependency management{% endif %}"
98
+ - "{% if project_metadata.get('language') == 'javascript' %}Use npm or yarn for dependency management{% endif %}"
99
+ ```
100
+
101
+ #### Using Daimyo Scope
102
+
103
+ The `.project-metadata.yml` file is used by Claude Code to determine the daimyo rule scope.
104
+ Its full contents are also available in templates:
105
+
106
+ ```yaml
107
+ project.info:
108
+ when: Project information rules
109
+ ruleset:
110
+ - "{% if project_metadata.get('daimyo', {}).get('scope') %}Rules scope: {{ project_metadata.daimyo.scope }}{% endif %}"
111
+ - "{% if project_metadata.get('team') %}Team: {{ project_metadata.team }}{% endif %}"
112
+ ```
113
+
114
+ #### Accessing Nested Metadata
115
+
116
+ ```yaml
117
+ project.team:
118
+ when: Team-specific guidelines
119
+ ruleset:
120
+ - "{% set team = project_metadata.get('team', {}) %}"
121
+ - "{% if team.get('timezone') %}Team timezone: {{ team.timezone }}{% endif %}"
122
+ - "{% if team.get('lead') %}Technical lead: {{ team.lead }}{% endif %}"
123
+ ```
124
+
125
+ ## Availability
126
+
127
+ The plugin is **always available**, even when `.project-metadata.yml` does not exist in the project root. In that case, `project_metadata` is an empty dict `{}`.
128
+
129
+ ## Security
130
+
131
+ This plugin reads only `.project-metadata.yml` from the current working directory. No path traversal is possible - the file path is fixed and cannot be influenced by template authors.
132
+
133
+ ## License
134
+
135
+ MIT License - see LICENSE file for details.
136
+
137
+ ## Support
138
+
139
+ For issues and questions, please visit the [Daimyo issue tracker](https://gitlab.com/Kencho1/daimyo/-/issues).
@@ -0,0 +1,91 @@
1
+ # bugyo-prjmeta
2
+
3
+ Project metadata plugin for Daimyo - provides `.project-metadata.yml` content for Jinja2 templates.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install bugyo-prjmeta
9
+ ```
10
+
11
+ ## Requirements
12
+
13
+ - Python >= 3.11
14
+ - daimyo >= 1.4.0
15
+ - pyyaml ~= 6.0
16
+
17
+ ## Features
18
+
19
+ ### Context Variables
20
+
21
+ The `prjmeta.context` plugin provides the following template variable:
22
+
23
+ | Variable | Type | Description |
24
+ |----------|------|-------------|
25
+ | `project_metadata` | dict | Full contents of `.project-metadata.yml` in the project root |
26
+
27
+ ## Configuration
28
+
29
+ Enable the plugin in your `.daimyo/config/settings.toml`:
30
+
31
+ ```toml
32
+ # Enable all project metadata plugins
33
+ enabled_plugins = ["prjmeta.*"]
34
+
35
+ # Or enable the specific context plugin
36
+ enabled_plugins = ["prjmeta.context"]
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ### Template Examples
42
+
43
+ #### Conditional Rules Based on Project Metadata
44
+
45
+ ```yaml
46
+ project.language:
47
+ when: Language-specific guidelines
48
+ ruleset:
49
+ - "{% if project_metadata.get('language') == 'python' %}Use uv for dependency management{% endif %}"
50
+ - "{% if project_metadata.get('language') == 'javascript' %}Use npm or yarn for dependency management{% endif %}"
51
+ ```
52
+
53
+ #### Using Daimyo Scope
54
+
55
+ The `.project-metadata.yml` file is used by Claude Code to determine the daimyo rule scope.
56
+ Its full contents are also available in templates:
57
+
58
+ ```yaml
59
+ project.info:
60
+ when: Project information rules
61
+ ruleset:
62
+ - "{% if project_metadata.get('daimyo', {}).get('scope') %}Rules scope: {{ project_metadata.daimyo.scope }}{% endif %}"
63
+ - "{% if project_metadata.get('team') %}Team: {{ project_metadata.team }}{% endif %}"
64
+ ```
65
+
66
+ #### Accessing Nested Metadata
67
+
68
+ ```yaml
69
+ project.team:
70
+ when: Team-specific guidelines
71
+ ruleset:
72
+ - "{% set team = project_metadata.get('team', {}) %}"
73
+ - "{% if team.get('timezone') %}Team timezone: {{ team.timezone }}{% endif %}"
74
+ - "{% if team.get('lead') %}Technical lead: {{ team.lead }}{% endif %}"
75
+ ```
76
+
77
+ ## Availability
78
+
79
+ The plugin is **always available**, even when `.project-metadata.yml` does not exist in the project root. In that case, `project_metadata` is an empty dict `{}`.
80
+
81
+ ## Security
82
+
83
+ This plugin reads only `.project-metadata.yml` from the current working directory. No path traversal is possible - the file path is fixed and cannot be influenced by template authors.
84
+
85
+ ## License
86
+
87
+ MIT License - see LICENSE file for details.
88
+
89
+ ## Support
90
+
91
+ For issues and questions, please visit the [Daimyo issue tracker](https://gitlab.com/Kencho1/daimyo/-/issues).
@@ -0,0 +1,4 @@
1
+ """Bugyo-PrjMeta: Project metadata plugin for Daimyo."""
2
+
3
+ __version__ = "1.0.0"
4
+ __all__ = ["__version__"]
@@ -0,0 +1,48 @@
1
+ """Project metadata plugin for Daimyo.
2
+
3
+ Provides project metadata from .project-metadata.yml for Jinja2 templates.
4
+ """
5
+
6
+ from pathlib import Path
7
+ from typing import Any
8
+
9
+ import yaml
10
+
11
+ from daimyo.domain import ContextProviderPlugin, MergedScope
12
+
13
+
14
+ class ProjectMetadataContextPlugin(ContextProviderPlugin):
15
+ """Provides project metadata from .project-metadata.yml for templates.
16
+
17
+ Reads the .project-metadata.yml file from the current working directory
18
+ and exposes its contents as the ``project_metadata`` template variable.
19
+ If the file does not exist, an empty dict is returned.
20
+ """
21
+
22
+ @property
23
+ def name(self) -> str:
24
+ return "prjmeta.context"
25
+
26
+ @property
27
+ def description(self) -> str:
28
+ return "Provides project metadata from .project-metadata.yml for templates"
29
+
30
+ def is_available(self) -> bool:
31
+ """Always available."""
32
+ return True
33
+
34
+ def get_context(self, scope: MergedScope) -> dict[str, Any]:
35
+ """Return project metadata context variables.
36
+
37
+ :param scope: The merged scope being rendered
38
+ :type scope: MergedScope
39
+ :returns: Dictionary containing ``project_metadata`` key with parsed YAML content
40
+ :rtype: dict[str, Any]
41
+ """
42
+ metadata_file = Path.cwd() / ".project-metadata.yml"
43
+
44
+ if not metadata_file.exists():
45
+ return {"project_metadata": {}}
46
+
47
+ data = yaml.safe_load(metadata_file.read_text())
48
+ return {"project_metadata": data or {}}
@@ -0,0 +1,96 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "bugyo-prjmeta"
7
+ dynamic = ["version"]
8
+ description = "Project metadata plugin for Daimyo - provides .project-metadata.yml content for templates"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = {file = "LICENSE"}
12
+ authors = [
13
+ {name = "Jesús Alonso Abad"},
14
+ ]
15
+ keywords = ["daimyo", "plugin", "project", "metadata", "templates", "jinja2"]
16
+ classifiers = [
17
+ "Development Status :: 5 - Production/Stable",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Programming Language :: Python :: 3.14",
26
+ "Topic :: Software Development :: Libraries :: Python Modules",
27
+ "Typing :: Typed",
28
+ ]
29
+
30
+ dependencies = [
31
+ "daimyo>=1.4.0",
32
+ "pyyaml~=6.0",
33
+ ]
34
+
35
+ [project.urls]
36
+ Homepage = "https://gitlab.com/Kencho1/daimyo"
37
+ Documentation = "https://gitlab.com/Kencho1/daimyo/-/blob/main/plugins/bugyo-prjmeta/README.md"
38
+ Repository = "https://gitlab.com/Kencho1/daimyo"
39
+ Issues = "https://gitlab.com/Kencho1/daimyo/-/issues"
40
+
41
+ [project.entry-points."daimyo.plugins"]
42
+ "prjmeta.context" = "bugyo_prjmeta.plugins:ProjectMetadataContextPlugin"
43
+
44
+ [tool.hatch.version]
45
+ path = "bugyo_prjmeta/__init__.py"
46
+
47
+ [tool.hatch.build.targets.wheel]
48
+ packages = ["bugyo_prjmeta"]
49
+
50
+ [tool.hatch.build.targets.sdist]
51
+ include = [
52
+ "bugyo_prjmeta/**/*.py",
53
+ "tests/**/*.py",
54
+ "README.md",
55
+ "LICENSE",
56
+ ]
57
+
58
+ [tool.pytest.ini_options]
59
+ testpaths = ["tests"]
60
+ python_files = ["test_*.py"]
61
+ python_classes = ["Test*"]
62
+ python_functions = ["test_*"]
63
+ addopts = "-v --strict-markers --tb=short"
64
+
65
+ [tool.mypy]
66
+ strict = true
67
+ warn_return_any = true
68
+ warn_unused_configs = true
69
+ disallow_untyped_defs = true
70
+ disallow_any_generics = true
71
+ check_untyped_defs = true
72
+ no_implicit_optional = true
73
+ warn_redundant_casts = true
74
+ warn_unused_ignores = true
75
+ warn_no_return = true
76
+ follow_imports = "normal"
77
+ show_error_codes = true
78
+
79
+ [tool.ruff]
80
+ line-length = 100
81
+ target-version = "py311"
82
+
83
+ [tool.ruff.lint]
84
+ select = [
85
+ "E", # pycodestyle errors
86
+ "W", # pycodestyle warnings
87
+ "F", # pyflakes
88
+ "I", # isort
89
+ "B", # flake8-bugbear
90
+ "C4", # flake8-comprehensions
91
+ "UP", # pyupgrade",
92
+ ]
93
+ ignore = []
94
+
95
+ [tool.ruff.lint.per-file-ignores]
96
+ "tests/**/*.py" = ["D"]
File without changes
@@ -0,0 +1,39 @@
1
+ """Test fixtures for bugyo-prjmeta plugin tests."""
2
+
3
+ import pytest
4
+ from daimyo.domain import MergedScope, RuleSet, ScopeMetadata
5
+
6
+
7
+ @pytest.fixture
8
+ def sample_merged_scope():
9
+ """Create a sample merged scope for testing."""
10
+ metadata = ScopeMetadata(
11
+ name="test-scope",
12
+ description="Test scope",
13
+ tags={"env": "test"},
14
+ )
15
+ return MergedScope(
16
+ metadata=metadata,
17
+ commandments=RuleSet(categories={}),
18
+ suggestions=RuleSet(categories={}),
19
+ sources=["local"],
20
+ )
21
+
22
+
23
+ @pytest.fixture
24
+ def project_metadata_file(tmp_path):
25
+ """Create a temporary .project-metadata.yml with sample YAML content.
26
+
27
+ :param tmp_path: pytest tmp_path fixture
28
+ :returns: Path to the created .project-metadata.yml file
29
+ """
30
+ metadata_file = tmp_path / ".project-metadata.yml"
31
+ metadata_file.write_text(
32
+ "daimyo:\n"
33
+ " scope: test-scope\n"
34
+ "language: python\n"
35
+ "team:\n"
36
+ " lead: Alice\n"
37
+ " timezone: UTC\n"
38
+ )
39
+ return metadata_file
File without changes
@@ -0,0 +1,93 @@
1
+ """Tests for project metadata plugin."""
2
+
3
+ import pytest
4
+
5
+ from bugyo_prjmeta.plugins import ProjectMetadataContextPlugin
6
+
7
+
8
+ class TestProjectMetadataContextPlugin:
9
+ """Test ProjectMetadataContextPlugin functionality."""
10
+
11
+ def test_name(self):
12
+ """Plugin has correct name."""
13
+ plugin = ProjectMetadataContextPlugin()
14
+ assert plugin.name == "prjmeta.context"
15
+
16
+ def test_description(self):
17
+ """Plugin has a non-empty description."""
18
+ plugin = ProjectMetadataContextPlugin()
19
+ assert plugin.description
20
+
21
+ def test_is_available(self):
22
+ """Plugin is always available."""
23
+ plugin = ProjectMetadataContextPlugin()
24
+ assert plugin.is_available() is True
25
+
26
+ def test_get_context_no_file(self, tmp_path, monkeypatch, sample_merged_scope):
27
+ """Returns empty dict when .project-metadata.yml does not exist."""
28
+ monkeypatch.chdir(tmp_path)
29
+ plugin = ProjectMetadataContextPlugin()
30
+ context = plugin.get_context(sample_merged_scope)
31
+ assert context == {"project_metadata": {}}
32
+
33
+ def test_get_context_with_file(
34
+ self, tmp_path, monkeypatch, project_metadata_file, sample_merged_scope
35
+ ):
36
+ """Parses .project-metadata.yml and returns its content."""
37
+ monkeypatch.chdir(tmp_path)
38
+ plugin = ProjectMetadataContextPlugin()
39
+ context = plugin.get_context(sample_merged_scope)
40
+
41
+ assert "project_metadata" in context
42
+ data = context["project_metadata"]
43
+ assert data["language"] == "python"
44
+ assert data["daimyo"]["scope"] == "test-scope"
45
+
46
+ def test_get_context_empty_file(self, tmp_path, monkeypatch, sample_merged_scope):
47
+ """Returns empty dict for an empty .project-metadata.yml."""
48
+ monkeypatch.chdir(tmp_path)
49
+ (tmp_path / ".project-metadata.yml").write_text("")
50
+ plugin = ProjectMetadataContextPlugin()
51
+ context = plugin.get_context(sample_merged_scope)
52
+ assert context == {"project_metadata": {}}
53
+
54
+ def test_get_context_nested(self, tmp_path, monkeypatch, sample_merged_scope):
55
+ """Handles nested YAML structures correctly."""
56
+ monkeypatch.chdir(tmp_path)
57
+ (tmp_path / ".project-metadata.yml").write_text(
58
+ "team:\n"
59
+ " lead: Alice\n"
60
+ " members:\n"
61
+ " - Bob\n"
62
+ " - Charlie\n"
63
+ )
64
+ plugin = ProjectMetadataContextPlugin()
65
+ context = plugin.get_context(sample_merged_scope)
66
+
67
+ data = context["project_metadata"]
68
+ assert data["team"]["lead"] == "Alice"
69
+ assert data["team"]["members"] == ["Bob", "Charlie"]
70
+
71
+ @pytest.mark.parametrize(
72
+ ("yaml_content", "expected_key", "expected_value"),
73
+ [
74
+ ("key: value\n", "key", "value"),
75
+ ("number: 42\n", "number", 42),
76
+ ("flag: true\n", "flag", True),
77
+ ],
78
+ )
79
+ def test_get_context_scalar_types(
80
+ self,
81
+ tmp_path,
82
+ monkeypatch,
83
+ sample_merged_scope,
84
+ yaml_content,
85
+ expected_key,
86
+ expected_value,
87
+ ):
88
+ """Parses different scalar YAML types correctly."""
89
+ monkeypatch.chdir(tmp_path)
90
+ (tmp_path / ".project-metadata.yml").write_text(yaml_content)
91
+ plugin = ProjectMetadataContextPlugin()
92
+ context = plugin.get_context(sample_merged_scope)
93
+ assert context["project_metadata"][expected_key] == expected_value