syv-conductor 0.1.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 (47) hide show
  1. syv_conductor-0.1.0/.gitignore +49 -0
  2. syv_conductor-0.1.0/LICENSE +199 -0
  3. syv_conductor-0.1.0/PKG-INFO +18 -0
  4. syv_conductor-0.1.0/pyproject.toml +29 -0
  5. syv_conductor-0.1.0/src/conductor/__init__.py +94 -0
  6. syv_conductor-0.1.0/src/conductor/_sentinel.py +32 -0
  7. syv_conductor-0.1.0/src/conductor/about/__init__.py +86 -0
  8. syv_conductor-0.1.0/src/conductor/about/__main__.py +47 -0
  9. syv_conductor-0.1.0/src/conductor/about/llms.txt +464 -0
  10. syv_conductor-0.1.0/src/conductor/category.py +169 -0
  11. syv_conductor-0.1.0/src/conductor/compound/__init__.py +18 -0
  12. syv_conductor-0.1.0/src/conductor/compound/for_each.py +151 -0
  13. syv_conductor-0.1.0/src/conductor/compound/protocol.py +48 -0
  14. syv_conductor-0.1.0/src/conductor/compound/subprocess.py +228 -0
  15. syv_conductor-0.1.0/src/conductor/compound/while_loop.py +257 -0
  16. syv_conductor-0.1.0/src/conductor/errors.py +274 -0
  17. syv_conductor-0.1.0/src/conductor/execution/__init__.py +0 -0
  18. syv_conductor-0.1.0/src/conductor/execution/checkpoint.py +88 -0
  19. syv_conductor-0.1.0/src/conductor/execution/engine.py +1053 -0
  20. syv_conductor-0.1.0/src/conductor/execution/events.py +142 -0
  21. syv_conductor-0.1.0/src/conductor/execution/request.py +20 -0
  22. syv_conductor-0.1.0/src/conductor/execution/resolver.py +197 -0
  23. syv_conductor-0.1.0/src/conductor/execution/results.py +71 -0
  24. syv_conductor-0.1.0/src/conductor/execution/retry.py +28 -0
  25. syv_conductor-0.1.0/src/conductor/execution/skip.py +63 -0
  26. syv_conductor-0.1.0/src/conductor/execution/state.py +55 -0
  27. syv_conductor-0.1.0/src/conductor/execution/store.py +37 -0
  28. syv_conductor-0.1.0/src/conductor/expr/__init__.py +42 -0
  29. syv_conductor-0.1.0/src/conductor/expr/engine.py +774 -0
  30. syv_conductor-0.1.0/src/conductor/flow_format/__init__.py +58 -0
  31. syv_conductor-0.1.0/src/conductor/flow_format/loader.py +220 -0
  32. syv_conductor-0.1.0/src/conductor/graph/__init__.py +0 -0
  33. syv_conductor-0.1.0/src/conductor/graph/compiler.py +407 -0
  34. syv_conductor-0.1.0/src/conductor/graph/model.py +140 -0
  35. syv_conductor-0.1.0/src/conductor/graph/regions.py +76 -0
  36. syv_conductor-0.1.0/src/conductor/graph/shared_refs.py +171 -0
  37. syv_conductor-0.1.0/src/conductor/graph/topology.py +97 -0
  38. syv_conductor-0.1.0/src/conductor/graph/type_check.py +249 -0
  39. syv_conductor-0.1.0/src/conductor/metadata.py +36 -0
  40. syv_conductor-0.1.0/src/conductor/node.py +27 -0
  41. syv_conductor-0.1.0/src/conductor/registry/__init__.py +585 -0
  42. syv_conductor-0.1.0/src/conductor/registry/definition.py +89 -0
  43. syv_conductor-0.1.0/src/conductor/registry/discovery.py +26 -0
  44. syv_conductor-0.1.0/src/conductor/registry/schema.py +75 -0
  45. syv_conductor-0.1.0/src/conductor/types.py +79 -0
  46. syv_conductor-0.1.0/src/conductor/validation.py +132 -0
  47. syv_conductor-0.1.0/src/conductor/widgets.py +455 -0
