metergraph-skills 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.
- metergraph_skills-0.1.0/LICENSE +201 -0
- metergraph_skills-0.1.0/PKG-INFO +86 -0
- metergraph_skills-0.1.0/README.md +68 -0
- metergraph_skills-0.1.0/pyproject.toml +35 -0
- metergraph_skills-0.1.0/src/metergraph_skills/__init__.py +6 -0
- metergraph_skills-0.1.0/src/metergraph_skills/__main__.py +5 -0
- metergraph_skills-0.1.0/src/metergraph_skills/bundle.py +67 -0
- metergraph_skills-0.1.0/src/metergraph_skills/cli.py +196 -0
- metergraph_skills-0.1.0/src/metergraph_skills/installer.py +547 -0
- metergraph_skills-0.1.0/src/metergraph_skills/skill/SKILL.md +73 -0
- metergraph_skills-0.1.0/src/metergraph_skills/skill/manifest.json +9 -0
- metergraph_skills-0.1.0/tests/test_installer.py +321 -0
|
@@ -0,0 +1,201 @@
|
|
|
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 reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and 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 Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: metergraph-skills
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Installs the Metergraph agent skill into a project for Codex, Claude Code or Cursor
|
|
5
|
+
Keywords: metergraph,agent,skill,llm,cost-tracking
|
|
6
|
+
Author: Metergraph
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Project-URL: Homepage, https://www.metergraph.dev/
|
|
15
|
+
Project-URL: Issues, https://github.com/metergraph/cli/issues
|
|
16
|
+
Project-URL: Source, https://github.com/metergraph/cli
|
|
17
|
+
|
|
18
|
+
# metergraph-skills
|
|
19
|
+
|
|
20
|
+
Installs the Metergraph agent skill into a project, so Codex, Claude Code or
|
|
21
|
+
Cursor can load it. This is the Python equivalent of `metergraph skill` in the
|
|
22
|
+
npm CLI ([`metergraph-cli`](https://www.npmjs.com/package/metergraph-cli)).
|
|
23
|
+
|
|
24
|
+
This package does not sign in, connect a workspace, configure MCP or make any
|
|
25
|
+
network request. For those, use the npm CLI: `npx metergraph-cli@next`. The
|
|
26
|
+
Python SDK for instrumenting an application is a different package,
|
|
27
|
+
[`metergraph`](https://pypi.org/project/metergraph/).
|
|
28
|
+
|
|
29
|
+
## Install the skill
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
pip install metergraph-skills
|
|
33
|
+
metergraph-skills install --client claude --runtime local
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Run it in the project directory, or pass `--project DIR`.
|
|
37
|
+
|
|
38
|
+
| Option | Values |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `--client` | `codex`, `claude`, `cursor` |
|
|
41
|
+
| `--runtime` | `local`, `cloud` |
|
|
42
|
+
| `--project` | Project directory. Default: the current directory. |
|
|
43
|
+
| `--json` | Print one JSON line on stdout. |
|
|
44
|
+
|
|
45
|
+
The skill is written to the client's project skill directory:
|
|
46
|
+
|
|
47
|
+
| Client | Path |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| Codex | `.agents/skills/metergraph/SKILL.md` |
|
|
50
|
+
| Claude Code | `.claude/skills/metergraph/SKILL.md` |
|
|
51
|
+
| Cursor | `.cursor/skills/metergraph/SKILL.md` |
|
|
52
|
+
|
|
53
|
+
An ownership receipt is written to `.metergraph/skill-installations.json`. It
|
|
54
|
+
holds no secrets. No other file is touched. Restart the client afterwards; the
|
|
55
|
+
skill is not discovered until the client loads it.
|
|
56
|
+
|
|
57
|
+
Use `metergraph-skills update` to replace an older revision installed by
|
|
58
|
+
Metergraph. A skill file that Metergraph did not install, or that was edited
|
|
59
|
+
after it was installed, is never replaced.
|
|
60
|
+
|
|
61
|
+
## Same files as the npm CLI
|
|
62
|
+
|
|
63
|
+
`metergraph-skills` and `metergraph skill` write the same paths and the same
|
|
64
|
+
receipt. A skill installed by one is recognised and updated by the other. The
|
|
65
|
+
bundled `SKILL.md` is byte-identical to the one in the npm package and to
|
|
66
|
+
<https://www.metergraph.dev/SKILL.md> for the same revision, and its SHA-256
|
|
67
|
+
is checked before anything is written.
|
|
68
|
+
|
|
69
|
+
To copy the file yourself, `metergraph-skills path` prints the directory that
|
|
70
|
+
holds the bundled `SKILL.md` and `manifest.json`.
|
|
71
|
+
|
|
72
|
+
## Exit codes
|
|
73
|
+
|
|
74
|
+
| Code | Outcome |
|
|
75
|
+
| --- | --- |
|
|
76
|
+
| 0 | `ok` |
|
|
77
|
+
| 1 | `internal_error`: the bundled skill failed its integrity check |
|
|
78
|
+
| 2 | `invalid_input` |
|
|
79
|
+
| 6 | `unsupported`: the client or runtime cannot load project skill files |
|
|
80
|
+
| 8 | `conflict`: an existing file was not replaced |
|
|
81
|
+
| 9 | `filesystem_error` |
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
Apache-2.0. Source: <https://github.com/metergraph/cli>.
|
|
86
|
+
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# metergraph-skills
|
|
2
|
+
|
|
3
|
+
Installs the Metergraph agent skill into a project, so Codex, Claude Code or
|
|
4
|
+
Cursor can load it. This is the Python equivalent of `metergraph skill` in the
|
|
5
|
+
npm CLI ([`metergraph-cli`](https://www.npmjs.com/package/metergraph-cli)).
|
|
6
|
+
|
|
7
|
+
This package does not sign in, connect a workspace, configure MCP or make any
|
|
8
|
+
network request. For those, use the npm CLI: `npx metergraph-cli@next`. The
|
|
9
|
+
Python SDK for instrumenting an application is a different package,
|
|
10
|
+
[`metergraph`](https://pypi.org/project/metergraph/).
|
|
11
|
+
|
|
12
|
+
## Install the skill
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
pip install metergraph-skills
|
|
16
|
+
metergraph-skills install --client claude --runtime local
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Run it in the project directory, or pass `--project DIR`.
|
|
20
|
+
|
|
21
|
+
| Option | Values |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| `--client` | `codex`, `claude`, `cursor` |
|
|
24
|
+
| `--runtime` | `local`, `cloud` |
|
|
25
|
+
| `--project` | Project directory. Default: the current directory. |
|
|
26
|
+
| `--json` | Print one JSON line on stdout. |
|
|
27
|
+
|
|
28
|
+
The skill is written to the client's project skill directory:
|
|
29
|
+
|
|
30
|
+
| Client | Path |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| Codex | `.agents/skills/metergraph/SKILL.md` |
|
|
33
|
+
| Claude Code | `.claude/skills/metergraph/SKILL.md` |
|
|
34
|
+
| Cursor | `.cursor/skills/metergraph/SKILL.md` |
|
|
35
|
+
|
|
36
|
+
An ownership receipt is written to `.metergraph/skill-installations.json`. It
|
|
37
|
+
holds no secrets. No other file is touched. Restart the client afterwards; the
|
|
38
|
+
skill is not discovered until the client loads it.
|
|
39
|
+
|
|
40
|
+
Use `metergraph-skills update` to replace an older revision installed by
|
|
41
|
+
Metergraph. A skill file that Metergraph did not install, or that was edited
|
|
42
|
+
after it was installed, is never replaced.
|
|
43
|
+
|
|
44
|
+
## Same files as the npm CLI
|
|
45
|
+
|
|
46
|
+
`metergraph-skills` and `metergraph skill` write the same paths and the same
|
|
47
|
+
receipt. A skill installed by one is recognised and updated by the other. The
|
|
48
|
+
bundled `SKILL.md` is byte-identical to the one in the npm package and to
|
|
49
|
+
<https://www.metergraph.dev/SKILL.md> for the same revision, and its SHA-256
|
|
50
|
+
is checked before anything is written.
|
|
51
|
+
|
|
52
|
+
To copy the file yourself, `metergraph-skills path` prints the directory that
|
|
53
|
+
holds the bundled `SKILL.md` and `manifest.json`.
|
|
54
|
+
|
|
55
|
+
## Exit codes
|
|
56
|
+
|
|
57
|
+
| Code | Outcome |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| 0 | `ok` |
|
|
60
|
+
| 1 | `internal_error`: the bundled skill failed its integrity check |
|
|
61
|
+
| 2 | `invalid_input` |
|
|
62
|
+
| 6 | `unsupported`: the client or runtime cannot load project skill files |
|
|
63
|
+
| 8 | `conflict`: an existing file was not replaced |
|
|
64
|
+
| 9 | `filesystem_error` |
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
Apache-2.0. Source: <https://github.com/metergraph/cli>.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["flit_core>=3.9,<4"]
|
|
3
|
+
build-backend = "flit_core.buildapi"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "metergraph-skills"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Installs the Metergraph agent skill into a project for Codex, Claude Code or Cursor"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
authors = [{ name = "Metergraph" }]
|
|
13
|
+
keywords = ["metergraph", "agent", "skill", "llm", "cost-tracking"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"License :: OSI Approved :: Apache Software License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
]
|
|
21
|
+
dependencies = []
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://www.metergraph.dev/"
|
|
25
|
+
Source = "https://github.com/metergraph/cli"
|
|
26
|
+
Issues = "https://github.com/metergraph/cli/issues"
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
metergraph-skills = "metergraph_skills.cli:main"
|
|
30
|
+
|
|
31
|
+
[tool.flit.module]
|
|
32
|
+
name = "metergraph_skills"
|
|
33
|
+
|
|
34
|
+
[tool.flit.sdist]
|
|
35
|
+
include = ["tests/"]
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""The skill bundled in this package and its integrity check.
|
|
2
|
+
|
|
3
|
+
The skill file in skill/ is a byte-for-byte copy of the public skill at the
|
|
4
|
+
manifest's source_url, and of assets/skill/SKILL.md in the npm CLI. The source
|
|
5
|
+
has no version of its own, so the revision is derived from the content hash.
|
|
6
|
+
The hash is pinned here as well as in the manifest, so editing either file
|
|
7
|
+
alone is detected. Keep PINNED_SHA256 equal to the one in src/skill-bundle.js.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import hashlib
|
|
11
|
+
import json
|
|
12
|
+
import re
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import NamedTuple, Optional
|
|
15
|
+
|
|
16
|
+
PINNED_SHA256 = "57b920677adf62759c7221629327192a2d16b7e6034f7948ffd96cee402d4891"
|
|
17
|
+
SOURCE_URL = "https://www.metergraph.dev/SKILL.md"
|
|
18
|
+
|
|
19
|
+
ASSET_DIR = Path(__file__).resolve().parent / "skill"
|
|
20
|
+
MANIFEST_KEYS = ["file", "manifest_version", "name", "revision", "sha256", "size", "source_url"]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Bundle(NamedTuple):
|
|
24
|
+
name: str
|
|
25
|
+
revision: str
|
|
26
|
+
sha256: str
|
|
27
|
+
content: bytes
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def sha256_hex(content: bytes) -> str:
|
|
31
|
+
return hashlib.sha256(content).hexdigest()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def revision_for(sha256: str) -> str:
|
|
35
|
+
return "sha256-" + sha256[:12]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def load_bundled_skill() -> Optional[Bundle]:
|
|
39
|
+
"""Returns the bundled skill, or None when the manifest or the skill file
|
|
40
|
+
is missing, malformed or does not match the pinned hash. Never downloads
|
|
41
|
+
anything."""
|
|
42
|
+
try:
|
|
43
|
+
manifest = json.loads((ASSET_DIR / "manifest.json").read_text(encoding="utf-8"))
|
|
44
|
+
content = (ASSET_DIR / "SKILL.md").read_bytes()
|
|
45
|
+
except (OSError, ValueError):
|
|
46
|
+
return None
|
|
47
|
+
if (
|
|
48
|
+
not isinstance(manifest, dict)
|
|
49
|
+
or sorted(manifest) != MANIFEST_KEYS
|
|
50
|
+
or manifest["manifest_version"] != 1
|
|
51
|
+
or manifest["file"] != "SKILL.md"
|
|
52
|
+
or manifest["source_url"] != SOURCE_URL
|
|
53
|
+
or not isinstance(manifest["name"], str)
|
|
54
|
+
or not re.fullmatch(r"[a-z0-9-]{1,64}", manifest["name"])
|
|
55
|
+
or manifest["sha256"] != PINNED_SHA256
|
|
56
|
+
or manifest["revision"] != revision_for(PINNED_SHA256)
|
|
57
|
+
or type(manifest["size"]) is not int
|
|
58
|
+
or manifest["size"] != len(content)
|
|
59
|
+
):
|
|
60
|
+
return None
|
|
61
|
+
sha256 = sha256_hex(content)
|
|
62
|
+
if sha256 != PINNED_SHA256:
|
|
63
|
+
return None
|
|
64
|
+
prefix = "---\nname: {}\ndescription: ".format(manifest["name"]).encode("utf-8")
|
|
65
|
+
if not content.startswith(prefix):
|
|
66
|
+
return None
|
|
67
|
+
return Bundle(manifest["name"], manifest["revision"], sha256, content)
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"""Command line entry point for metergraph-skills.
|
|
2
|
+
|
|
3
|
+
Results use the same JSON envelope and exit codes as "metergraph skill" in the
|
|
4
|
+
npm CLI, so scripts and agents can handle either one.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
import sys
|
|
9
|
+
from typing import Any, Dict, List, Optional
|
|
10
|
+
|
|
11
|
+
from . import __version__
|
|
12
|
+
from .bundle import ASSET_DIR
|
|
13
|
+
from .installer import (
|
|
14
|
+
HANDOFF_SKILL_CLIENTS,
|
|
15
|
+
HANDOFF_SKILL_RUNTIMES,
|
|
16
|
+
SKILL_CLIENTS,
|
|
17
|
+
SKILL_RUNTIMES,
|
|
18
|
+
run_skill,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
SCHEMA_VERSION = 1
|
|
22
|
+
EXIT_CODES = {
|
|
23
|
+
"ok": 0,
|
|
24
|
+
"internal_error": 1,
|
|
25
|
+
"invalid_input": 2,
|
|
26
|
+
"unsupported": 6,
|
|
27
|
+
"conflict": 8,
|
|
28
|
+
"filesystem_error": 9,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
USAGE = """Usage:
|
|
33
|
+
metergraph-skills install --client CLIENT --runtime RUNTIME [--project DIR] [--json]
|
|
34
|
+
metergraph-skills update --client CLIENT --runtime RUNTIME [--project DIR] [--json]
|
|
35
|
+
metergraph-skills path
|
|
36
|
+
metergraph-skills --version
|
|
37
|
+
|
|
38
|
+
Install or update the Metergraph agent skill in a project.
|
|
39
|
+
--client codex, claude or cursor
|
|
40
|
+
--runtime local or cloud
|
|
41
|
+
--project Project directory. Default: the current directory.
|
|
42
|
+
--json Print one JSON line on stdout.
|
|
43
|
+
|
|
44
|
+
This does not sign in, connect a workspace or configure MCP. For those, use
|
|
45
|
+
the Metergraph CLI: npx metergraph-cli@next
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
ACTIONS = ("install", "update")
|
|
49
|
+
OPTIONS = ("--client", "--runtime", "--project")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class UsageError(Exception):
|
|
53
|
+
def __init__(self, reason: str, message: str) -> None:
|
|
54
|
+
super().__init__(message)
|
|
55
|
+
self.reason = reason
|
|
56
|
+
self.message = message
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def parse_args(argv: List[str]) -> Dict[str, Any]:
|
|
60
|
+
"""Mirrors the npm CLI's "skill" parser: the same reasons and messages.
|
|
61
|
+
Messages are fixed strings and never contain an argument value, because
|
|
62
|
+
a mistyped argument can be a credential."""
|
|
63
|
+
if "--help" in argv or "-h" in argv:
|
|
64
|
+
return {"command": "help"}
|
|
65
|
+
command = None
|
|
66
|
+
values: Dict[str, str] = {}
|
|
67
|
+
index = 0
|
|
68
|
+
while index < len(argv):
|
|
69
|
+
arg = argv[index]
|
|
70
|
+
position = index + 1
|
|
71
|
+
index += 1
|
|
72
|
+
if arg == "--json":
|
|
73
|
+
continue
|
|
74
|
+
if command is None and arg in ACTIONS + ("path", "--version"):
|
|
75
|
+
command = arg
|
|
76
|
+
continue
|
|
77
|
+
name, equals, inline = arg.partition("=")
|
|
78
|
+
if command in ACTIONS and name in OPTIONS:
|
|
79
|
+
if equals:
|
|
80
|
+
value = inline
|
|
81
|
+
elif index < len(argv):
|
|
82
|
+
value = argv[index]
|
|
83
|
+
index += 1
|
|
84
|
+
else:
|
|
85
|
+
raise UsageError("missing_value", "{} requires a value.".format(name))
|
|
86
|
+
if name in values:
|
|
87
|
+
raise UsageError("duplicate_option", "{} may be given only once.".format(name))
|
|
88
|
+
values[name] = value
|
|
89
|
+
continue
|
|
90
|
+
if command is None and not arg.startswith("-"):
|
|
91
|
+
raise UsageError(
|
|
92
|
+
"unknown_command",
|
|
93
|
+
'Unknown command at argument {}. Run "metergraph-skills --help" for usage.'.format(position),
|
|
94
|
+
)
|
|
95
|
+
raise UsageError(
|
|
96
|
+
"unknown_argument",
|
|
97
|
+
'Unrecognized argument at position {}. Run "metergraph-skills --help" for usage.'.format(position),
|
|
98
|
+
)
|
|
99
|
+
if command is None:
|
|
100
|
+
return {"command": "help"}
|
|
101
|
+
if command not in ACTIONS:
|
|
102
|
+
return {"command": command}
|
|
103
|
+
client = values.get("--client")
|
|
104
|
+
if client is None:
|
|
105
|
+
raise UsageError("missing_client", "--client is required. Use codex, claude or cursor.")
|
|
106
|
+
if client not in SKILL_CLIENTS and client not in HANDOFF_SKILL_CLIENTS:
|
|
107
|
+
raise UsageError("invalid_client", "--client must be codex, claude or cursor.")
|
|
108
|
+
runtime = values.get("--runtime")
|
|
109
|
+
if runtime is None:
|
|
110
|
+
raise UsageError("missing_runtime", "--runtime is required. Use local or cloud.")
|
|
111
|
+
if runtime not in SKILL_RUNTIMES and runtime not in HANDOFF_SKILL_RUNTIMES:
|
|
112
|
+
raise UsageError("invalid_runtime", "--runtime must be local or cloud.")
|
|
113
|
+
project = values.get("--project")
|
|
114
|
+
if project is not None and (project == "" or "\0" in project):
|
|
115
|
+
raise UsageError("invalid_project", "--project must name an existing directory.")
|
|
116
|
+
return {"command": command, "client": client, "runtime": runtime, "project": project}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _envelope(command: Optional[str], outcome: str, data, reason=None, message=None) -> Dict[str, Any]:
|
|
120
|
+
ok = outcome == "ok"
|
|
121
|
+
return {
|
|
122
|
+
"schema_version": SCHEMA_VERSION,
|
|
123
|
+
"command": command,
|
|
124
|
+
"ok": ok,
|
|
125
|
+
"outcome": outcome,
|
|
126
|
+
"exit_code": EXIT_CODES[outcome],
|
|
127
|
+
"data": data,
|
|
128
|
+
"error": None if ok else {"code": outcome, "reason": reason, "message": message},
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _write_json(envelope: Dict[str, Any]) -> None:
|
|
133
|
+
sys.stdout.write(json.dumps(envelope, separators=(",", ":"), ensure_ascii=False) + "\n")
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def main(argv: Optional[List[str]] = None) -> int:
|
|
137
|
+
argv = sys.argv[1:] if argv is None else list(argv)
|
|
138
|
+
as_json = "--json" in argv
|
|
139
|
+
try:
|
|
140
|
+
args = parse_args(argv)
|
|
141
|
+
except UsageError as error:
|
|
142
|
+
action = next((arg for arg in argv if arg in ACTIONS), None)
|
|
143
|
+
envelope = _envelope("skill " + action if action else None, "invalid_input", None, error.reason, error.message)
|
|
144
|
+
if as_json:
|
|
145
|
+
_write_json(envelope)
|
|
146
|
+
else:
|
|
147
|
+
sys.stderr.write(error.message + "\n")
|
|
148
|
+
return envelope["exit_code"]
|
|
149
|
+
|
|
150
|
+
if args["command"] == "help":
|
|
151
|
+
sys.stdout.write(USAGE)
|
|
152
|
+
return 0
|
|
153
|
+
if args["command"] == "--version":
|
|
154
|
+
print("metergraph-skills " + __version__)
|
|
155
|
+
return 0
|
|
156
|
+
if args["command"] == "path":
|
|
157
|
+
print(ASSET_DIR)
|
|
158
|
+
return 0
|
|
159
|
+
|
|
160
|
+
result = run_skill(args["command"], args["client"], args["runtime"], args["project"])
|
|
161
|
+
envelope = _envelope(
|
|
162
|
+
"skill " + args["command"],
|
|
163
|
+
result["outcome"],
|
|
164
|
+
result["data"],
|
|
165
|
+
result["reason"],
|
|
166
|
+
None if result["outcome"] == "ok" else result["message"],
|
|
167
|
+
)
|
|
168
|
+
if as_json:
|
|
169
|
+
_write_json(envelope)
|
|
170
|
+
else:
|
|
171
|
+
sys.stdout.write(_text(envelope, result["message"]))
|
|
172
|
+
return envelope["exit_code"]
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _text(result, message: str) -> str:
|
|
176
|
+
report = result["data"]
|
|
177
|
+
label = SKILL_CLIENTS.get(report["client"], {}).get("label") or HANDOFF_SKILL_CLIENTS.get(report["client"])
|
|
178
|
+
lines = ["Metergraph {}: {}, {} runtime".format(result["command"], label, report["runtime"])]
|
|
179
|
+
if report["path"] is not None:
|
|
180
|
+
lines.append("Path: " + report["path"])
|
|
181
|
+
if result["ok"]:
|
|
182
|
+
lines += [
|
|
183
|
+
"Status: " + report["status"],
|
|
184
|
+
"Source revision: {} (sha256 {})".format(report["source"]["revision"], report["source"]["sha256"]),
|
|
185
|
+
"Discovery: pending until {} loads the skill".format(label),
|
|
186
|
+
"Authenticated: no",
|
|
187
|
+
"",
|
|
188
|
+
message,
|
|
189
|
+
"Next: " + report["next_action"]["message"],
|
|
190
|
+
]
|
|
191
|
+
else:
|
|
192
|
+
lines += ["", "Result: {} (exit {})".format(result["outcome"], result["exit_code"]), message]
|
|
193
|
+
next_action = report["next_action"] or {}
|
|
194
|
+
if next_action.get("kind") == "connection_guide":
|
|
195
|
+
lines.append("Connection guide: " + next_action["url"])
|
|
196
|
+
return "\n".join(lines) + "\n"
|