yaddd-agents 0.2.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,169 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110
+ .pdm.toml
111
+ .pdm-python
112
+ .pdm-build/
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # ruff
144
+ .ruff_cache/
145
+
146
+ # mypy
147
+ .mypy_cache/
148
+
149
+ # ty
150
+ .ty/
151
+
152
+ # Pyre type checker
153
+ .pyre/
154
+
155
+ # pytype static type analyzer
156
+ .pytype/
157
+
158
+ # Cython debug symbols
159
+ cython_debug/
160
+
161
+ # IDE
162
+ .idea
163
+ .vscode/!launch.json
164
+ .vscode/!tasks.json
165
+
166
+ # OS
167
+ .DS_Store
168
+
169
+ *_old/
@@ -0,0 +1,59 @@
1
+ Metadata-Version: 2.5
2
+ Name: yaddd-agents
3
+ Version: 0.2.0
4
+ Summary: Generate and verify layered AGENTS.md rules for yaddd projects.
5
+ License: MIT
6
+ Keywords: agents,ai,ddd,yaddd
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Topic :: Software Development :: Quality Assurance
14
+ Requires-Python: >=3.12
15
+ Description-Content-Type: text/markdown
16
+
17
+ # yaddd-agents
18
+
19
+ Generates and verifies the layered rule set used by AI coding agents in
20
+ projects built on `yaddd`.
21
+
22
+ The package is intentionally generic: it knows about DDD layers, not about
23
+ FastAPI, Redis or any other application framework. Framework-specific rules
24
+ come from extension packages (`yaddd-pydantic`, `yaddd-sqlalchemy`, …) and
25
+ from the project's own `.agents/rules/local/` directory.
26
+
27
+ ## Commands
28
+
29
+ ```bash
30
+ yaddd-agents init # create .agents/, .yaddd/ and the managed block
31
+ yaddd-agents sync # rebuild generated files from active packs
32
+ yaddd-agents check # fail when generated files are stale
33
+ yaddd-agents explain RULE_ID # show where a rule comes from
34
+ yaddd-agents list --json # machine-readable rule list
35
+ ```
36
+
37
+ Generated paths:
38
+
39
+ ```
40
+ .agents/rules/base/ # copied from yaddd-agents
41
+ .agents/rules/extensions/<pack>/ # copied from extension packages
42
+ .agents/rules/local/ # hand-written, never overwritten
43
+ .agents/manifest.lock.json # pack versions and content hashes
44
+ .yaddd/layers.json # machine config for yaddd-linter
45
+ AGENTS.md # managed block between markers
46
+ ```
47
+
48
+ ## Extension packs
49
+
50
+ An extension pack is a distribution whose module contains
51
+ `agents/manifest.toml` and `agents/rules/*.md`. `yaddd-agents` discovers it
52
+ from the project's dependencies or from an explicit mapping:
53
+
54
+ ```toml
55
+ [tool.yaddd.agents.extensions]
56
+ my-extension = "my_extension/agents/manifest.toml"
57
+ ```
58
+
59
+ No entry points or registries are used, matching the yaddd plugin contract.
@@ -0,0 +1,43 @@
1
+ # yaddd-agents
2
+
3
+ Generates and verifies the layered rule set used by AI coding agents in
4
+ projects built on `yaddd`.
5
+
6
+ The package is intentionally generic: it knows about DDD layers, not about
7
+ FastAPI, Redis or any other application framework. Framework-specific rules
8
+ come from extension packages (`yaddd-pydantic`, `yaddd-sqlalchemy`, …) and
9
+ from the project's own `.agents/rules/local/` directory.
10
+
11
+ ## Commands
12
+
13
+ ```bash
14
+ yaddd-agents init # create .agents/, .yaddd/ and the managed block
15
+ yaddd-agents sync # rebuild generated files from active packs
16
+ yaddd-agents check # fail when generated files are stale
17
+ yaddd-agents explain RULE_ID # show where a rule comes from
18
+ yaddd-agents list --json # machine-readable rule list
19
+ ```
20
+
21
+ Generated paths:
22
+
23
+ ```
24
+ .agents/rules/base/ # copied from yaddd-agents
25
+ .agents/rules/extensions/<pack>/ # copied from extension packages
26
+ .agents/rules/local/ # hand-written, never overwritten
27
+ .agents/manifest.lock.json # pack versions and content hashes
28
+ .yaddd/layers.json # machine config for yaddd-linter
29
+ AGENTS.md # managed block between markers
30
+ ```
31
+
32
+ ## Extension packs
33
+
34
+ An extension pack is a distribution whose module contains
35
+ `agents/manifest.toml` and `agents/rules/*.md`. `yaddd-agents` discovers it
36
+ from the project's dependencies or from an explicit mapping:
37
+
38
+ ```toml
39
+ [tool.yaddd.agents.extensions]
40
+ my-extension = "my_extension/agents/manifest.toml"
41
+ ```
42
+
43
+ No entry points or registries are used, matching the yaddd plugin contract.
@@ -0,0 +1,38 @@
1
+ [project]
2
+ name = "yaddd-agents"
3
+ version = "0.2.0"
4
+ description = "Generate and verify layered AGENTS.md rules for yaddd projects."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ license = { text = "MIT" }
8
+ keywords = ["ddd", "agents", "ai", "yaddd"]
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "Intended Audience :: Developers",
12
+ "Programming Language :: Python :: 3",
13
+ "Programming Language :: Python :: 3.12",
14
+ "Programming Language :: Python :: 3.13",
15
+ "Programming Language :: Python :: 3.14",
16
+ "Topic :: Software Development :: Quality Assurance",
17
+ ]
18
+ dependencies = []
19
+
20
+ [project.scripts]
21
+ yaddd-agents = "yaddd_agents.cli:main"
22
+
23
+ [build-system]
24
+ requires = ["hatchling"]
25
+ build-backend = "hatchling.build"
26
+
27
+ [tool.hatch.build.targets.wheel]
28
+ packages = ["src/yaddd_agents"]
29
+ artifacts = ["src/yaddd_agents/resources/**"]
30
+
31
+ [tool.ruff]
32
+ line-length = 120
33
+
34
+ [tool.ruff.lint]
35
+ select = ["E", "F", "I", "B", "C4"]
36
+
37
+ [tool.ty.environment]
38
+ python-version = "3.12"
@@ -0,0 +1,5 @@
1
+ """Generate and verify layered AGENTS.md rules for yaddd projects."""
2
+
3
+ __version__ = "0.2.0"
4
+
5
+ __all__ = ["__version__"]
@@ -0,0 +1,140 @@
1
+ """Command-line entry point for yaddd-agents."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ import sys
8
+ from pathlib import Path
9
+ from typing import Any
10
+
11
+ from yaddd_agents import __version__
12
+ from yaddd_agents.discover import discover_packs, load_local_operations, load_project
13
+ from yaddd_agents.model import AgentsError, Project, Resolution
14
+ from yaddd_agents.render import check_outputs, expected_outputs, write_outputs
15
+ from yaddd_agents.resolve import explain, pack_summary, resolve
16
+
17
+
18
+ def _build_parser() -> argparse.ArgumentParser:
19
+ """Build the command-line parser."""
20
+ parser = argparse.ArgumentParser(prog="yaddd-agents", description="Generate layered AGENTS.md rules.")
21
+ parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
22
+ parser.add_argument("--root", type=Path, default=None, help="Project root (default: nearest pyproject.toml).")
23
+ parser.add_argument(
24
+ "--workspace",
25
+ type=Path,
26
+ default=None,
27
+ help="Monorepo root used to discover editable extension packs.",
28
+ )
29
+ subparsers = parser.add_subparsers(dest="command", required=True)
30
+
31
+ subparsers.add_parser("init", help="Create .agents/, .yaddd/ and sync generated files.")
32
+ subparsers.add_parser("sync", help="Rebuild generated rules and configuration.")
33
+ subparsers.add_parser("check", help="Fail when generated files are stale.")
34
+
35
+ explain_parser = subparsers.add_parser("explain", help="Show where a rule comes from.")
36
+ explain_parser.add_argument("rule", help="Rule ID, for example IMPORTS_DOMAIN.")
37
+ explain_parser.add_argument("--json", action="store_true", help="Emit JSON.")
38
+
39
+ list_parser = subparsers.add_parser("list", help="List active packs and rules.")
40
+ list_parser.add_argument("--json", action="store_true", help="Emit JSON.")
41
+ return parser
42
+
43
+
44
+ def main(argv: list[str] | None = None) -> int:
45
+ """Run the CLI."""
46
+ parser = _build_parser()
47
+ args = parser.parse_args(argv)
48
+ try:
49
+ project = load_project(args.root)
50
+ workspace = args.workspace.resolve() if args.workspace is not None else None
51
+ if args.command == "init":
52
+ return _init(project, workspace)
53
+ if args.command == "sync":
54
+ return _sync(project, workspace)
55
+ if args.command == "check":
56
+ return _check(project, workspace)
57
+ resolution = _resolve(project, workspace)
58
+ if args.command == "explain":
59
+ return _explain(resolution, args.rule, args.json)
60
+ if args.command == "list":
61
+ return _list(resolution, args.json)
62
+ except AgentsError as exc:
63
+ print(f"error: {exc}", file=sys.stderr)
64
+ return 2
65
+ parser.error(f"unknown command: {args.command}")
66
+ return 2
67
+
68
+
69
+ def _resolve(project: Project, workspace: Path | None) -> Resolution:
70
+ """Discover packs and resolve every active rule."""
71
+ packs = discover_packs(project, workspace)
72
+ return resolve(project, packs, load_local_operations(project))
73
+
74
+
75
+ def _init(project: Project, workspace: Path | None) -> int:
76
+ """Create directories and sync generated content."""
77
+ project.local_rules_dir.mkdir(parents=True, exist_ok=True)
78
+ keep = project.local_rules_dir / ".gitkeep"
79
+ if not keep.exists():
80
+ keep.write_text("", encoding="utf-8")
81
+ return _sync(project, workspace)
82
+
83
+
84
+ def _sync(project: Project, workspace: Path | None) -> int:
85
+ """Render and write every generated file."""
86
+ resolution = _resolve(project, workspace)
87
+ outputs = expected_outputs(project, resolution)
88
+ write_outputs(project, outputs)
89
+ print(f"Synced {len(outputs)} files from {len(resolution.packs)} packs.")
90
+ return 0
91
+
92
+
93
+ def _check(project: Project, workspace: Path | None) -> int:
94
+ """Verify that generated files match the active packs."""
95
+ resolution = _resolve(project, workspace)
96
+ problems = check_outputs(project, expected_outputs(project, resolution))
97
+ if problems:
98
+ for problem in problems:
99
+ print(problem, file=sys.stderr)
100
+ print("Run `yaddd-agents sync` to update generated files.", file=sys.stderr)
101
+ return 1
102
+ print(f"Agent rules are up to date ({len(resolution.rules)} rules).")
103
+ return 0
104
+
105
+
106
+ def _explain(resolution: Resolution, rule_id: str, as_json: bool) -> int:
107
+ """Print one resolved rule."""
108
+ payload = explain(resolution, rule_id)
109
+ if as_json:
110
+ print(json.dumps(payload, indent=2, sort_keys=True))
111
+ return 0
112
+ print(f"{payload['id']} ({payload['layer']}, {payload['kind']})")
113
+ print(f"enabled: {'yes' if payload['enabled'] else 'no'}")
114
+ print(f"allow first-party: {', '.join(payload['effective_first_party']) or '-'}")
115
+ print(f"allow third-party: {', '.join(payload['effective_third_party']) or '-'}")
116
+ print(f"deny first-party: {', '.join(payload['deny_first_party']) or '-'}")
117
+ print(f"deny third-party: {', '.join(payload['deny_third_party']) or '-'}")
118
+ print(f"sources: {', '.join(payload['sources']) or '-'}")
119
+ print(f"docs: {', '.join(payload['docs']) or '-'}")
120
+ return 0
121
+
122
+
123
+ def _list(resolution: Resolution, as_json: bool) -> int:
124
+ """Print active packs and rules."""
125
+ payload: dict[str, Any] = {
126
+ "packs": pack_summary(resolution.packs),
127
+ "rules": {rule_id: explain(resolution, rule_id) for rule_id in sorted(resolution.rules)},
128
+ }
129
+ if as_json:
130
+ print(json.dumps(payload, indent=2, sort_keys=True))
131
+ return 0
132
+ for pack in payload["packs"]:
133
+ print(f"{pack['name']} {pack['version']}")
134
+ for rule_id in sorted(resolution.rules):
135
+ print(f" {rule_id}")
136
+ return 0
137
+
138
+
139
+ if __name__ == "__main__":
140
+ sys.exit(main())