@@ -0,0 +1,49 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ *.egg-info/
7
+ *.egg
8
+ dist/
9
+ build/
10
+ *.whl
11
+
12
+ # Virtual environments
13
+ .venv/
14
+ venv/
15
+ env/
16
+
17
+ # uv
18
+ uv.lock
19
+
20
+ # IDE
21
+ .idea/
22
+ .vscode/
23
+ *.swp
24
+ *.swo
25
+ *~
26
+
27
+ # OS
28
+ .DS_Store
29
+ Thumbs.db
30
+
31
+ # Testing
32
+ .pytest_cache/
33
+ .coverage
34
+ htmlcov/
35
+ .mypy_cache/
36
+
37
+ # Docs build
38
+ site/
39
+
40
+ # Notebooks
41
+ *.ipynb
42
+ .ipynb_checkpoints/
43
+ # ...but keep the tutorial notebooks in examples/
44
+ !examples/*.ipynb
45
+
46
+ # Misc
47
+ *.log
48
+ .env
49
+ .env.*
@@ -0,0 +1,199 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may accept warranty, liability,
167
+ or other obligations and/or rights consistent with this License.
168
+ However, in accepting such obligations, You may act only on Your
169
+ own behalf and on Your sole responsibility, not on behalf of any
170
+ other Contributor, and only if You agree to indemnify, defend,
171
+ and hold each Contributor harmless for any liability incurred by,
172
+ or claims asserted against, such Contributor by reason of your
173
+ accepting any such warranty or support.
174
+
175
+ END OF TERMS AND CONDITIONS
176
+
177
+ APPENDIX: How to apply the Apache License to your work.
178
+
179
+ To apply the Apache License to your work, attach the following
180
+ boilerplate notice, with the fields enclosed by brackets "[]"
181
+ replaced with your own identifying information. (Don't include
182
+ the brackets!) The text should be enclosed in the appropriate
183
+ comment syntax for the file format. We also recommend that a
184
+ file or class name and description of a copyright owner be provided
185
+ on a separate line in the Source form of the Work.
186
+
187
+ Copyright 2026 Syvai
188
+
189
+ Licensed under the Apache License, Version 2.0 (the "License");
190
+ you may not use this file except in compliance with the License.
191
+ You may obtain a copy of the License at
192
+
193
+ http://www.apache.org/licenses/LICENSE-2.0
194
+
195
+ Unless required by applicable law or agreed to in writing, software
196
+ distributed under the License is distributed on an "AS IS" BASIS,
197
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
198
+ implied. See the License for the specific language governing
199
+ permissions and limitations under the License.
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: syv-conductor
3
+ Version: 0.1.0
4
+ Summary: Reusable DAG execution engine — node registration, graph compilation, eager parallel streaming execution, retry, shared references, and human-in-the-loop checkpointing.
5
+ Project-URL: Repository, https://github.com/syvai/conductor
6
+ Author-email: Syvai <billy@syv.ai>
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Typing :: Typed
15
+ Requires-Python: >=3.12
16
+ Requires-Dist: pydantic>=2.0
17
+ Provides-Extra: yaml
18
+ Requires-Dist: pyyaml>=6.0; extra == 'yaml'
@@ -0,0 +1,29 @@
1
+ [project]
2
+ name = "syv-conductor"
3
+ version = "0.1.0"
4
+ description = "Reusable DAG execution engine — node registration, graph compilation, eager parallel streaming execution, retry, shared references, and human-in-the-loop checkpointing."
5
+ requires-python = ">=3.12"
6
+ authors = [{ name = "Syvai", email = "billy@syv.ai" }]
7
+ license = "Apache-2.0"
8
+ classifiers = [
9
+ "Development Status :: 4 - Beta",
10
+ "Intended Audience :: Developers",
11
+ "License :: OSI Approved :: Apache Software License",
12
+ "Programming Language :: Python :: 3",
13
+ "Programming Language :: Python :: 3.12",
14
+ "Typing :: Typed",
15
+ ]
16
+ dependencies = ["pydantic>=2.0"]
17
+
18
+ [project.optional-dependencies]
19
+ yaml = ["pyyaml>=6.0"]
20
+
21
+ [project.urls]
22
+ Repository = "https://github.com/syvai/conductor"
23
+
24
+ [build-system]
25
+ requires = ["hatchling"]
26
+ build-backend = "hatchling.build"
27
+
28
+ [tool.hatch.build.targets.wheel]
29
+ packages = ["src/conductor"]
@@ -0,0 +1,94 @@
1
+ """conductor — reusable graph execution engine.
2
+
3
+ The top-level package re-exports the surfaces most projects need. Deeper
4
+ internals (resolver, state, topology, etc.) stay in submodules.
5
+ """
6
+
7
+ from conductor import errors, expr, widgets
8
+ from conductor._sentinel import SKIPPED
9
+ from conductor.compound import FOR_EACH, SUBPROCESS, WHILE, ForEachNode, SubprocessNode, WhileNode
10
+ from conductor.compound.subprocess import SubprocessRegistry
11
+ from conductor.errors import (
12
+ CompilationError,
13
+ ConductorError,
14
+ FlowExecutionError,
15
+ FlowPausedError,
16
+ HumanInputRequired,
17
+ LoopRunawayError,
18
+ NodeConnectionError,
19
+ NodeError,
20
+ NodeExecutionError,
21
+ NodeTimeoutError,
22
+ NodeValidationError,
23
+ SignalRequired,
24
+ SubprocessFailedError,
25
+ )
26
+ from conductor.execution.checkpoint import FlowCheckpoint
27
+ from conductor.execution.engine import execute, execute_sync, resume, resume_sync
28
+ from conductor.execution.retry import RetryConfig
29
+ from conductor.execution.store import FlowStore
30
+ from conductor.graph.compiler import CompiledGraph, compile
31
+ from conductor.graph.model import (
32
+ Flow,
33
+ FlowDependency,
34
+ FlowTrigger,
35
+ GraphEdge,
36
+ GraphNode,
37
+ )
38
+ from conductor.node import BaseNode
39
+ from conductor.registry import NodeRegistry
40
+ from conductor.registry.definition import Actor
41
+ from conductor.types import NodeCategory, ResultFormat, WidgetType
42
+
43
+ __all__ = [
44
+ # Registry + graph
45
+ "NodeRegistry",
46
+ "GraphNode",
47
+ "GraphEdge",
48
+ "Flow",
49
+ "FlowDependency",
50
+ "FlowTrigger",
51
+ "BaseNode",
52
+ "Actor",
53
+ "compile",
54
+ "CompiledGraph",
55
+ # Execution
56
+ "execute",
57
+ "execute_sync",
58
+ "resume",
59
+ "resume_sync",
60
+ "RetryConfig",
61
+ "FlowStore",
62
+ "FlowCheckpoint",
63
+ "SKIPPED",
64
+ # Compound nodes
65
+ "ForEachNode",
66
+ "FOR_EACH",
67
+ "WhileNode",
68
+ "WHILE",
69
+ "SubprocessNode",
70
+ "SUBPROCESS",
71
+ "SubprocessRegistry",
72
+ # Types / enums
73
+ "ResultFormat",
74
+ "NodeCategory",
75
+ "WidgetType",
76
+ # Errors (most commonly raised from node code)
77
+ "ConductorError",
78
+ "CompilationError",
79
+ "NodeError",
80
+ "NodeValidationError",
81
+ "NodeExecutionError",
82
+ "NodeConnectionError",
83
+ "NodeTimeoutError",
84
+ "FlowExecutionError",
85
+ "HumanInputRequired",
86
+ "FlowPausedError",
87
+ "SignalRequired",
88
+ "LoopRunawayError",
89
+ "SubprocessFailedError",
90
+ # Submodules re-exported for namespace access (`conductor.widgets.Text`, etc.)
91
+ "widgets",
92
+ "errors",
93
+ "expr",
94
+ ]
@@ -0,0 +1,32 @@
1
+ """SKIPPED sentinel for conditional branch propagation."""
2
+
3
+ from typing import Any
4
+
5
+
6
+ class _SkippedType:
7
+ """Sentinel value indicating an output branch was not taken.
8
+
9
+ Used by conditional nodes (If, Switch) to mark inactive branches.
10
+ When a node receives only SKIPPED inputs, it is also skipped.
11
+ """
12
+
13
+ _instance: "_SkippedType | None" = None
14
+
15
+ def __new__(cls) -> "_SkippedType":
16
+ if cls._instance is None:
17
+ cls._instance = super().__new__(cls)
18
+ return cls._instance
19
+
20
+ def __repr__(self) -> str:
21
+ return "SKIPPED"
22
+
23
+ def __bool__(self) -> bool:
24
+ return False
25
+
26
+
27
+ SKIPPED = _SkippedType()
28
+
29
+
30
+ def is_skipped(value: Any) -> bool:
31
+ """Check if a value is the SKIPPED sentinel."""
32
+ return value is SKIPPED
@@ -0,0 +1,86 @@
1
+ """Runnable library context — meant to be consumed by AI agents or humans.
2
+
3
+ Usage (CLI):
4
+
5
+ python -m conductor.about # full reference
6
+ python -m conductor.about sections # list section slugs
7
+ python -m conductor.about scheduling # a single section (prefix match ok)
8
+
9
+ Usage (programmatic):
10
+
11
+ from conductor.about import get_content, list_sections, get_section
12
+
13
+ The text served is ``conductor/about/llms.txt`` — the canonical reference
14
+ text shipped inside the package. Downstream projects get it for free via
15
+ pip/uv install without needing repo access.
16
+ """
17
+
18
+ from __future__ import annotations
19
+
20
+ import re
21
+
22
+
23
+ def _load_text() -> str:
24
+ """Read the packaged ``llms.txt``."""
25
+ from importlib.resources import files
26
+
27
+ resource = files("conductor.about").joinpath("llms.txt")
28
+ if resource.is_file():
29
+ return resource.read_text(encoding="utf-8")
30
+
31
+ raise RuntimeError(
32
+ "conductor.about could not locate llms.txt inside the package. "
33
+ "This indicates a broken install; please reinstall conductor."
34
+ )
35
+
36
+
37
+ _HEADING = re.compile(r"^(##+) (.+)$", re.MULTILINE)
38
+
39
+
40
+ def _slug(heading: str) -> str:
41
+ return re.sub(r"[^a-z0-9]+", "-", heading.lower()).strip("-")
42
+
43
+
44
+ def _parse_sections(text: str) -> dict[str, str]:
45
+ """Parse H2 and H3 headings into sections.
46
+
47
+ A section runs from its heading up to the next heading of the **same or
48
+ higher level** (fewer ``#``), so "Retry" (H3 inside Core Concepts) ends
49
+ at the next H3 or when Core Concepts ends — not when a later H2 starts.
50
+ """
51
+ matches = list(_HEADING.finditer(text))
52
+ out: dict[str, str] = {}
53
+ for i, m in enumerate(matches):
54
+ level = len(m.group(1)) # 2 for ##, 3 for ###
55
+ start = m.start()
56
+ end = len(text)
57
+ for nxt in matches[i + 1:]:
58
+ if len(nxt.group(1)) <= level:
59
+ end = nxt.start()
60
+ break
61
+ out[_slug(m.group(2))] = text[start:end].rstrip() + "\n"
62
+ return out
63
+
64
+
65
+ def get_content() -> str:
66
+ """Return the full reference text."""
67
+ return _load_text()
68
+
69
+
70
+ def list_sections() -> list[str]:
71
+ """Return the slugs of every top-level (``##``) section, in document order."""
72
+ return list(_parse_sections(_load_text()).keys())
73
+
74
+
75
+ def get_section(name: str) -> str | None:
76
+ """Return one section by slug. Accepts a prefix/substring match."""
77
+ sections = _parse_sections(_load_text())
78
+ if name in sections:
79
+ return sections[name]
80
+ for slug, body in sections.items():
81
+ if name.lower() in slug:
82
+ return body
83
+ return None
84
+
85
+
86
+ __all__ = ["get_content", "list_sections", "get_section"]
@@ -0,0 +1,47 @@
1
+ """CLI entry point: ``python -m conductor.about [section]``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import sys
6
+
7
+ from conductor.about import get_content, get_section, list_sections
8
+
9
+ _USAGE = """\
10
+ Usage: python -m conductor.about [section]
11
+
12
+ (no args) print the full reference text
13
+ sections list available section slugs
14
+ <slug> print the matching section (prefix/substring ok)
15
+ -h, --help show this message
16
+ """
17
+
18
+
19
+ def main(argv: list[str]) -> int:
20
+ if not argv:
21
+ sys.stdout.write(get_content())
22
+ return 0
23
+
24
+ arg = argv[0]
25
+
26
+ if arg in ("-h", "--help"):
27
+ sys.stdout.write(_USAGE)
28
+ return 0
29
+
30
+ if arg == "sections":
31
+ for slug in list_sections():
32
+ print(slug)
33
+ return 0
34
+
35
+ section = get_section(arg)
36
+ if section is None:
37
+ print(f"No section matching '{arg}'. Available:", file=sys.stderr)
38
+ for slug in list_sections():
39
+ print(f" {slug}", file=sys.stderr)
40
+ return 1
41
+
42
+ sys.stdout.write(section)
43
+ return 0
44
+
45
+
46
+ if __name__ == "__main__":
47
+ raise SystemExit(main(sys.argv[1:]))