instruction.md 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.
Files changed (101) hide show
  1. instruction_md-0.2.0/LICENSE-APACHE +202 -0
  2. instruction_md-0.2.0/LICENSE-MIT +21 -0
  3. instruction_md-0.2.0/MANIFEST.in +3 -0
  4. instruction_md-0.2.0/NOTICE +28 -0
  5. instruction_md-0.2.0/PKG-INFO +200 -0
  6. instruction_md-0.2.0/README.md +160 -0
  7. instruction_md-0.2.0/conformance/README.md +17 -0
  8. instruction_md-0.2.0/conformance/specification/conformance/LICENSE +202 -0
  9. instruction_md-0.2.0/conformance/specification/conformance/model-cases.json +3004 -0
  10. instruction_md-0.2.0/conformance/specification/conformance/resolution-cases.json +504 -0
  11. instruction_md-0.2.0/conformance/specification/conformance/source-cases.json +202 -0
  12. instruction_md-0.2.0/conformance/specification/conformance/text/all-tabs.json +41 -0
  13. instruction_md-0.2.0/conformance/specification/conformance/text/all-tabs.txt +9 -0
  14. instruction_md-0.2.0/conformance/specification/conformance/text/labelled-example.json +19 -0
  15. instruction_md-0.2.0/conformance/specification/conformance/text/labelled-example.txt +5 -0
  16. instruction_md-0.2.0/conformance/specification/conformance/text/literal-blank-lines.json +19 -0
  17. instruction_md-0.2.0/conformance/specification/conformance/text/literal-blank-lines.txt +8 -0
  18. instruction_md-0.2.0/conformance/specification/conformance/text/reason.json +20 -0
  19. instruction_md-0.2.0/conformance/specification/conformance/text/reason.txt +2 -0
  20. instruction_md-0.2.0/conformance/specification/conformance/text/rule.json +19 -0
  21. instruction_md-0.2.0/conformance/specification/conformance/text/rule.txt +1 -0
  22. instruction_md-0.2.0/conformance/specification/conformance/workflow-cases.json +1497 -0
  23. instruction_md-0.2.0/conformance/specification/instruction.schema.json +7728 -0
  24. instruction_md-0.2.0/conformance/specification/samples/agentd-assistant/guidance.md +8 -0
  25. instruction_md-0.2.0/conformance/specification/samples/agentd-assistant/instruction.md +110 -0
  26. instruction_md-0.2.0/conformance/specification/samples/agentd-assistant/skills/prioritize/SKILL.md +8 -0
  27. instruction_md-0.2.0/conformance/specification/samples/morning-assistant/base.md +18 -0
  28. instruction_md-0.2.0/conformance/specification/samples/morning-assistant/instruction.md +193 -0
  29. instruction_md-0.2.0/conformance/specification/samples/morning-assistant/skills/prioritize/SKILL.md +10 -0
  30. instruction_md-0.2.0/conformance/specification/samples/morning-assistant/team.md +14 -0
  31. instruction_md-0.2.0/conformance/specification/samples/self-contained.md +19 -0
  32. instruction_md-0.2.0/conformance/specification/samples/workflows/instruction.md +191 -0
  33. instruction_md-0.2.0/conformance/specification/schemas/bundle.schema.json +259 -0
  34. instruction_md-0.2.0/conformance/specification/schemas/extension.schema.json +229 -0
  35. instruction_md-0.2.0/conformance/specification/schemas/resolved.schema.json +565 -0
  36. instruction_md-0.2.0/conformance/specification/schemas/testing.schema.json +298 -0
  37. instruction_md-0.2.0/conformance/vectors/LICENSE +21 -0
  38. instruction_md-0.2.0/conformance/vectors/README.md +22 -0
  39. instruction_md-0.2.0/conformance/vectors/inline/cases.json +576 -0
  40. instruction_md-0.2.0/conformance/vectors/read/alerts.json +84 -0
  41. instruction_md-0.2.0/conformance/vectors/read/all-elements.json +2428 -0
  42. instruction_md-0.2.0/conformance/vectors/read/attributes.json +117 -0
  43. instruction_md-0.2.0/conformance/vectors/read/composition.json +128 -0
  44. instruction_md-0.2.0/conformance/vectors/read/directive-errors.json +169 -0
  45. instruction_md-0.2.0/conformance/vectors/read/directives.json +217 -0
  46. instruction_md-0.2.0/conformance/vectors/read/inline.json +96 -0
  47. instruction_md-0.2.0/conformance/vectors/read/keywords.json +173 -0
  48. instruction_md-0.2.0/conformance/vectors/read/markdown.json +24 -0
  49. instruction_md-0.2.0/conformance/vectors/read/metadata-errors.json +55 -0
  50. instruction_md-0.2.0/conformance/vectors/read/metadata.json +116 -0
  51. instruction_md-0.2.0/conformance/vectors/read/reasons.json +103 -0
  52. instruction_md-0.2.0/conformance/vectors/read/sample-agentd-assistant.json +363 -0
  53. instruction_md-0.2.0/conformance/vectors/read/sample-agentd-skill.json +27 -0
  54. instruction_md-0.2.0/conformance/vectors/read/sample-morning-assistant.json +931 -0
  55. instruction_md-0.2.0/conformance/vectors/read/sample-morning-base.json +149 -0
  56. instruction_md-0.2.0/conformance/vectors/read/sample-morning-team.json +92 -0
  57. instruction_md-0.2.0/conformance/vectors/read/sample-self-contained.json +94 -0
  58. instruction_md-0.2.0/conformance/vectors/read/sample-workflows.json +383 -0
  59. instruction_md-0.2.0/conformance/vectors/read/thematic-break.json +28 -0
  60. instruction_md-0.2.0/conformance/vectors/resolve/composition.json +332 -0
  61. instruction_md-0.2.0/conformance/vectors/resolve/missing-base.json +125 -0
  62. instruction_md-0.2.0/conformance/vectors/resolve/morning-assistant.json +1103 -0
  63. instruction_md-0.2.0/conformance/vectors/resolve/parameters-missing.json +52 -0
  64. instruction_md-0.2.0/conformance/vectors/resolve/parameters.json +66 -0
  65. instruction_md-0.2.0/conformance/vectors/resolve/pins.json +46 -0
  66. instruction_md-0.2.0/conformance/vectors/workflow/cases.json +454 -0
  67. instruction_md-0.2.0/instruction.md.egg-info/PKG-INFO +200 -0
  68. instruction_md-0.2.0/instruction.md.egg-info/SOURCES.txt +99 -0
  69. instruction_md-0.2.0/instruction.md.egg-info/dependency_links.txt +1 -0
  70. instruction_md-0.2.0/instruction.md.egg-info/requires.txt +12 -0
  71. instruction_md-0.2.0/instruction.md.egg-info/top_level.txt +1 -0
  72. instruction_md-0.2.0/instruction_md/__init__.py +56 -0
  73. instruction_md-0.2.0/instruction_md/__main__.py +195 -0
  74. instruction_md-0.2.0/instruction_md/_js.py +170 -0
  75. instruction_md-0.2.0/instruction_md/_micromark.py +3234 -0
  76. instruction_md-0.2.0/instruction_md/_yaml.py +432 -0
  77. instruction_md-0.2.0/instruction_md/attributes.py +193 -0
  78. instruction_md-0.2.0/instruction_md/check.py +145 -0
  79. instruction_md-0.2.0/instruction_md/consumer.py +494 -0
  80. instruction_md-0.2.0/instruction_md/digest.py +34 -0
  81. instruction_md-0.2.0/instruction_md/format.py +51 -0
  82. instruction_md-0.2.0/instruction_md/inline.py +486 -0
  83. instruction_md-0.2.0/instruction_md/jcs.py +28 -0
  84. instruction_md-0.2.0/instruction_md/mcp_auth.py +55 -0
  85. instruction_md-0.2.0/instruction_md/py.typed +0 -0
  86. instruction_md-0.2.0/instruction_md/read.py +942 -0
  87. instruction_md-0.2.0/instruction_md/registry.json +1603 -0
  88. instruction_md-0.2.0/instruction_md/registry.py +116 -0
  89. instruction_md-0.2.0/instruction_md/resolve.py +864 -0
  90. instruction_md-0.2.0/instruction_md/text.py +268 -0
  91. instruction_md-0.2.0/instruction_md/types.py +219 -0
  92. instruction_md-0.2.0/instruction_md/verify.py +195 -0
  93. instruction_md-0.2.0/instruction_md/workflow-registry.json +1028 -0
  94. instruction_md-0.2.0/instruction_md/workflow.py +325 -0
  95. instruction_md-0.2.0/pyproject.toml +60 -0
  96. instruction_md-0.2.0/setup.cfg +4 -0
  97. instruction_md-0.2.0/tests/test_conformance.py +228 -0
  98. instruction_md-0.2.0/tests/test_mcp_auth.py +39 -0
  99. instruction_md-0.2.0/tests/test_units.py +278 -0
  100. instruction_md-0.2.0/tests/test_verify_and_follow.py +217 -0
  101. instruction_md-0.2.0/tests/test_workflow.py +65 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TSOK Inc.
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,3 @@
1
+ # The source distribution runs its own tests: they read only the vendored conformance data (conformance/README.md),
2
+ # which carries its own licences. The wheel holds the package alone (pyproject.toml's package data).
3
+ graft conformance
@@ -0,0 +1,28 @@
1
+ instruction.md (Python)
2
+ Copyright (c) 2026 TSOK Inc.
3
+
4
+ This package (sdks/python) is licensed under either of the MIT licence
5
+ (LICENSE-MIT) or the Apache License, Version 2.0 (LICENSE-APACHE), at your
6
+ option. That is the package's own licence: the rest of the repository it is
7
+ built from keeps its own (the Business Source License 1.1), and does not
8
+ apply to this package.
9
+
10
+ The package additionally redistributes material from the Instruction
11
+ Specification, under a different licence:
12
+
13
+ The instruction.md specification's registries
14
+ (`instruction_md/registry.json` and `instruction_md/workflow-registry.json`,
15
+ verbatim)
16
+ Source: https://github.com/instruction-md/specification
17
+ Licence: Creative Commons Attribution 4.0 International (CC BY 4.0)
18
+ https://creativecommons.org/licenses/by/4.0/
19
+ Author: instruction.md (TSOK Inc.)
20
+ Changes: none; redistributed verbatim.
21
+
22
+ The source distribution also carries the data its tests read (`conformance/`,
23
+ listed in `conformance/README.md`): the specification's conformance cases
24
+ (Apache License 2.0, `conformance/specification/conformance/LICENSE`), its
25
+ schemas and samples (CC BY 4.0, as above, verbatim), and the TypeScript
26
+ reference implementation's vectors (MIT, `conformance/vectors/LICENSE`).
27
+
28
+ CC BY 4.0 requires attribution, and attribution has to arrive with the copy.
@@ -0,0 +1,200 @@
1
+ Metadata-Version: 2.4
2
+ Name: instruction.md
3
+ Version: 0.2.0
4
+ Summary: Read, check, resolve and verify instruction.md files (the specification's first edition, instruction/1), and follow them from a registry
5
+ Author: TSOK Inc.
6
+ License-Expression: MIT OR Apache-2.0
7
+ Project-URL: Homepage, https://instruction.md
8
+ Project-URL: Documentation, https://instruction.md/docs/
9
+ Project-URL: Specification, https://instruction.md/specification/
10
+ Project-URL: Issues, https://github.com/instruction-md/specification/issues
11
+ Keywords: instruction.md,agents,mcp,markdown
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.9
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE-MIT
28
+ License-File: LICENSE-APACHE
29
+ License-File: NOTICE
30
+ Requires-Dist: PyYAML>=6.0
31
+ Provides-Extra: sign
32
+ Requires-Dist: cryptography>=38; extra == "sign"
33
+ Provides-Extra: mcp
34
+ Requires-Dist: mcp>=2.3; extra == "mcp"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=8; extra == "dev"
37
+ Requires-Dist: cryptography>=38; extra == "dev"
38
+ Requires-Dist: jsonschema>=4.20; extra == "dev"
39
+ Dynamic: license-file
40
+
41
+ # instruction.md (Python)
42
+
43
+ The [instruction.md](https://instruction.md) specification's [first edition](https://instruction.md/specification/)
44
+ (`instruction/1`) in Python: the reader and its checks, the inline syntax, resolution and the agent's text profile,
45
+ the registry, the formatter, digests and signature verification — and a follower for instructions served over MCP. It
46
+ is a port of the TypeScript reference, `instruction.md` on npm, byte-exact with its vectors and with the
47
+ specification's conformance data.
48
+
49
+ ```sh
50
+ pip install instruction.md # Python 3.9 or later; PyYAML is its one dependency
51
+ pip install 'instruction.md[sign]' # signature verification (cryptography)
52
+ pip install 'instruction.md[mcp]' # following over MCP (the official mcp SDK 2.3 or later, Python 3.10 or later)
53
+ ```
54
+
55
+ ```python
56
+ from instruction_md import check, digest, read, resolve
57
+
58
+ text = """---
59
+ spec: "1"
60
+ title: House style
61
+ parameters:
62
+ audience: { type: string, default: developers }
63
+ ---
64
+
65
+ # House style
66
+
67
+ You write for ${audience}.
68
+
69
+ MUST: write in the second person.
70
+ BECAUSE: the reader is the one acting.
71
+
72
+ NEVER: promise a date you cannot keep.
73
+ """
74
+
75
+ r = read(text)
76
+ print(r.document.to_json()["format"]) # instruction/1: the authored tree, as the schema has it
77
+ print(check(r)) # []: no diagnostics
78
+ res = resolve(text, uri="house-style.md", params={"audience": "support engineers"})
79
+ print(res.ok) # True
80
+ print(res.text, end="") # what the agent receives (instruction-text/1)
81
+ print(digest(text)) # sha256:… of the stored bytes
82
+ ```
83
+
84
+ prints
85
+
86
+ ```text
87
+ instruction/1
88
+ []
89
+ True
90
+ # House style
91
+
92
+ You write for support engineers.
93
+
94
+ MUST: write in the second person.
95
+ BECAUSE: the reader is the one acting.
96
+
97
+ NEVER: promise a date you cannot keep.
98
+ sha256:20f4f08abec3d38ca9b2324884e1063fd1b0eb1751da2a5c08b29945b775ae84
99
+ ```
100
+
101
+ - `read(text, fragment=False, uri=None)` → `ReadResult`: `document`, `diagnostics`, `identities`, `parameters`,
102
+ `footnotes`, and which Markdown nodes are prose, which keyword a rule was written with, where its reason was.
103
+ Nodes are `MarkdownNode` and `DirectiveNode` (`to_json()` gives the reference's JSON: `{format: "instruction/1",
104
+ metadata: {front, back}, body: [...]}`); a structured body is a `StructuredValue` with its `source` and, parsed,
105
+ its `data`. Metadata and structured bodies are YAML 1.2's Core Schema restricted to JSON: no anchors, aliases,
106
+ custom tags, non-string keys, non-finite numbers or second document, duplicate keys refused.
107
+ - `check(text | ReadResult)` → `list[Diagnostic]`, the reader's diagnostics (§18) with the inline checks, in source
108
+ order: `code`, `severity`, `message`, `range` (and `uri` for another source's).
109
+ - `inline_tokens(source)` → the inline forms — `:kind[label]{attrs}`, `[[target|label]]`, `![[…]]`, `[^note]`,
110
+ `$math$`, `${parameter}` — read where CommonMark reads text: never in code, raw HTML, an autolink, a link
111
+ destination or title, or a definition (the tokenizer is a port of micromark's, with GFM's tables, task list items
112
+ and autolink literals).
113
+ - `resolve(text, uri=, version=, params=, load=)` composes bases (`extends`) with their patches, includes as separate
114
+ instances, pins and parameters; `load` is a callable (`uri → Source | str | None`) or a mapping of resolved URIs to
115
+ sources, and nothing is ever fetched. `res.text` is the agent text, `res.resolved.to_json()` the resolved artifact
116
+ (`instruction-resolved/1`, its `resolved_digest` in RFC 8785 form). `resolve_with(text, sources)` takes the sources
117
+ already loaded, `resolve_tree(tree, trees)` authored trees (as `AuthoredDocument` or JSON).
118
+ - `to_text(tree, params=, parameters=, prose=, identities=, known=)` → the text profile of any tree, authored or
119
+ resolved; `canonical_json` / `json_digest` → RFC 8785; `format(text)` → the conservative formatter; `digest(text)`
120
+ → `sha256:` of the stored bytes, nothing stripped; the registry → `KINDS`, `INLINE`, `KEYWORDS`, `PATTERNS`, …
121
+ (the specification's `registry.json`, shipped with the package).
122
+ - The workflow registry (`workflow-registry.json`, shipped with the package): `WORKFLOW_KINDS`,
123
+ `WORKFLOW_COMMON_FIELDS`, `WORKFLOW_LIMITS`; `WORKFLOW_SCOPES`, the kinds whose `body` or `branches` hold nested steps
124
+ (foreach, batch, iterate, subgraph; parallel, race), from reference/workflows.md, since the registry doesn't say:
125
+ another kind's field of that name (an `http` request's `body`) is data. The reader checks each `:::workflow{dialect="instruction/workflow"}` body
126
+ against it (unknown kinds and fields, required fields, triggers, dependencies, routes, cycles, scopes and limits:
127
+ `invalid-workflow`, `limit-exceeded`, `extension-unavailable`); `workflow_diagnostics(definition)` checks a
128
+ definition on its own.
129
+
130
+ Offsets (an inline token's, a range's lines) index the Python string, by code point.
131
+
132
+ ## Signatures
133
+
134
+ With the `sign` extra, `verify_author(jws, text, keys, doc=, pub=)` checks an author signature over the stored bytes;
135
+ `verify_delivery(jws, delivered, delivery_keys, author_keys, aud=, authored_text=, pub=)` a delivery signature over
136
+ what one reader received, with the author signature it embeds. A delivery binds its resolution: its `manifest` is
137
+ `{format: "instruction-resolved/1", status, document: {uri, sha256, version?}, dependencies, resolved_digest}`
138
+ (`Resolved.manifest()`), and the author's digest must be its document's `sha256`. `sign_jws` and `public_jwk` are for
139
+ tests and tooling.
140
+
141
+ ## Following
142
+
143
+ Following (asyncio, any MCP client with `read_resource` / `call_tool` / `subscribe_resource`): `InstructionFollower`;
144
+ `McpSessionClient` adapts the official `mcp` SDK's session (the `mcp` extra). On the 2026-07-28 wire its subscription
145
+ is a `subscriptions/listen` stream that calls `follower.notify`, and reopens after a drop; `mcp_auth.ClientCredentials`
146
+ signs an agent in (the client-credentials grant, renewed before its five minutes are up).
147
+
148
+ `watch` speaks MCP 2026-07-28, statelessly: `Client(transport, mode="2026-07-28")`. There is no `initialize` and no
149
+ session id, so any replica of the server answers each request. It is the only protocol instruction.md supports, so
150
+ pin it in your own code too: `mode="auto"` falls back to the older session handshake when its `server/discover`
151
+ probe is answered with an error.
152
+
153
+ ## Command line
154
+
155
+ ```sh
156
+ python -m instruction_md check FILE # diagnostics on stderr; exit 1 on an error (warnings pass)
157
+ python -m instruction_md tree FILE # the authored tree as JSON
158
+ python -m instruction_md deliver FILE [--param NAME=VALUE ...] [--resolved]
159
+ # the text a model receives; its bases and includes are read from the files
160
+ # beside it, under its directory (never above it, never a URL)
161
+ python -m instruction_md format FILE # the formatted text
162
+ ```
163
+
164
+ and `watch` (the `mcp` extra) to follow an instruction on an instruction.md server. Each version applied is a JSON
165
+ line on stdout, and each one held is a JSON line on stderr. The follower declares a binding and reports what it
166
+ applied, so the instruction's maintainers see it among its consumers.
167
+
168
+ ```sh
169
+ # as an agent: the studio's Settings ▸ Security makes the credential, and shows its id, secret and token URL once
170
+ export INSTRUCTION_MD_CLIENT_ID=… INSTRUCTION_MD_TOKEN_URL=… INSTRUCTION_MD_CLIENT_SECRET=…
171
+ python -m instruction_md watch instruction://acme/support-agent@latest \
172
+ --require-signature --require-delivery-signature --out AGENTS.md
173
+ # once, in CI, with a token you already hold: exit 0 applied, 6 held
174
+ python -m instruction_md watch instruction://ins_…@stable --token "$TOKEN" --once --require-signature
175
+ ```
176
+
177
+ ## Conformance
178
+
179
+ The tests run the vendored data (`conformance/`, listed in its README): the specification's source, model (with
180
+ `jsonschema` installed), resolution and text cases and its samples, and the reference's vectors — every read case's
181
+ tree, diagnostics, identities, parameters and text, every resolution's artifact and text, the inline tokens — compared
182
+ exactly. The source distribution carries both, so an unpacked sdist runs them:
183
+
184
+ ```sh
185
+ python3 -m venv .venv && .venv/bin/pip install '.[dev]'
186
+ .venv/bin/pytest
187
+ ```
188
+
189
+ In the repository the package is built from, `scripts/sync-fixtures.sh [--check]` keeps those copies, the package's
190
+ `registry.json` and `workflow-registry.json` in step with their sources. Malformed YAML is reported under the same code and line as
191
+ the reference does, its message PyYAML's.
192
+
193
+ ## Licence
194
+
195
+ Licensed under either of the MIT licence (`LICENSE-MIT`) or the Apache License, Version 2.0 (`LICENSE-APACHE`), at
196
+ your option; the repository it is built from keeps its own licence, which does not apply to this package. It redistributes the specification's
197
+ registries (`instruction_md/registry.json`, `instruction_md/workflow-registry.json`), unchanged, from
198
+ [instruction-md/specification](https://github.com/instruction-md/specification) by instruction.md (TSOK Inc.), under
199
+ the Creative Commons Attribution 4.0 International licence (https://creativecommons.org/licenses/by/4.0/); `NOTICE`
200
+ says so, and lists the licences of the conformance data the source distribution carries.
@@ -0,0 +1,160 @@
1
+ # instruction.md (Python)
2
+
3
+ The [instruction.md](https://instruction.md) specification's [first edition](https://instruction.md/specification/)
4
+ (`instruction/1`) in Python: the reader and its checks, the inline syntax, resolution and the agent's text profile,
5
+ the registry, the formatter, digests and signature verification — and a follower for instructions served over MCP. It
6
+ is a port of the TypeScript reference, `instruction.md` on npm, byte-exact with its vectors and with the
7
+ specification's conformance data.
8
+
9
+ ```sh
10
+ pip install instruction.md # Python 3.9 or later; PyYAML is its one dependency
11
+ pip install 'instruction.md[sign]' # signature verification (cryptography)
12
+ pip install 'instruction.md[mcp]' # following over MCP (the official mcp SDK 2.3 or later, Python 3.10 or later)
13
+ ```
14
+
15
+ ```python
16
+ from instruction_md import check, digest, read, resolve
17
+
18
+ text = """---
19
+ spec: "1"
20
+ title: House style
21
+ parameters:
22
+ audience: { type: string, default: developers }
23
+ ---
24
+
25
+ # House style
26
+
27
+ You write for ${audience}.
28
+
29
+ MUST: write in the second person.
30
+ BECAUSE: the reader is the one acting.
31
+
32
+ NEVER: promise a date you cannot keep.
33
+ """
34
+
35
+ r = read(text)
36
+ print(r.document.to_json()["format"]) # instruction/1: the authored tree, as the schema has it
37
+ print(check(r)) # []: no diagnostics
38
+ res = resolve(text, uri="house-style.md", params={"audience": "support engineers"})
39
+ print(res.ok) # True
40
+ print(res.text, end="") # what the agent receives (instruction-text/1)
41
+ print(digest(text)) # sha256:… of the stored bytes
42
+ ```
43
+
44
+ prints
45
+
46
+ ```text
47
+ instruction/1
48
+ []
49
+ True
50
+ # House style
51
+
52
+ You write for support engineers.
53
+
54
+ MUST: write in the second person.
55
+ BECAUSE: the reader is the one acting.
56
+
57
+ NEVER: promise a date you cannot keep.
58
+ sha256:20f4f08abec3d38ca9b2324884e1063fd1b0eb1751da2a5c08b29945b775ae84
59
+ ```
60
+
61
+ - `read(text, fragment=False, uri=None)` → `ReadResult`: `document`, `diagnostics`, `identities`, `parameters`,
62
+ `footnotes`, and which Markdown nodes are prose, which keyword a rule was written with, where its reason was.
63
+ Nodes are `MarkdownNode` and `DirectiveNode` (`to_json()` gives the reference's JSON: `{format: "instruction/1",
64
+ metadata: {front, back}, body: [...]}`); a structured body is a `StructuredValue` with its `source` and, parsed,
65
+ its `data`. Metadata and structured bodies are YAML 1.2's Core Schema restricted to JSON: no anchors, aliases,
66
+ custom tags, non-string keys, non-finite numbers or second document, duplicate keys refused.
67
+ - `check(text | ReadResult)` → `list[Diagnostic]`, the reader's diagnostics (§18) with the inline checks, in source
68
+ order: `code`, `severity`, `message`, `range` (and `uri` for another source's).
69
+ - `inline_tokens(source)` → the inline forms — `:kind[label]{attrs}`, `[[target|label]]`, `![[…]]`, `[^note]`,
70
+ `$math$`, `${parameter}` — read where CommonMark reads text: never in code, raw HTML, an autolink, a link
71
+ destination or title, or a definition (the tokenizer is a port of micromark's, with GFM's tables, task list items
72
+ and autolink literals).
73
+ - `resolve(text, uri=, version=, params=, load=)` composes bases (`extends`) with their patches, includes as separate
74
+ instances, pins and parameters; `load` is a callable (`uri → Source | str | None`) or a mapping of resolved URIs to
75
+ sources, and nothing is ever fetched. `res.text` is the agent text, `res.resolved.to_json()` the resolved artifact
76
+ (`instruction-resolved/1`, its `resolved_digest` in RFC 8785 form). `resolve_with(text, sources)` takes the sources
77
+ already loaded, `resolve_tree(tree, trees)` authored trees (as `AuthoredDocument` or JSON).
78
+ - `to_text(tree, params=, parameters=, prose=, identities=, known=)` → the text profile of any tree, authored or
79
+ resolved; `canonical_json` / `json_digest` → RFC 8785; `format(text)` → the conservative formatter; `digest(text)`
80
+ → `sha256:` of the stored bytes, nothing stripped; the registry → `KINDS`, `INLINE`, `KEYWORDS`, `PATTERNS`, …
81
+ (the specification's `registry.json`, shipped with the package).
82
+ - The workflow registry (`workflow-registry.json`, shipped with the package): `WORKFLOW_KINDS`,
83
+ `WORKFLOW_COMMON_FIELDS`, `WORKFLOW_LIMITS`; `WORKFLOW_SCOPES`, the kinds whose `body` or `branches` hold nested steps
84
+ (foreach, batch, iterate, subgraph; parallel, race), from reference/workflows.md, since the registry doesn't say:
85
+ another kind's field of that name (an `http` request's `body`) is data. The reader checks each `:::workflow{dialect="instruction/workflow"}` body
86
+ against it (unknown kinds and fields, required fields, triggers, dependencies, routes, cycles, scopes and limits:
87
+ `invalid-workflow`, `limit-exceeded`, `extension-unavailable`); `workflow_diagnostics(definition)` checks a
88
+ definition on its own.
89
+
90
+ Offsets (an inline token's, a range's lines) index the Python string, by code point.
91
+
92
+ ## Signatures
93
+
94
+ With the `sign` extra, `verify_author(jws, text, keys, doc=, pub=)` checks an author signature over the stored bytes;
95
+ `verify_delivery(jws, delivered, delivery_keys, author_keys, aud=, authored_text=, pub=)` a delivery signature over
96
+ what one reader received, with the author signature it embeds. A delivery binds its resolution: its `manifest` is
97
+ `{format: "instruction-resolved/1", status, document: {uri, sha256, version?}, dependencies, resolved_digest}`
98
+ (`Resolved.manifest()`), and the author's digest must be its document's `sha256`. `sign_jws` and `public_jwk` are for
99
+ tests and tooling.
100
+
101
+ ## Following
102
+
103
+ Following (asyncio, any MCP client with `read_resource` / `call_tool` / `subscribe_resource`): `InstructionFollower`;
104
+ `McpSessionClient` adapts the official `mcp` SDK's session (the `mcp` extra). On the 2026-07-28 wire its subscription
105
+ is a `subscriptions/listen` stream that calls `follower.notify`, and reopens after a drop; `mcp_auth.ClientCredentials`
106
+ signs an agent in (the client-credentials grant, renewed before its five minutes are up).
107
+
108
+ `watch` speaks MCP 2026-07-28, statelessly: `Client(transport, mode="2026-07-28")`. There is no `initialize` and no
109
+ session id, so any replica of the server answers each request. It is the only protocol instruction.md supports, so
110
+ pin it in your own code too: `mode="auto"` falls back to the older session handshake when its `server/discover`
111
+ probe is answered with an error.
112
+
113
+ ## Command line
114
+
115
+ ```sh
116
+ python -m instruction_md check FILE # diagnostics on stderr; exit 1 on an error (warnings pass)
117
+ python -m instruction_md tree FILE # the authored tree as JSON
118
+ python -m instruction_md deliver FILE [--param NAME=VALUE ...] [--resolved]
119
+ # the text a model receives; its bases and includes are read from the files
120
+ # beside it, under its directory (never above it, never a URL)
121
+ python -m instruction_md format FILE # the formatted text
122
+ ```
123
+
124
+ and `watch` (the `mcp` extra) to follow an instruction on an instruction.md server. Each version applied is a JSON
125
+ line on stdout, and each one held is a JSON line on stderr. The follower declares a binding and reports what it
126
+ applied, so the instruction's maintainers see it among its consumers.
127
+
128
+ ```sh
129
+ # as an agent: the studio's Settings ▸ Security makes the credential, and shows its id, secret and token URL once
130
+ export INSTRUCTION_MD_CLIENT_ID=… INSTRUCTION_MD_TOKEN_URL=… INSTRUCTION_MD_CLIENT_SECRET=…
131
+ python -m instruction_md watch instruction://acme/support-agent@latest \
132
+ --require-signature --require-delivery-signature --out AGENTS.md
133
+ # once, in CI, with a token you already hold: exit 0 applied, 6 held
134
+ python -m instruction_md watch instruction://ins_…@stable --token "$TOKEN" --once --require-signature
135
+ ```
136
+
137
+ ## Conformance
138
+
139
+ The tests run the vendored data (`conformance/`, listed in its README): the specification's source, model (with
140
+ `jsonschema` installed), resolution and text cases and its samples, and the reference's vectors — every read case's
141
+ tree, diagnostics, identities, parameters and text, every resolution's artifact and text, the inline tokens — compared
142
+ exactly. The source distribution carries both, so an unpacked sdist runs them:
143
+
144
+ ```sh
145
+ python3 -m venv .venv && .venv/bin/pip install '.[dev]'
146
+ .venv/bin/pytest
147
+ ```
148
+
149
+ In the repository the package is built from, `scripts/sync-fixtures.sh [--check]` keeps those copies, the package's
150
+ `registry.json` and `workflow-registry.json` in step with their sources. Malformed YAML is reported under the same code and line as
151
+ the reference does, its message PyYAML's.
152
+
153
+ ## Licence
154
+
155
+ Licensed under either of the MIT licence (`LICENSE-MIT`) or the Apache License, Version 2.0 (`LICENSE-APACHE`), at
156
+ your option; the repository it is built from keeps its own licence, which does not apply to this package. It redistributes the specification's
157
+ registries (`instruction_md/registry.json`, `instruction_md/workflow-registry.json`), unchanged, from
158
+ [instruction-md/specification](https://github.com/instruction-md/specification) by instruction.md (TSOK Inc.), under
159
+ the Creative Commons Attribution 4.0 International licence (https://creativecommons.org/licenses/by/4.0/); `NOTICE`
160
+ says so, and lists the licences of the conformance data the source distribution carries.
@@ -0,0 +1,17 @@
1
+ # Conformance data
2
+
3
+ Vendored from `packages/spec` by `scripts/sync-fixtures.sh` (`--check` fails when a copy differs); never edited
4
+ here. The SDK's tests run against these files alone, so they need no Node.
5
+
6
+ | Here | From | What | Licence |
7
+ |---|---|---|---|
8
+ | `specification/conformance/` | `packages/spec/specification/conformance/` | the specification's conformance cases: source structure, the model's schema, resolution of trees, workflow definitions, the text profile | Apache-2.0 (`specification/conformance/LICENSE`) |
9
+ | `specification/instruction.schema.json`, `specification/schemas/` | `packages/spec/specification/` | the authored tree's schema, the resolved snapshot's and the others | CC BY 4.0 |
10
+ | `specification/samples/` | `packages/spec/specification/samples/` | the specification's sample documents | CC BY 4.0 |
11
+ | `vectors/` | `packages/spec/vectors/` | what the reference implementation produces, byte for byte: reading, resolution, inline tokens, workflow diagnostics (`vectors/README.md`) | MIT (`vectors/LICENSE`) |
12
+
13
+ The specification's data (the conformance cases, the schemas, the samples, and the registries the package ships as
14
+ `instruction_md/registry.json` and `instruction_md/workflow-registry.json`) is [instruction-md/specification](https://github.com/instruction-md/specification)'s,
15
+ branch `codex/first-specification` at `af8400f` — by instruction.md (TSOK Inc.), redistributed unchanged; the
16
+ registry, schemas and samples under the Creative Commons Attribution 4.0 International licence
17
+ (https://creativecommons.org/licenses/by/4.0/). The vectors are written by the TypeScript reference (`packages/spec`, `instruction.md` on npm).