doctrine-agents 1.0.2__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 (174) hide show
  1. doctrine_agents-1.0.2/LICENSE +21 -0
  2. doctrine_agents-1.0.2/PKG-INFO +177 -0
  3. doctrine_agents-1.0.2/README.md +158 -0
  4. doctrine_agents-1.0.2/doctrine/__init__.py +10 -0
  5. doctrine_agents-1.0.2/doctrine/_compiler/__init__.py +1 -0
  6. doctrine_agents-1.0.2/doctrine/_compiler/compile/__init__.py +29 -0
  7. doctrine_agents-1.0.2/doctrine/_compiler/compile/agent.py +615 -0
  8. doctrine_agents-1.0.2/doctrine/_compiler/compile/final_output.py +431 -0
  9. doctrine_agents-1.0.2/doctrine/_compiler/compile/outputs.py +317 -0
  10. doctrine_agents-1.0.2/doctrine/_compiler/compile/readable_blocks.py +465 -0
  11. doctrine_agents-1.0.2/doctrine/_compiler/compile/readables.py +508 -0
  12. doctrine_agents-1.0.2/doctrine/_compiler/compile/records.py +270 -0
  13. doctrine_agents-1.0.2/doctrine/_compiler/compile/review_cases.py +318 -0
  14. doctrine_agents-1.0.2/doctrine/_compiler/compile/review_contract.py +684 -0
  15. doctrine_agents-1.0.2/doctrine/_compiler/compile/reviews.py +284 -0
  16. doctrine_agents-1.0.2/doctrine/_compiler/compile/skill_package.py +226 -0
  17. doctrine_agents-1.0.2/doctrine/_compiler/compile/workflows.py +331 -0
  18. doctrine_agents-1.0.2/doctrine/_compiler/constants.py +111 -0
  19. doctrine_agents-1.0.2/doctrine/_compiler/context.py +141 -0
  20. doctrine_agents-1.0.2/doctrine/_compiler/display.py +889 -0
  21. doctrine_agents-1.0.2/doctrine/_compiler/flow.py +981 -0
  22. doctrine_agents-1.0.2/doctrine/_compiler/indexing.py +490 -0
  23. doctrine_agents-1.0.2/doctrine/_compiler/naming.py +83 -0
  24. doctrine_agents-1.0.2/doctrine/_compiler/resolve/__init__.py +39 -0
  25. doctrine_agents-1.0.2/doctrine/_compiler/resolve/addressable_skills.py +221 -0
  26. doctrine_agents-1.0.2/doctrine/_compiler/resolve/addressables.py +390 -0
  27. doctrine_agents-1.0.2/doctrine/_compiler/resolve/agent_slots.py +356 -0
  28. doctrine_agents-1.0.2/doctrine/_compiler/resolve/analysis.py +259 -0
  29. doctrine_agents-1.0.2/doctrine/_compiler/resolve/document_blocks.py +527 -0
  30. doctrine_agents-1.0.2/doctrine/_compiler/resolve/documents.py +210 -0
  31. doctrine_agents-1.0.2/doctrine/_compiler/resolve/io_contracts.py +331 -0
  32. doctrine_agents-1.0.2/doctrine/_compiler/resolve/law_paths.py +252 -0
  33. doctrine_agents-1.0.2/doctrine/_compiler/resolve/outputs.py +691 -0
  34. doctrine_agents-1.0.2/doctrine/_compiler/resolve/refs.py +459 -0
  35. doctrine_agents-1.0.2/doctrine/_compiler/resolve/reviews.py +1049 -0
  36. doctrine_agents-1.0.2/doctrine/_compiler/resolve/route_semantics.py +111 -0
  37. doctrine_agents-1.0.2/doctrine/_compiler/resolve/schemas.py +398 -0
  38. doctrine_agents-1.0.2/doctrine/_compiler/resolve/section_bodies.py +126 -0
  39. doctrine_agents-1.0.2/doctrine/_compiler/resolve/skills.py +311 -0
  40. doctrine_agents-1.0.2/doctrine/_compiler/resolve/workflows.py +648 -0
  41. doctrine_agents-1.0.2/doctrine/_compiler/resolved_types.py +623 -0
  42. doctrine_agents-1.0.2/doctrine/_compiler/session.py +201 -0
  43. doctrine_agents-1.0.2/doctrine/_compiler/support.py +49 -0
  44. doctrine_agents-1.0.2/doctrine/_compiler/support_files.py +9 -0
  45. doctrine_agents-1.0.2/doctrine/_compiler/types.py +322 -0
  46. doctrine_agents-1.0.2/doctrine/_compiler/validate/__init__.py +326 -0
  47. doctrine_agents-1.0.2/doctrine/_compiler/validate/addressable_children.py +521 -0
  48. doctrine_agents-1.0.2/doctrine/_compiler/validate/addressable_display.py +403 -0
  49. doctrine_agents-1.0.2/doctrine/_compiler/validate/agents.py +256 -0
  50. doctrine_agents-1.0.2/doctrine/_compiler/validate/contracts.py +484 -0
  51. doctrine_agents-1.0.2/doctrine/_compiler/validate/display.py +290 -0
  52. doctrine_agents-1.0.2/doctrine/_compiler/validate/law_paths.py +427 -0
  53. doctrine_agents-1.0.2/doctrine/_compiler/validate/outputs.py +493 -0
  54. doctrine_agents-1.0.2/doctrine/_compiler/validate/readables.py +91 -0
  55. doctrine_agents-1.0.2/doctrine/_compiler/validate/review_agreement.py +508 -0
  56. doctrine_agents-1.0.2/doctrine/_compiler/validate/review_branches.py +454 -0
  57. doctrine_agents-1.0.2/doctrine/_compiler/validate/review_gate_observation.py +447 -0
  58. doctrine_agents-1.0.2/doctrine/_compiler/validate/review_preflight.py +417 -0
  59. doctrine_agents-1.0.2/doctrine/_compiler/validate/review_semantics.py +520 -0
  60. doctrine_agents-1.0.2/doctrine/_compiler/validate/reviews.py +19 -0
  61. doctrine_agents-1.0.2/doctrine/_compiler/validate/route_semantics.py +13 -0
  62. doctrine_agents-1.0.2/doctrine/_compiler/validate/route_semantics_context.py +422 -0
  63. doctrine_agents-1.0.2/doctrine/_compiler/validate/route_semantics_reads.py +106 -0
  64. doctrine_agents-1.0.2/doctrine/_compiler/validate/routes.py +1208 -0
  65. doctrine_agents-1.0.2/doctrine/_compiler/validate/schema_helpers.py +149 -0
  66. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/__init__.py +1 -0
  67. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/compile_checks.py +374 -0
  68. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/emit_checks.py +410 -0
  69. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/fixtures.py +34 -0
  70. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/fixtures_authored.py +146 -0
  71. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/fixtures_common.py +29 -0
  72. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/fixtures_final_output.py +346 -0
  73. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/fixtures_flow.py +90 -0
  74. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/fixtures_reviews.py +218 -0
  75. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/flow_checks.py +11 -0
  76. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/flow_emit_checks.py +254 -0
  77. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/flow_graph_checks.py +103 -0
  78. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/flow_route_checks.py +454 -0
  79. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/parse_checks.py +67 -0
  80. doctrine_agents-1.0.2/doctrine/_diagnostic_smoke/review_checks.py +368 -0
  81. doctrine_agents-1.0.2/doctrine/_diagnostics/__init__.py +3 -0
  82. doctrine_agents-1.0.2/doctrine/_diagnostics/_message_builders_agents.py +192 -0
  83. doctrine_agents-1.0.2/doctrine/_diagnostics/_message_builders_authored.py +247 -0
  84. doctrine_agents-1.0.2/doctrine/_diagnostics/_message_builders_emit.py +175 -0
  85. doctrine_agents-1.0.2/doctrine/_diagnostics/_message_builders_readables.py +353 -0
  86. doctrine_agents-1.0.2/doctrine/_diagnostics/_message_builders_refs.py +183 -0
  87. doctrine_agents-1.0.2/doctrine/_diagnostics/_message_builders_reviews.py +446 -0
  88. doctrine_agents-1.0.2/doctrine/_diagnostics/_message_builders_workflow_law.py +393 -0
  89. doctrine_agents-1.0.2/doctrine/_diagnostics/contracts.py +56 -0
  90. doctrine_agents-1.0.2/doctrine/_diagnostics/formatting.py +113 -0
  91. doctrine_agents-1.0.2/doctrine/_diagnostics/message_builders.py +97 -0
  92. doctrine_agents-1.0.2/doctrine/_diagnostics/parse_errors.py +169 -0
  93. doctrine_agents-1.0.2/doctrine/_flow_render/__init__.py +3 -0
  94. doctrine_agents-1.0.2/doctrine/_flow_render/d2.py +310 -0
  95. doctrine_agents-1.0.2/doctrine/_flow_render/layout.py +267 -0
  96. doctrine_agents-1.0.2/doctrine/_flow_render/svg.py +52 -0
  97. doctrine_agents-1.0.2/doctrine/_model/__init__.py +14 -0
  98. doctrine_agents-1.0.2/doctrine/_model/agent.py +97 -0
  99. doctrine_agents-1.0.2/doctrine/_model/analysis.py +128 -0
  100. doctrine_agents-1.0.2/doctrine/_model/core.py +101 -0
  101. doctrine_agents-1.0.2/doctrine/_model/declarations.py +64 -0
  102. doctrine_agents-1.0.2/doctrine/_model/io.py +206 -0
  103. doctrine_agents-1.0.2/doctrine/_model/law.py +179 -0
  104. doctrine_agents-1.0.2/doctrine/_model/readable.py +176 -0
  105. doctrine_agents-1.0.2/doctrine/_model/review.py +269 -0
  106. doctrine_agents-1.0.2/doctrine/_model/schema.py +106 -0
  107. doctrine_agents-1.0.2/doctrine/_model/workflow.py +212 -0
  108. doctrine_agents-1.0.2/doctrine/_parser/__init__.py +3 -0
  109. doctrine_agents-1.0.2/doctrine/_parser/agents.py +97 -0
  110. doctrine_agents-1.0.2/doctrine/_parser/analysis_decisions.py +293 -0
  111. doctrine_agents-1.0.2/doctrine/_parser/expressions.py +102 -0
  112. doctrine_agents-1.0.2/doctrine/_parser/io.py +406 -0
  113. doctrine_agents-1.0.2/doctrine/_parser/parts.py +375 -0
  114. doctrine_agents-1.0.2/doctrine/_parser/readables.py +480 -0
  115. doctrine_agents-1.0.2/doctrine/_parser/reviews.py +470 -0
  116. doctrine_agents-1.0.2/doctrine/_parser/runtime.py +62 -0
  117. doctrine_agents-1.0.2/doctrine/_parser/skills.py +251 -0
  118. doctrine_agents-1.0.2/doctrine/_parser/transformer.py +534 -0
  119. doctrine_agents-1.0.2/doctrine/_parser/workflows.py +359 -0
  120. doctrine_agents-1.0.2/doctrine/_release_flow/__init__.py +1 -0
  121. doctrine_agents-1.0.2/doctrine/_release_flow/common.py +64 -0
  122. doctrine_agents-1.0.2/doctrine/_release_flow/models.py +112 -0
  123. doctrine_agents-1.0.2/doctrine/_release_flow/ops.py +343 -0
  124. doctrine_agents-1.0.2/doctrine/_release_flow/parsing.py +471 -0
  125. doctrine_agents-1.0.2/doctrine/_release_flow/tags.py +299 -0
  126. doctrine_agents-1.0.2/doctrine/_renderer/__init__.py +3 -0
  127. doctrine_agents-1.0.2/doctrine/_renderer/blocks.py +557 -0
  128. doctrine_agents-1.0.2/doctrine/_renderer/semantic.py +90 -0
  129. doctrine_agents-1.0.2/doctrine/_renderer/tables.py +51 -0
  130. doctrine_agents-1.0.2/doctrine/_verify_corpus/__init__.py +1 -0
  131. doctrine_agents-1.0.2/doctrine/_verify_corpus/diff.py +129 -0
  132. doctrine_agents-1.0.2/doctrine/_verify_corpus/manifest.py +283 -0
  133. doctrine_agents-1.0.2/doctrine/_verify_corpus/report.py +85 -0
  134. doctrine_agents-1.0.2/doctrine/_verify_corpus/runners.py +412 -0
  135. doctrine_agents-1.0.2/doctrine/compiler.py +238 -0
  136. doctrine_agents-1.0.2/doctrine/diagnostic_smoke.py +22 -0
  137. doctrine_agents-1.0.2/doctrine/diagnostics.py +326 -0
  138. doctrine_agents-1.0.2/doctrine/emit_common.py +395 -0
  139. doctrine_agents-1.0.2/doctrine/emit_contract.py +161 -0
  140. doctrine_agents-1.0.2/doctrine/emit_docs.py +171 -0
  141. doctrine_agents-1.0.2/doctrine/emit_flow.py +226 -0
  142. doctrine_agents-1.0.2/doctrine/emit_skill.py +125 -0
  143. doctrine_agents-1.0.2/doctrine/flow_renderer.py +48 -0
  144. doctrine_agents-1.0.2/doctrine/flow_svg.mjs +30 -0
  145. doctrine_agents-1.0.2/doctrine/grammars/doctrine.lark +828 -0
  146. doctrine_agents-1.0.2/doctrine/indenter.py +14 -0
  147. doctrine_agents-1.0.2/doctrine/model.py +237 -0
  148. doctrine_agents-1.0.2/doctrine/parser.py +127 -0
  149. doctrine_agents-1.0.2/doctrine/project_config.py +133 -0
  150. doctrine_agents-1.0.2/doctrine/release_flow.py +129 -0
  151. doctrine_agents-1.0.2/doctrine/renderer.py +25 -0
  152. doctrine_agents-1.0.2/doctrine/verify_corpus.py +47 -0
  153. doctrine_agents-1.0.2/doctrine/verify_prereqs.py +34 -0
  154. doctrine_agents-1.0.2/doctrine_agents.egg-info/PKG-INFO +177 -0
  155. doctrine_agents-1.0.2/doctrine_agents.egg-info/SOURCES.txt +172 -0
  156. doctrine_agents-1.0.2/doctrine_agents.egg-info/dependency_links.txt +1 -0
  157. doctrine_agents-1.0.2/doctrine_agents.egg-info/requires.txt +2 -0
  158. doctrine_agents-1.0.2/doctrine_agents.egg-info/top_level.txt +1 -0
  159. doctrine_agents-1.0.2/pyproject.toml +107 -0
  160. doctrine_agents-1.0.2/setup.cfg +4 -0
  161. doctrine_agents-1.0.2/tests/test_compiler_boundary.py +73 -0
  162. doctrine_agents-1.0.2/tests/test_decision_attachment.py +88 -0
  163. doctrine_agents-1.0.2/tests/test_emit_docs.py +388 -0
  164. doctrine_agents-1.0.2/tests/test_emit_flow.py +96 -0
  165. doctrine_agents-1.0.2/tests/test_emit_skill.py +130 -0
  166. doctrine_agents-1.0.2/tests/test_final_output.py +1609 -0
  167. doctrine_agents-1.0.2/tests/test_import_loading.py +90 -0
  168. doctrine_agents-1.0.2/tests/test_parse_diagnostics.py +524 -0
  169. doctrine_agents-1.0.2/tests/test_project_config.py +182 -0
  170. doctrine_agents-1.0.2/tests/test_release_flow.py +670 -0
  171. doctrine_agents-1.0.2/tests/test_review_imported_outputs.py +265 -0
  172. doctrine_agents-1.0.2/tests/test_route_output_semantics.py +577 -0
  173. doctrine_agents-1.0.2/tests/test_verify_corpus.py +169 -0
  174. doctrine_agents-1.0.2/tests/test_verify_prereqs.py +47 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aelaguiz
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,177 @@
1
+ Metadata-Version: 2.4
2
+ Name: doctrine-agents
3
+ Version: 1.0.2
4
+ Summary: Typed DSL and compiler for reusable AI agent instructions and workflows that compile to AGENTS.md.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/aelaguiz/doctrine
7
+ Project-URL: Documentation, https://github.com/aelaguiz/doctrine/tree/main/docs
8
+ Project-URL: Repository, https://github.com/aelaguiz/doctrine
9
+ Project-URL: Issues, https://github.com/aelaguiz/doctrine/issues
10
+ Project-URL: Changelog, https://github.com/aelaguiz/doctrine/blob/main/CHANGELOG.md
11
+ Project-URL: Discussions, https://github.com/aelaguiz/doctrine/discussions
12
+ Project-URL: Security, https://github.com/aelaguiz/doctrine/security/policy
13
+ Requires-Python: >=3.14
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: interegular<1,>=0.3
17
+ Requires-Dist: lark<2,>=1.2
18
+ Dynamic: license-file
19
+
20
+ # Doctrine
21
+
22
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
23
+ [![Python 3.14%2B](https://img.shields.io/badge/python-3.14%2B-3776AB.svg)](pyproject.toml)
24
+ [![CI](https://img.shields.io/github/actions/workflow/status/aelaguiz/doctrine/ci.yml?branch=main&label=ci)](https://github.com/aelaguiz/doctrine/actions/workflows/ci.yml)
25
+ [![PyPI](https://img.shields.io/pypi/v/doctrine-agents.svg)](https://pypi.org/project/doctrine-agents/)
26
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/aelaguiz/doctrine/badge)](https://scorecard.dev/viewer/?uri=github.com/aelaguiz/doctrine)
27
+ [![Output: AGENTS.md](https://img.shields.io/badge/output-AGENTS.md-6E56CF.svg)](https://github.com/aelaguiz/doctrine)
28
+
29
+ [Docs](docs/README.md) · [Versioning](docs/VERSIONING.md) · [Changelog](CHANGELOG.md) · [Rally](https://github.com/aelaguiz/rally) · [VS Code extension](editors/vscode/README.md)
30
+
31
+ Write agent flows as code. Compile them to `AGENTS.md`.
32
+
33
+ Doctrine is a typed DSL and compiler for reusable agent instructions, workflows, reviews, skills, and I/O contracts. Instead of hand-editing giant `AGENTS.md` files, you author small `.prompt` files and compile deterministic runtime artifacts that current coding-agent tools can already read today.
34
+
35
+ <p align="center">
36
+ <img src="docs/assets/readme-doctrine-agent-example.png" alt="Side-by-side view of Doctrine source on the left and compiled AGENTS.md output on the right." width="1200">
37
+ </p>
38
+
39
+ Why teams reach for Doctrine:
40
+
41
+ - one shared rule changes once
42
+ - compile-time failures catch drift before runtime
43
+ - humans can review source and emitted runtime side by side
44
+ - flow diagrams, verification, and editor support ship today
45
+
46
+ ## Doctrine and Rally
47
+
48
+ - Use Doctrine when you want to author and validate the flow.
49
+ - Use Rally when you want to run that flow with repo-local state, resumability, and strict turn routing.
50
+ - The split is deliberate: Doctrine is the authoring layer, Rally is the runtime layer.
51
+
52
+ ## Why Doctrine exists
53
+
54
+ Serious agent systems drift fast when the source of truth is copied Markdown:
55
+
56
+ - shared sections get duplicated and then edited out of sync
57
+ - one policy fix turns into search-and-hope edits
58
+ - large prompt trees become hard to review
59
+ - runtime Markdown is the delivery format, not the right authoring surface
60
+
61
+ Doctrine turns that into a language and compiler problem.
62
+
63
+ ## Quick example
64
+
65
+ ```prompt
66
+ workflow SharedTurn: "How To Take A Turn"
67
+ "Read the current brief before you act."
68
+ "Leave one honest handoff and stop."
69
+
70
+ skill RepoSearchSkill: "repo-search"
71
+ purpose: "Find the right repo surface for the current job."
72
+
73
+ abstract agent ReviewRole:
74
+ read_first: SharedTurn
75
+
76
+ agent BriefReviewer[ReviewRole]:
77
+ role: "Core job: review the current brief and route the same issue honestly."
78
+
79
+ inherit read_first
80
+
81
+ skills: "Skills"
82
+ can_run: "Can Run"
83
+ skill search: RepoSearchSkill
84
+ requirement: Advisory
85
+ ```
86
+
87
+ That compiles to runtime Markdown:
88
+
89
+ ```md
90
+ Core job: review the current brief and route the same issue honestly.
91
+
92
+ ## How To Take A Turn
93
+
94
+ Read the current brief before you act.
95
+ Leave one honest handoff and stop.
96
+
97
+ ## Skills
98
+
99
+ ### Can Run
100
+
101
+ #### repo-search
102
+ ```
103
+
104
+ ## Quickstart
105
+
106
+ Source checkout is still the full setup path for contributor proof, the
107
+ example corpus, and `emit_flow`.
108
+
109
+ When Doctrine is installed from a package index, the distribution name is
110
+ `doctrine-agents`. The Python module name stays `doctrine`.
111
+
112
+ Want the packaged compiler instead of a source checkout?
113
+
114
+ ```bash
115
+ python -m pip install doctrine-agents
116
+ ```
117
+
118
+ ```bash
119
+ git clone https://github.com/aelaguiz/doctrine.git
120
+ cd doctrine
121
+ uv sync
122
+ npm ci
123
+ make check
124
+ ```
125
+
126
+ Want a smaller first proof?
127
+
128
+ ```bash
129
+ uv run --locked python -m doctrine.verify_corpus --manifest examples/01_hello_world/cases.toml
130
+ ```
131
+
132
+ Want generated output right away?
133
+
134
+ ```bash
135
+ uv run --locked python -m doctrine.emit_docs --target example_07_handoffs
136
+ uv run --locked python -m doctrine.emit_flow --target example_73_flow_visualizer_showcase
137
+ ```
138
+
139
+ ## What ships today
140
+
141
+ - concrete and abstract `agent` declarations
142
+ - reusable and inherited `workflow` declarations
143
+ - first-class `review` and `abstract review` declarations
144
+ - typed `skills`, `inputs`, `outputs`, and JSON-schema-backed contracts
145
+ - imports, readable refs, interpolation, enums, and workflow law
146
+ - `emit_docs`, `emit_flow`, and `emit_skill`
147
+ - manifest-backed verification through `examples/106_review_split_final_output_json_schema_partial`
148
+ - a repo-local VS Code extension for `.prompt` files
149
+
150
+ ## Workflow visualizer
151
+
152
+ <p align="center">
153
+ <img src="examples/73_flow_visualizer_showcase/build_ref/AGENTS.flow.svg" alt="Generated Doctrine workflow diagram showing shared inputs, a route-first handoff lane, and compiler-owned flow output." width="1200">
154
+ </p>
155
+
156
+ The checked-in showcase above comes from `examples/73_flow_visualizer_showcase`. It proves that Doctrine can emit human-readable runtime docs and compiler-owned flow diagrams from the same source graph.
157
+
158
+ ## Read next
159
+
160
+ - [docs/README.md](docs/README.md)
161
+ - [docs/VERSIONING.md](docs/VERSIONING.md)
162
+ - [CHANGELOG.md](CHANGELOG.md)
163
+ - [docs/WHY_DOCTRINE.md](docs/WHY_DOCTRINE.md)
164
+ - [docs/LANGUAGE_REFERENCE.md](docs/LANGUAGE_REFERENCE.md)
165
+ - [docs/EMIT_GUIDE.md](docs/EMIT_GUIDE.md)
166
+ - [examples/README.md](examples/README.md)
167
+ - [editors/vscode/README.md](editors/vscode/README.md)
168
+ - [CONTRIBUTING.md](CONTRIBUTING.md)
169
+
170
+ ## Questions and contributions
171
+
172
+ - Use [Discussions](https://github.com/aelaguiz/doctrine/discussions) for questions and design talk.
173
+ - Use [Issues](https://github.com/aelaguiz/doctrine/issues) for clear bugs or scoped proposals.
174
+ - See [CONTRIBUTING.md](CONTRIBUTING.md) for setup and proof commands.
175
+ - See [SUPPORT.md](SUPPORT.md) for help paths, [SECURITY.md](SECURITY.md) for private vulnerability reports, and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for collaboration rules.
176
+
177
+ If this direction is useful, star the repo and watch releases.
@@ -0,0 +1,158 @@
1
+ # Doctrine
2
+
3
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4
+ [![Python 3.14%2B](https://img.shields.io/badge/python-3.14%2B-3776AB.svg)](pyproject.toml)
5
+ [![CI](https://img.shields.io/github/actions/workflow/status/aelaguiz/doctrine/ci.yml?branch=main&label=ci)](https://github.com/aelaguiz/doctrine/actions/workflows/ci.yml)
6
+ [![PyPI](https://img.shields.io/pypi/v/doctrine-agents.svg)](https://pypi.org/project/doctrine-agents/)
7
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/aelaguiz/doctrine/badge)](https://scorecard.dev/viewer/?uri=github.com/aelaguiz/doctrine)
8
+ [![Output: AGENTS.md](https://img.shields.io/badge/output-AGENTS.md-6E56CF.svg)](https://github.com/aelaguiz/doctrine)
9
+
10
+ [Docs](docs/README.md) · [Versioning](docs/VERSIONING.md) · [Changelog](CHANGELOG.md) · [Rally](https://github.com/aelaguiz/rally) · [VS Code extension](editors/vscode/README.md)
11
+
12
+ Write agent flows as code. Compile them to `AGENTS.md`.
13
+
14
+ Doctrine is a typed DSL and compiler for reusable agent instructions, workflows, reviews, skills, and I/O contracts. Instead of hand-editing giant `AGENTS.md` files, you author small `.prompt` files and compile deterministic runtime artifacts that current coding-agent tools can already read today.
15
+
16
+ <p align="center">
17
+ <img src="docs/assets/readme-doctrine-agent-example.png" alt="Side-by-side view of Doctrine source on the left and compiled AGENTS.md output on the right." width="1200">
18
+ </p>
19
+
20
+ Why teams reach for Doctrine:
21
+
22
+ - one shared rule changes once
23
+ - compile-time failures catch drift before runtime
24
+ - humans can review source and emitted runtime side by side
25
+ - flow diagrams, verification, and editor support ship today
26
+
27
+ ## Doctrine and Rally
28
+
29
+ - Use Doctrine when you want to author and validate the flow.
30
+ - Use Rally when you want to run that flow with repo-local state, resumability, and strict turn routing.
31
+ - The split is deliberate: Doctrine is the authoring layer, Rally is the runtime layer.
32
+
33
+ ## Why Doctrine exists
34
+
35
+ Serious agent systems drift fast when the source of truth is copied Markdown:
36
+
37
+ - shared sections get duplicated and then edited out of sync
38
+ - one policy fix turns into search-and-hope edits
39
+ - large prompt trees become hard to review
40
+ - runtime Markdown is the delivery format, not the right authoring surface
41
+
42
+ Doctrine turns that into a language and compiler problem.
43
+
44
+ ## Quick example
45
+
46
+ ```prompt
47
+ workflow SharedTurn: "How To Take A Turn"
48
+ "Read the current brief before you act."
49
+ "Leave one honest handoff and stop."
50
+
51
+ skill RepoSearchSkill: "repo-search"
52
+ purpose: "Find the right repo surface for the current job."
53
+
54
+ abstract agent ReviewRole:
55
+ read_first: SharedTurn
56
+
57
+ agent BriefReviewer[ReviewRole]:
58
+ role: "Core job: review the current brief and route the same issue honestly."
59
+
60
+ inherit read_first
61
+
62
+ skills: "Skills"
63
+ can_run: "Can Run"
64
+ skill search: RepoSearchSkill
65
+ requirement: Advisory
66
+ ```
67
+
68
+ That compiles to runtime Markdown:
69
+
70
+ ```md
71
+ Core job: review the current brief and route the same issue honestly.
72
+
73
+ ## How To Take A Turn
74
+
75
+ Read the current brief before you act.
76
+ Leave one honest handoff and stop.
77
+
78
+ ## Skills
79
+
80
+ ### Can Run
81
+
82
+ #### repo-search
83
+ ```
84
+
85
+ ## Quickstart
86
+
87
+ Source checkout is still the full setup path for contributor proof, the
88
+ example corpus, and `emit_flow`.
89
+
90
+ When Doctrine is installed from a package index, the distribution name is
91
+ `doctrine-agents`. The Python module name stays `doctrine`.
92
+
93
+ Want the packaged compiler instead of a source checkout?
94
+
95
+ ```bash
96
+ python -m pip install doctrine-agents
97
+ ```
98
+
99
+ ```bash
100
+ git clone https://github.com/aelaguiz/doctrine.git
101
+ cd doctrine
102
+ uv sync
103
+ npm ci
104
+ make check
105
+ ```
106
+
107
+ Want a smaller first proof?
108
+
109
+ ```bash
110
+ uv run --locked python -m doctrine.verify_corpus --manifest examples/01_hello_world/cases.toml
111
+ ```
112
+
113
+ Want generated output right away?
114
+
115
+ ```bash
116
+ uv run --locked python -m doctrine.emit_docs --target example_07_handoffs
117
+ uv run --locked python -m doctrine.emit_flow --target example_73_flow_visualizer_showcase
118
+ ```
119
+
120
+ ## What ships today
121
+
122
+ - concrete and abstract `agent` declarations
123
+ - reusable and inherited `workflow` declarations
124
+ - first-class `review` and `abstract review` declarations
125
+ - typed `skills`, `inputs`, `outputs`, and JSON-schema-backed contracts
126
+ - imports, readable refs, interpolation, enums, and workflow law
127
+ - `emit_docs`, `emit_flow`, and `emit_skill`
128
+ - manifest-backed verification through `examples/106_review_split_final_output_json_schema_partial`
129
+ - a repo-local VS Code extension for `.prompt` files
130
+
131
+ ## Workflow visualizer
132
+
133
+ <p align="center">
134
+ <img src="examples/73_flow_visualizer_showcase/build_ref/AGENTS.flow.svg" alt="Generated Doctrine workflow diagram showing shared inputs, a route-first handoff lane, and compiler-owned flow output." width="1200">
135
+ </p>
136
+
137
+ The checked-in showcase above comes from `examples/73_flow_visualizer_showcase`. It proves that Doctrine can emit human-readable runtime docs and compiler-owned flow diagrams from the same source graph.
138
+
139
+ ## Read next
140
+
141
+ - [docs/README.md](docs/README.md)
142
+ - [docs/VERSIONING.md](docs/VERSIONING.md)
143
+ - [CHANGELOG.md](CHANGELOG.md)
144
+ - [docs/WHY_DOCTRINE.md](docs/WHY_DOCTRINE.md)
145
+ - [docs/LANGUAGE_REFERENCE.md](docs/LANGUAGE_REFERENCE.md)
146
+ - [docs/EMIT_GUIDE.md](docs/EMIT_GUIDE.md)
147
+ - [examples/README.md](examples/README.md)
148
+ - [editors/vscode/README.md](editors/vscode/README.md)
149
+ - [CONTRIBUTING.md](CONTRIBUTING.md)
150
+
151
+ ## Questions and contributions
152
+
153
+ - Use [Discussions](https://github.com/aelaguiz/doctrine/discussions) for questions and design talk.
154
+ - Use [Issues](https://github.com/aelaguiz/doctrine/issues) for clear bugs or scoped proposals.
155
+ - See [CONTRIBUTING.md](CONTRIBUTING.md) for setup and proof commands.
156
+ - See [SUPPORT.md](SUPPORT.md) for help paths, [SECURITY.md](SECURITY.md) for private vulnerability reports, and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for collaboration rules.
157
+
158
+ If this direction is useful, star the repo and watch releases.
@@ -0,0 +1,10 @@
1
+ """Doctrine language bootstrap package."""
2
+
3
+ from doctrine.diagnostics import CompileError, EmitError, ParseError, DoctrineError
4
+
5
+ __all__ = [
6
+ "CompileError",
7
+ "EmitError",
8
+ "ParseError",
9
+ "DoctrineError",
10
+ ]
@@ -0,0 +1 @@
1
+ """Internal compiler package; top-level operator imports should stay on doctrine.compiler."""
@@ -0,0 +1,29 @@
1
+ from __future__ import annotations
2
+
3
+ from doctrine._compiler.compile.agent import CompileAgentMixin
4
+ from doctrine._compiler.compile.final_output import CompileFinalOutputMixin
5
+ from doctrine._compiler.compile.outputs import CompileOutputsMixin
6
+ from doctrine._compiler.compile.readable_blocks import CompileReadableBlocksMixin
7
+ from doctrine._compiler.compile.readables import CompileReadablesMixin
8
+ from doctrine._compiler.compile.records import CompileRecordsMixin
9
+ from doctrine._compiler.compile.review_cases import CompileReviewCasesMixin
10
+ from doctrine._compiler.compile.review_contract import CompileReviewContractMixin
11
+ from doctrine._compiler.compile.reviews import CompileReviewsMixin
12
+ from doctrine._compiler.compile.skill_package import CompileSkillPackageMixin
13
+ from doctrine._compiler.compile.workflows import CompileWorkflowsMixin
14
+
15
+
16
+ class CompileMixin(
17
+ CompileWorkflowsMixin,
18
+ CompileReviewCasesMixin,
19
+ CompileReviewContractMixin,
20
+ CompileReviewsMixin,
21
+ CompileRecordsMixin,
22
+ CompileOutputsMixin,
23
+ CompileReadableBlocksMixin,
24
+ CompileAgentMixin,
25
+ CompileReadablesMixin,
26
+ CompileFinalOutputMixin,
27
+ CompileSkillPackageMixin,
28
+ ):
29
+ """Compile helper boundary for CompilationContext."""