awcap 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.
- awcap-0.1.0/LICENSE +202 -0
- awcap-0.1.0/PKG-INFO +117 -0
- awcap-0.1.0/README.md +102 -0
- awcap-0.1.0/awcap/__init__.py +6 -0
- awcap-0.1.0/awcap/__main__.py +8 -0
- awcap-0.1.0/awcap/_doctor.py +199 -0
- awcap-0.1.0/awcap/_selftest.py +88 -0
- awcap-0.1.0/awcap/cli.py +204 -0
- awcap-0.1.0/awcap/descriptor.py +314 -0
- awcap-0.1.0/awcap/index.py +54 -0
- awcap-0.1.0/awcap/py.typed +0 -0
- awcap-0.1.0/awcap/scaffold.py +342 -0
- awcap-0.1.0/awcap.egg-info/PKG-INFO +117 -0
- awcap-0.1.0/awcap.egg-info/SOURCES.txt +23 -0
- awcap-0.1.0/awcap.egg-info/dependency_links.txt +1 -0
- awcap-0.1.0/awcap.egg-info/entry_points.txt +2 -0
- awcap-0.1.0/awcap.egg-info/requires.txt +4 -0
- awcap-0.1.0/awcap.egg-info/top_level.txt +1 -0
- awcap-0.1.0/pyproject.toml +34 -0
- awcap-0.1.0/setup.cfg +4 -0
- awcap-0.1.0/tests/test_check.py +124 -0
- awcap-0.1.0/tests/test_cli.py +30 -0
- awcap-0.1.0/tests/test_index.py +65 -0
- awcap-0.1.0/tests/test_scaffold.py +126 -0
- awcap-0.1.0/tests/test_self_descriptor.py +46 -0
awcap-0.1.0/LICENSE
ADDED
|
@@ -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.
|
awcap-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: awcap
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Aither World capabilities: describe a capability once and reach it the same way from CLI, Python, MCP and relay.
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/Aitherium/awcap
|
|
7
|
+
Project-URL: Repository, https://github.com/Aitherium/awcap.git
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: PyYAML>=6.0
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# awcap — Aither World capabilities
|
|
17
|
+
|
|
18
|
+
Describe one capability in one file and get the same name, arguments and JSON
|
|
19
|
+
back from CLI, Python, MCP and relay.
|
|
20
|
+
|
|
21
|
+
A tool that ships a CLI, a Python API and an MCP server usually ends up with
|
|
22
|
+
three names, three argument shapes and three result formats — and nothing says
|
|
23
|
+
which of them still work. `awcap` puts all of that in one `awcap.yaml` next to
|
|
24
|
+
the package, validates it, compiles the argument and result shapes to JSON
|
|
25
|
+
Schema, and refuses to let a capability call itself `live` unless it names a
|
|
26
|
+
check that can fail.
|
|
27
|
+
|
|
28
|
+
Status: **MVP, not yet published.** No daemon, no network; the only dependency
|
|
29
|
+
is PyYAML. Python 3.10+.
|
|
30
|
+
|
|
31
|
+
## The descriptor
|
|
32
|
+
|
|
33
|
+
```yaml
|
|
34
|
+
awcap: 1
|
|
35
|
+
brick: notes # the package this describes
|
|
36
|
+
capabilities:
|
|
37
|
+
- id: notes.add
|
|
38
|
+
summary: Add a note.
|
|
39
|
+
surfaces:
|
|
40
|
+
cli: {argv: [notes, add, "{title}", "{body}"]}
|
|
41
|
+
python: {module: notes.store, callable: add}
|
|
42
|
+
mcp: {tool: notes_add}
|
|
43
|
+
relay: {channel: "#notes", kind: finding}
|
|
44
|
+
input: {title: str, body: str, tags: "list[str]?"}
|
|
45
|
+
output: {id: str, created_at: str}
|
|
46
|
+
effects: write # read | write | spend | irreversible
|
|
47
|
+
state: live # live | planned | retired
|
|
48
|
+
checks: [tests/test_add.py::test_add_roundtrip]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Rules `awcap check` enforces, each one named when it fails:
|
|
52
|
+
|
|
53
|
+
- `awcap: 1`, a lowercase `brick`, and a non-empty `capabilities` list.
|
|
54
|
+
- Every capability has a unique `id`, at least one surface, and only the keys
|
|
55
|
+
above; each surface carries exactly its own keys.
|
|
56
|
+
- Every `{placeholder}` in a CLI `argv` is a declared input.
|
|
57
|
+
- Types are `str int float bool list dict any`, `list[T]`, and `T?` for an
|
|
58
|
+
optional field. They compile to JSON Schema (`additionalProperties: false`).
|
|
59
|
+
- `effects` and `state` come from the fixed sets above.
|
|
60
|
+
- **`state: live` requires a non-empty `checks` list.** A live claim nothing
|
|
61
|
+
can falsify is not live.
|
|
62
|
+
|
|
63
|
+
Unknown top-level keys are allowed, so a descriptor can sit alongside other
|
|
64
|
+
package metadata in the same file.
|
|
65
|
+
|
|
66
|
+
## Commands
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
awcap check awcap.yaml # surfaces + compiled schemas; 0/1/2
|
|
70
|
+
awcap check --json awcap.yaml # the same, machine-readable
|
|
71
|
+
awcap check --all . # every awcap.yaml under a tree
|
|
72
|
+
awcap index --out caps.json a/awcap.yaml b/awcap.yaml
|
|
73
|
+
awcap scaffold <installed-package> # draft a descriptor, all `planned`
|
|
74
|
+
awcap doctor # what is installed around awcap
|
|
75
|
+
awcap --self-test # prove each exit code fires
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Exit codes everywhere: **0** clean, **1** a violation (every problem printed),
|
|
79
|
+
**2** could not judge — an unreadable file, a directory with no descriptors, a
|
|
80
|
+
package that is not installed. An empty directory is never a pass.
|
|
81
|
+
|
|
82
|
+
`index` validates every input first and writes nothing if any of them is
|
|
83
|
+
invalid, unreadable, or describes a brick another file already described: a
|
|
84
|
+
partial index reads as complete to whoever consumes it. Output is
|
|
85
|
+
deterministic (sorted keys, no timestamps).
|
|
86
|
+
|
|
87
|
+
## Scaffolding
|
|
88
|
+
|
|
89
|
+
`awcap scaffold <pkg>` looks at an installed package three ways, all local:
|
|
90
|
+
|
|
91
|
+
1. its console script's `--help` (argparse or click subcommands) and each
|
|
92
|
+
subcommand's `--help` for positional arguments;
|
|
93
|
+
2. its public functions, via `importlib` and `inspect` (types from annotations,
|
|
94
|
+
defaults become optional fields);
|
|
95
|
+
3. a static MCP tool list, if a `mcp_server`/`mcp_tools`/`mcp` submodule
|
|
96
|
+
defines `TOOLS` or `TOOL_NAMES`. Anything that would need a running server
|
|
97
|
+
is skipped, and a note says so.
|
|
98
|
+
|
|
99
|
+
A subcommand, function and tool with the same name merge into one capability
|
|
100
|
+
with several surfaces. Every capability is written as `state: planned` with no
|
|
101
|
+
checks — scaffolding never claims anything is live. `effects` is guessed from
|
|
102
|
+
the verb (`list`, `show`, `status` … are `read`; the rest `write`) and
|
|
103
|
+
`output` is left empty: review both before promoting anything.
|
|
104
|
+
|
|
105
|
+
## Python
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from awcap.descriptor import check_file
|
|
109
|
+
from awcap.index import build_index
|
|
110
|
+
|
|
111
|
+
res = check_file("awcap.yaml")
|
|
112
|
+
res.exit_code, res.problems, res.as_dict()
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
Apache-2.0.
|
awcap-0.1.0/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# awcap — Aither World capabilities
|
|
2
|
+
|
|
3
|
+
Describe one capability in one file and get the same name, arguments and JSON
|
|
4
|
+
back from CLI, Python, MCP and relay.
|
|
5
|
+
|
|
6
|
+
A tool that ships a CLI, a Python API and an MCP server usually ends up with
|
|
7
|
+
three names, three argument shapes and three result formats — and nothing says
|
|
8
|
+
which of them still work. `awcap` puts all of that in one `awcap.yaml` next to
|
|
9
|
+
the package, validates it, compiles the argument and result shapes to JSON
|
|
10
|
+
Schema, and refuses to let a capability call itself `live` unless it names a
|
|
11
|
+
check that can fail.
|
|
12
|
+
|
|
13
|
+
Status: **MVP, not yet published.** No daemon, no network; the only dependency
|
|
14
|
+
is PyYAML. Python 3.10+.
|
|
15
|
+
|
|
16
|
+
## The descriptor
|
|
17
|
+
|
|
18
|
+
```yaml
|
|
19
|
+
awcap: 1
|
|
20
|
+
brick: notes # the package this describes
|
|
21
|
+
capabilities:
|
|
22
|
+
- id: notes.add
|
|
23
|
+
summary: Add a note.
|
|
24
|
+
surfaces:
|
|
25
|
+
cli: {argv: [notes, add, "{title}", "{body}"]}
|
|
26
|
+
python: {module: notes.store, callable: add}
|
|
27
|
+
mcp: {tool: notes_add}
|
|
28
|
+
relay: {channel: "#notes", kind: finding}
|
|
29
|
+
input: {title: str, body: str, tags: "list[str]?"}
|
|
30
|
+
output: {id: str, created_at: str}
|
|
31
|
+
effects: write # read | write | spend | irreversible
|
|
32
|
+
state: live # live | planned | retired
|
|
33
|
+
checks: [tests/test_add.py::test_add_roundtrip]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Rules `awcap check` enforces, each one named when it fails:
|
|
37
|
+
|
|
38
|
+
- `awcap: 1`, a lowercase `brick`, and a non-empty `capabilities` list.
|
|
39
|
+
- Every capability has a unique `id`, at least one surface, and only the keys
|
|
40
|
+
above; each surface carries exactly its own keys.
|
|
41
|
+
- Every `{placeholder}` in a CLI `argv` is a declared input.
|
|
42
|
+
- Types are `str int float bool list dict any`, `list[T]`, and `T?` for an
|
|
43
|
+
optional field. They compile to JSON Schema (`additionalProperties: false`).
|
|
44
|
+
- `effects` and `state` come from the fixed sets above.
|
|
45
|
+
- **`state: live` requires a non-empty `checks` list.** A live claim nothing
|
|
46
|
+
can falsify is not live.
|
|
47
|
+
|
|
48
|
+
Unknown top-level keys are allowed, so a descriptor can sit alongside other
|
|
49
|
+
package metadata in the same file.
|
|
50
|
+
|
|
51
|
+
## Commands
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
awcap check awcap.yaml # surfaces + compiled schemas; 0/1/2
|
|
55
|
+
awcap check --json awcap.yaml # the same, machine-readable
|
|
56
|
+
awcap check --all . # every awcap.yaml under a tree
|
|
57
|
+
awcap index --out caps.json a/awcap.yaml b/awcap.yaml
|
|
58
|
+
awcap scaffold <installed-package> # draft a descriptor, all `planned`
|
|
59
|
+
awcap doctor # what is installed around awcap
|
|
60
|
+
awcap --self-test # prove each exit code fires
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Exit codes everywhere: **0** clean, **1** a violation (every problem printed),
|
|
64
|
+
**2** could not judge — an unreadable file, a directory with no descriptors, a
|
|
65
|
+
package that is not installed. An empty directory is never a pass.
|
|
66
|
+
|
|
67
|
+
`index` validates every input first and writes nothing if any of them is
|
|
68
|
+
invalid, unreadable, or describes a brick another file already described: a
|
|
69
|
+
partial index reads as complete to whoever consumes it. Output is
|
|
70
|
+
deterministic (sorted keys, no timestamps).
|
|
71
|
+
|
|
72
|
+
## Scaffolding
|
|
73
|
+
|
|
74
|
+
`awcap scaffold <pkg>` looks at an installed package three ways, all local:
|
|
75
|
+
|
|
76
|
+
1. its console script's `--help` (argparse or click subcommands) and each
|
|
77
|
+
subcommand's `--help` for positional arguments;
|
|
78
|
+
2. its public functions, via `importlib` and `inspect` (types from annotations,
|
|
79
|
+
defaults become optional fields);
|
|
80
|
+
3. a static MCP tool list, if a `mcp_server`/`mcp_tools`/`mcp` submodule
|
|
81
|
+
defines `TOOLS` or `TOOL_NAMES`. Anything that would need a running server
|
|
82
|
+
is skipped, and a note says so.
|
|
83
|
+
|
|
84
|
+
A subcommand, function and tool with the same name merge into one capability
|
|
85
|
+
with several surfaces. Every capability is written as `state: planned` with no
|
|
86
|
+
checks — scaffolding never claims anything is live. `effects` is guessed from
|
|
87
|
+
the verb (`list`, `show`, `status` … are `read`; the rest `write`) and
|
|
88
|
+
`output` is left empty: review both before promoting anything.
|
|
89
|
+
|
|
90
|
+
## Python
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from awcap.descriptor import check_file
|
|
94
|
+
from awcap.index import build_index
|
|
95
|
+
|
|
96
|
+
res = check_file("awcap.yaml")
|
|
97
|
+
res.exit_code, res.problems, res.as_dict()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
Apache-2.0.
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"""Stack-aware `doctor` for awcap.
|
|
2
|
+
|
|
3
|
+
GENERATED BY gen_aw_doctor.py -- DO NOT EDIT.
|
|
4
|
+
Regenerate it with the generator named above; a hand-edit here is reverted by
|
|
5
|
+
the next run and fails the parity gate.
|
|
6
|
+
|
|
7
|
+
Why a doctor exists at all: the aw* bricks are designed to COMPOSE, so the
|
|
8
|
+
interesting failures live BETWEEN them. "awcap is installed" is not the useful
|
|
9
|
+
fact -- "awcap is installed and the thing it pairs with is not" is. This reports
|
|
10
|
+
the whole stack, not just itself.
|
|
11
|
+
|
|
12
|
+
stdlib only, on purpose: a diagnostic that cannot run because a dependency is
|
|
13
|
+
missing is worthless precisely when you need it.
|
|
14
|
+
"""
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import importlib.util
|
|
18
|
+
import os
|
|
19
|
+
import shutil
|
|
20
|
+
import sys
|
|
21
|
+
|
|
22
|
+
#: Frozen from the Aither World registry at generation time. A shipped
|
|
23
|
+
#: package cannot read the registry, and a doctor that guessed at the family
|
|
24
|
+
#: would go stale in silence. Regenerate to update.
|
|
25
|
+
SELF = 'awcap'
|
|
26
|
+
FAMILY = [
|
|
27
|
+
'awask', 'awavatar', 'awbac', 'awbrain', 'awbrowse', 'awcams', 'awclassify', 'awdecide',
|
|
28
|
+
'awdeck', 'awdelphi', 'awdiscord', 'awdit', 'awembed', 'awevolve', 'awfind', 'awflow',
|
|
29
|
+
'awfocus', 'awgit', 'awgraph', 'awgym', 'awiam', 'awkno', 'awm', 'awmail', 'awmine', 'awnboard',
|
|
30
|
+
'awnest', 'awnet', 'awpermit', 'awplay', 'awpool', 'awpredict', 'awprism', 'awprove',
|
|
31
|
+
'awreason', 'awrecover', 'awrecurse', 'awrelay', 'awrena', 'awrepl', 'awreport', 'awresearch',
|
|
32
|
+
'awrise', 'awrouter', 'awrtifact', 'awrun', 'awscope', 'awscreen', 'awseal', 'awsettings',
|
|
33
|
+
'awshare', 'awsprite', 'awstorage', 'awsuite', 'awswarm', 'awtax', 'awtoll', 'awtunnel',
|
|
34
|
+
'awvision', 'awvoice', 'awwall', 'gawbbonet',
|
|
35
|
+
]
|
|
36
|
+
PAIRS_WITH = ['adk', 'awflow', 'awgit', 'awm', 'awrelay']
|
|
37
|
+
|
|
38
|
+
#: This brick's OWN config, read out of its source at generation time.
|
|
39
|
+
#: ENV_REQUIRED is `os.environ["X"]` -- absent, that is a KeyError the moment
|
|
40
|
+
#: the line runs. ENV_OPTIONAL is `os.getenv("X")`, which returns None and lets
|
|
41
|
+
#: the caller cope. Only this brick's namespace is listed: reporting the
|
|
42
|
+
#: platform-wide vars it also touches would be noise, and a doctor that floods
|
|
43
|
+
#: gets ignored.
|
|
44
|
+
ENV_REQUIRED = []
|
|
45
|
+
ENV_OPTIONAL = []
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _installed(mod: str) -> "str | None":
|
|
49
|
+
"""Version if importable, else None. Never raises -- a broken sibling must
|
|
50
|
+
not take the diagnostic down with it."""
|
|
51
|
+
try:
|
|
52
|
+
if importlib.util.find_spec(mod) is None:
|
|
53
|
+
return None
|
|
54
|
+
except (ImportError, ValueError):
|
|
55
|
+
return None
|
|
56
|
+
try:
|
|
57
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
58
|
+
try:
|
|
59
|
+
return version(mod)
|
|
60
|
+
except PackageNotFoundError:
|
|
61
|
+
return "installed"
|
|
62
|
+
except Exception:
|
|
63
|
+
return "installed"
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def report(out=None) -> int:
|
|
67
|
+
"""Print the stack picture. 0 = this brick and its pairs are present."""
|
|
68
|
+
out = out or sys.stdout
|
|
69
|
+
print(f"{SELF} doctor", file=out)
|
|
70
|
+
|
|
71
|
+
mine = _installed(SELF)
|
|
72
|
+
print(f" self {SELF} {mine or 'NOT IMPORTABLE'}", file=out)
|
|
73
|
+
shim = shutil.which(SELF)
|
|
74
|
+
print(f" command {shim or 'not on PATH'}", file=out)
|
|
75
|
+
|
|
76
|
+
# The stack. Siblings this brick pairs with are called out separately,
|
|
77
|
+
# because a missing pair is a REASON, while a missing unrelated brick is
|
|
78
|
+
# just a fact about your machine.
|
|
79
|
+
missing_pairs, present = [], []
|
|
80
|
+
for name in FAMILY:
|
|
81
|
+
v = _installed(name)
|
|
82
|
+
if v:
|
|
83
|
+
present.append(name)
|
|
84
|
+
elif name in PAIRS_WITH:
|
|
85
|
+
missing_pairs.append(name)
|
|
86
|
+
print(f" stack {len(present)}/{len(FAMILY)} aw* packages installed",
|
|
87
|
+
file=out)
|
|
88
|
+
if present:
|
|
89
|
+
print(f" {' '.join(sorted(present))}", file=out)
|
|
90
|
+
|
|
91
|
+
missing_req = [v for v in ENV_REQUIRED if not os.environ.get(v)]
|
|
92
|
+
if ENV_REQUIRED or ENV_OPTIONAL:
|
|
93
|
+
have = sum(1 for v in ENV_REQUIRED + ENV_OPTIONAL if os.environ.get(v))
|
|
94
|
+
total = len(ENV_REQUIRED) + len(ENV_OPTIONAL)
|
|
95
|
+
print(f" config {have}/{total} of this brick's own vars set", file=out)
|
|
96
|
+
if missing_req:
|
|
97
|
+
# Not a preference. os.environ[...] raises the moment it runs.
|
|
98
|
+
print(f" MISSING REQUIRED: {' '.join(missing_req)}", file=out)
|
|
99
|
+
|
|
100
|
+
local = _local_checks()
|
|
101
|
+
for line in local:
|
|
102
|
+
print(f" {line}", file=out)
|
|
103
|
+
problems, unjudged = _local_verdict()
|
|
104
|
+
|
|
105
|
+
if mine is None:
|
|
106
|
+
print(f"\nverdict: {SELF} itself is not importable. Reinstall it before "
|
|
107
|
+
f"anything else here means much.", file=out)
|
|
108
|
+
return 1
|
|
109
|
+
if missing_req:
|
|
110
|
+
print(f"\nverdict: {SELF} is missing required config "
|
|
111
|
+
f"({', '.join(missing_req)}). Those are read with os.environ[...], "
|
|
112
|
+
f"so the code path that needs them raises rather than degrades.",
|
|
113
|
+
file=out)
|
|
114
|
+
return 1
|
|
115
|
+
# A measured NO outranks a missing optional pair: awrise printed
|
|
116
|
+
# "nothing wakes run-due" and still exited 0 because the missing-pairs
|
|
117
|
+
# branch returned first (measured 2026-09-20).
|
|
118
|
+
if problems:
|
|
119
|
+
for p in problems:
|
|
120
|
+
print(f"\nverdict: {p}", file=out)
|
|
121
|
+
return 1
|
|
122
|
+
if unjudged:
|
|
123
|
+
for u in unjudged:
|
|
124
|
+
print(f"\nverdict: UNJUDGED -- could not judge: {u}", file=out)
|
|
125
|
+
return 2
|
|
126
|
+
if missing_pairs:
|
|
127
|
+
print(f"\nverdict: {SELF} works, but pairs with "
|
|
128
|
+
f"{', '.join(sorted(missing_pairs))} which "
|
|
129
|
+
f"{'is' if len(missing_pairs) == 1 else 'are'} not installed. "
|
|
130
|
+
f"That is a capability you are missing, not an error.", file=out)
|
|
131
|
+
return 0
|
|
132
|
+
print(f"\nverdict: {SELF} and everything it pairs with are present.", file=out)
|
|
133
|
+
return 0
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def _local_verdict() -> tuple:
|
|
137
|
+
"""The brick's OWN verdict, folded into the exit code.
|
|
138
|
+
|
|
139
|
+
Without this the local lines are DECORATION. Measured 2026-09-20: awrise
|
|
140
|
+
printed "hostclock NOT INSTALLED -- nothing wakes run-due" and "last tick
|
|
141
|
+
never", then exited 0 -- teaching an operator that a doctor exit code
|
|
142
|
+
carries no information. A brick opts in with `_doctor_local_verdict()`
|
|
143
|
+
returning (problems, unjudged); a brick without one is unaffected.
|
|
144
|
+
"""
|
|
145
|
+
try:
|
|
146
|
+
mod = importlib.import_module(f"{SELF}.doctor_local")
|
|
147
|
+
problems, unjudged = mod._doctor_local_verdict()
|
|
148
|
+
except Exception: # noqa: BLE001
|
|
149
|
+
return [], []
|
|
150
|
+
return list(problems or []), list(unjudged or [])
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _local_checks() -> "list[str]":
|
|
154
|
+
"""Per-brick checks, if this package defines them.
|
|
155
|
+
|
|
156
|
+
Kept as a HOOK rather than generated guesses: the generator knows the family
|
|
157
|
+
from the registry, but it does not know what awcap needs at runtime, and a
|
|
158
|
+
doctor that invented config requirements would be confidently wrong. A
|
|
159
|
+
package supplies `_doctor_local()` returning display lines; absent, the
|
|
160
|
+
stack picture above still stands on its own.
|
|
161
|
+
"""
|
|
162
|
+
try:
|
|
163
|
+
mod = importlib.import_module(f"{SELF}.doctor_local")
|
|
164
|
+
except Exception:
|
|
165
|
+
return []
|
|
166
|
+
try:
|
|
167
|
+
return list(mod._doctor_local())
|
|
168
|
+
except Exception as exc: # noqa: BLE001
|
|
169
|
+
return [f"local checks raised {type(exc).__name__}: {exc}"]
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def main(argv: "list[str] | None" = None) -> int:
|
|
173
|
+
# --self-test delegates to a SIBLING module when one exists.
|
|
174
|
+
#
|
|
175
|
+
# This file is generated and a fresh run replaces it, so a self-test
|
|
176
|
+
# written HERE is deleted by the next regeneration. awdelphi learned that
|
|
177
|
+
# the expensive way: 125 lines exercising four real failure paths --
|
|
178
|
+
# convergence, roster anonymization, resume, gateway-down -- lived in this
|
|
179
|
+
# file and were destroyed by a routine regeneration, silently, leaving a
|
|
180
|
+
# --self-test flag that reported PASS while asserting nothing.
|
|
181
|
+
#
|
|
182
|
+
# So the seam is a separate module the generator never writes. A package
|
|
183
|
+
# with real machinery to prove puts it in _selftest.py; everything else
|
|
184
|
+
# keeps the honest answer below rather than a self-test that only ever
|
|
185
|
+
# passes.
|
|
186
|
+
argv = list(argv if argv is not None else __import__("sys").argv[1:])
|
|
187
|
+
if "--self-test" in argv:
|
|
188
|
+
try:
|
|
189
|
+
from . import _selftest as _st
|
|
190
|
+
except Exception:
|
|
191
|
+
print("no _selftest module: this doctor reports the stack, and has",
|
|
192
|
+
"no machinery of its own to prove")
|
|
193
|
+
return 0
|
|
194
|
+
return int(_st.run())
|
|
195
|
+
return report()
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
if __name__ == "__main__":
|
|
199
|
+
raise SystemExit(main())
|