agent_skill_parser 0.1.0
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.
- checksums.yaml +7 -0
- data/.yardopts +12 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/LICENSE +201 -0
- data/README.md +175 -0
- data/Rakefile +15 -0
- data/lib/agent_skill_parser/allowed_tool.rb +17 -0
- data/lib/agent_skill_parser/allowed_tools_parser.rb +32 -0
- data/lib/agent_skill_parser/document_splitter.rb +38 -0
- data/lib/agent_skill_parser/errors/base.rb +11 -0
- data/lib/agent_skill_parser/errors/parser.rb +18 -0
- data/lib/agent_skill_parser/errors/validation.rb +18 -0
- data/lib/agent_skill_parser/errors.rb +11 -0
- data/lib/agent_skill_parser/frontmatter.rb +42 -0
- data/lib/agent_skill_parser/frontmatter_parser.rb +74 -0
- data/lib/agent_skill_parser/parser.rb +39 -0
- data/lib/agent_skill_parser/skill.rb +29 -0
- data/lib/agent_skill_parser/validator.rb +88 -0
- data/lib/agent_skill_parser/version.rb +6 -0
- data/lib/agent_skill_parser.rb +50 -0
- data/sig/agent_skill_parser.rbs +4 -0
- metadata +83 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: bb27507d0523f0c0bb623a65b8817074f30f0c33bf415acfa29c16dd25e4d999
|
|
4
|
+
data.tar.gz: 13913b040ccc6fd706c9ed5d7bd79d00ef6d1ca46c988fa6d5033e06db9dfc68
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2ba5711dcaa15a855e53a45332f420c3d0c917e3d784468060ed3f7ce4c109eedbf90bdd88f04845402d165b55704403c63b40324cb641020dfd5dea6ee0fba3
|
|
7
|
+
data.tar.gz: 2b40d143d5f582a5d805887511d726dd849fffa5fced18f3f47bd11b1826e8a41503a32d4b69bcf681e236c9bbd06c2ec7518dbef9ee7f399994f2b5ec33ecac
|
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
"agent_skill_parser" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
|
|
4
|
+
|
|
5
|
+
* Participants will be tolerant of opposing views.
|
|
6
|
+
* Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
|
|
7
|
+
* When interpreting the words and actions of others, participants should always assume good intentions.
|
|
8
|
+
* Behaviour which can be reasonably considered harassment will not be tolerated.
|
|
9
|
+
|
|
10
|
+
If you have any concerns about behaviour within this project, please contact us at ["lucianghinda@users.noreply.github.com"](mailto:"lucianghinda@users.noreply.github.com").
|
data/LICENSE
ADDED
|
@@ -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.
|
data/README.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# AgentSkillParser
|
|
2
|
+
|
|
3
|
+
A Ruby gem for parsing skill files that use YAML frontmatter and markdown body content. Designed for agent/AI systems where skills are defined as structured markdown documents with metadata.
|
|
4
|
+
|
|
5
|
+
Warning:
|
|
6
|
+
- This gem does not protect against Prompt Injection. It only parses the structure of the skill according with the specification from https://agentskills.io/specification
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
Add this line to your application's Gemfile:
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
gem "agent_skill_parser"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
And then execute:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bundle install
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or install it yourself as:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
gem install agent_skill_parser
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Skill File Format
|
|
29
|
+
|
|
30
|
+
A skill file is a markdown document with YAML frontmatter delimited by `---`:
|
|
31
|
+
|
|
32
|
+
```markdown
|
|
33
|
+
---
|
|
34
|
+
name: pdf-processing
|
|
35
|
+
description: Extract text from PDF documents using various parsing strategies
|
|
36
|
+
license: Apache-2.0
|
|
37
|
+
compatibility: OpenAI Anthropic
|
|
38
|
+
metadata:
|
|
39
|
+
author: Acme Inc
|
|
40
|
+
version: 1.0.0
|
|
41
|
+
category: document-processing
|
|
42
|
+
allowed-tools: Bash(git:*) Read
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Instructions
|
|
46
|
+
|
|
47
|
+
This skill helps extract text from PDFs.
|
|
48
|
+
|
|
49
|
+
### Step 1: Download the PDF
|
|
50
|
+
Use the Bash tool to download PDF files from URLs.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Frontmatter Fields
|
|
54
|
+
|
|
55
|
+
| Field | Required | Description |
|
|
56
|
+
|-------|----------|-------------|
|
|
57
|
+
| `name` | Yes | Skill identifier. Lowercase letters, numbers, and hyphens only (1-64 chars). Cannot start/end with a hyphen or contain consecutive hyphens. |
|
|
58
|
+
| `description` | Yes | Human-readable description (1-1024 chars). |
|
|
59
|
+
| `license` | No | License name (e.g., `MIT`, `Apache-2.0`). |
|
|
60
|
+
| `compatibility` | No | Compatibility notes (max 500 chars). |
|
|
61
|
+
| `metadata` | No | Custom key-value pairs. Values are coerced to strings. |
|
|
62
|
+
| `allowed-tools` | No | Space or comma-separated tool names, optionally with patterns: `Bash(git:*) Read Write`. |
|
|
63
|
+
|
|
64
|
+
### Allowed Tools Format
|
|
65
|
+
|
|
66
|
+
Tools can be listed with optional regex patterns in parentheses:
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
allowed-tools: Bash(git:*) Read Write
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
This produces `AllowedTool` objects where `Bash` has a pattern of `git:*`, and `Read`/`Write` have no pattern.
|
|
73
|
+
|
|
74
|
+
## Usage
|
|
75
|
+
|
|
76
|
+
### Parsing a Skill File
|
|
77
|
+
|
|
78
|
+
```ruby
|
|
79
|
+
skill = AgentSkillParser.parse("path/to/skill.md")
|
|
80
|
+
|
|
81
|
+
skill.name # => "pdf-processing"
|
|
82
|
+
skill.description # => "Extract text from PDF documents..."
|
|
83
|
+
skill.body # => "## Instructions\n\nThis skill helps..."
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Accessing Frontmatter
|
|
87
|
+
|
|
88
|
+
```ruby
|
|
89
|
+
fm = skill.frontmatter
|
|
90
|
+
|
|
91
|
+
fm.name # => "pdf-processing"
|
|
92
|
+
fm.description # => "Extract text from PDF documents..."
|
|
93
|
+
fm.license # => "Apache-2.0"
|
|
94
|
+
fm.compatibility # => "OpenAI Anthropic"
|
|
95
|
+
fm.metadata # => {"author" => "Acme Inc", "version" => "1.0.0", "category" => "document-processing"}
|
|
96
|
+
fm.allowed_tools # => [#<AllowedTool name="Bash" pattern="git:*">, ...]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Accessing Allowed Tools
|
|
100
|
+
|
|
101
|
+
```ruby
|
|
102
|
+
tool = skill.frontmatter.allowed_tools.first
|
|
103
|
+
|
|
104
|
+
tool.name # => "Bash"
|
|
105
|
+
tool.pattern # => "git:*"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Error Handling
|
|
109
|
+
|
|
110
|
+
```ruby
|
|
111
|
+
begin
|
|
112
|
+
AgentSkillParser.parse("skill.md")
|
|
113
|
+
rescue AgentSkillParser::Errors::Parser => e
|
|
114
|
+
puts "Parse error: #{e.message}"
|
|
115
|
+
rescue AgentSkillParser::Errors::Validation => e
|
|
116
|
+
puts "Validation error: #{e.message}"
|
|
117
|
+
rescue Errno::ENOENT => e
|
|
118
|
+
puts "File not found: #{e.message}"
|
|
119
|
+
end
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
- `Errors::Parser` -- raised when YAML is malformed or the file cannot be read.
|
|
123
|
+
- `Errors::Validation` -- raised when frontmatter values violate schema rules (e.g., invalid name format, description too long).
|
|
124
|
+
|
|
125
|
+
### Minimal Skill File
|
|
126
|
+
|
|
127
|
+
A skill file only requires `name` and `description`:
|
|
128
|
+
|
|
129
|
+
```markdown
|
|
130
|
+
---
|
|
131
|
+
name: simple-skill
|
|
132
|
+
description: A simple skill for testing
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Instructions
|
|
136
|
+
|
|
137
|
+
This is a simple skill.
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Files Without Frontmatter
|
|
141
|
+
|
|
142
|
+
Files without YAML frontmatter are parsed with an empty frontmatter and the entire content as the body.
|
|
143
|
+
|
|
144
|
+
## Architecture
|
|
145
|
+
|
|
146
|
+
The parsing pipeline consists of four stages:
|
|
147
|
+
|
|
148
|
+
1. **DocumentSplitter** -- Separates YAML frontmatter from the markdown body.
|
|
149
|
+
2. **FrontmatterParser** -- Parses the YAML string into a `Frontmatter` object.
|
|
150
|
+
3. **Validator** -- Validates frontmatter against schema rules.
|
|
151
|
+
4. **Skill construction** -- Combines the validated frontmatter and body into a `Skill` object.
|
|
152
|
+
|
|
153
|
+
All data structures (`Skill`, `Frontmatter`, `AllowedTool`) are immutable, built using Ruby's `Data.define`.
|
|
154
|
+
|
|
155
|
+
## Requirements
|
|
156
|
+
|
|
157
|
+
- Ruby >= 3.2.0
|
|
158
|
+
|
|
159
|
+
## Development
|
|
160
|
+
|
|
161
|
+
Note:
|
|
162
|
+
- The code of this gem was generated with Claude Code + GLM but I review it manually and even if in some cases the code design could be better I feel like it is good enough for a first release.
|
|
163
|
+
|
|
164
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
bundle exec rake test # Run tests
|
|
168
|
+
bundle exec rake rubocop # Run linter
|
|
169
|
+
bundle exec rake yard # Generate documentation
|
|
170
|
+
bundle exec rake # Run tests + linter
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "minitest/test_task"
|
|
5
|
+
|
|
6
|
+
Minitest::TestTask.create
|
|
7
|
+
|
|
8
|
+
require "rubocop/rake_task"
|
|
9
|
+
|
|
10
|
+
RuboCop::RakeTask.new
|
|
11
|
+
|
|
12
|
+
require "yard"
|
|
13
|
+
YARD::Rake::YardocTask.new
|
|
14
|
+
|
|
15
|
+
task default: %i[test rubocop]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AgentSkillParser
|
|
4
|
+
# Represents an allowed tool with optional regex pattern.
|
|
5
|
+
#
|
|
6
|
+
# @!attribute [r] name
|
|
7
|
+
# @return [String] the tool name (e.g., "bash")
|
|
8
|
+
# @!attribute [r] pattern
|
|
9
|
+
# @return [String, nil] optional regex pattern for arguments
|
|
10
|
+
#
|
|
11
|
+
# @example Tool without pattern
|
|
12
|
+
# AllowedTool.new(name: "bash", pattern: nil)
|
|
13
|
+
#
|
|
14
|
+
# @example Tool with pattern
|
|
15
|
+
# AllowedTool.new(name: "search_files", pattern: "\\.(rb|js)$")
|
|
16
|
+
AllowedTool = Data.define(:name, :pattern)
|
|
17
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AgentSkillParser
|
|
4
|
+
# Parses tool names with optional argument patterns.
|
|
5
|
+
#
|
|
6
|
+
# @example Parse tools
|
|
7
|
+
# parser = AllowedToolsParser.new("bash, search_files(\\.rb$)")
|
|
8
|
+
# parser.call
|
|
9
|
+
# # => [
|
|
10
|
+
# # AllowedTool.new(name: "bash", pattern: nil),
|
|
11
|
+
# # AllowedTool.new(name: "search_files", pattern: "\\.rb$")
|
|
12
|
+
# # ]
|
|
13
|
+
class AllowedToolsParser
|
|
14
|
+
# @return [Regexp] pattern matching "tool_name" or "tool_name(pattern)"
|
|
15
|
+
TOOL_REGEX = /([A-Za-z_]\w*)(?:\(([^)]*)\))?/
|
|
16
|
+
|
|
17
|
+
# @param string [String] comma-separated tool list
|
|
18
|
+
def initialize(string)
|
|
19
|
+
@string = string
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @return [Array<AllowedTool>] parsed tool definitions
|
|
23
|
+
# @see AllowedTool
|
|
24
|
+
def call
|
|
25
|
+
return [] if @string.nil? || @string.empty?
|
|
26
|
+
|
|
27
|
+
@string.scan(TOOL_REGEX).map do |name, pattern|
|
|
28
|
+
AllowedTool.new(name:, pattern:)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AgentSkillParser
|
|
4
|
+
# Splits a markdown document into YAML frontmatter and body.
|
|
5
|
+
#
|
|
6
|
+
# @example With frontmatter
|
|
7
|
+
# splitter = DocumentSplitter.new("---\nname: skill\n---\n# Body")
|
|
8
|
+
# splitter.call # => ["name: skill", "# Body"]
|
|
9
|
+
#
|
|
10
|
+
# @example Without frontmatter
|
|
11
|
+
# splitter = DocumentSplitter.new("# Just body")
|
|
12
|
+
# splitter.call # => ["", "# Just body"]
|
|
13
|
+
class DocumentSplitter
|
|
14
|
+
# Represents a raw YAML document with separated YAML frontmatter and body.
|
|
15
|
+
#
|
|
16
|
+
# @!attribute [r] yaml_string
|
|
17
|
+
# @return [String] YAML frontmatter content
|
|
18
|
+
# @!attribute [r] body
|
|
19
|
+
# @return [String] Markdown body content
|
|
20
|
+
RawYamlDocument = Data.define(:yaml_string, :body)
|
|
21
|
+
|
|
22
|
+
# @param text [String] full document content
|
|
23
|
+
def initialize(text)
|
|
24
|
+
@text = text
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @return [RawYamlDocument]
|
|
28
|
+
def call
|
|
29
|
+
parts = @text.lstrip.split(/^---$/, 3)
|
|
30
|
+
|
|
31
|
+
if parts.length == 3 && parts[0].empty?
|
|
32
|
+
RawYamlDocument.new(yaml_string: parts[1].strip, body: parts[2].strip)
|
|
33
|
+
else
|
|
34
|
+
RawYamlDocument.new(yaml_string: "", body: @text.strip)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AgentSkillParser
|
|
4
|
+
module Errors
|
|
5
|
+
# Raised when parsing fails (e.g., invalid YAML, file not found).
|
|
6
|
+
#
|
|
7
|
+
# @example Rescue pattern
|
|
8
|
+
# begin
|
|
9
|
+
# AgentSkillParser.parse("invalid.md")
|
|
10
|
+
# rescue AgentSkillParser::Errors::Parser => e
|
|
11
|
+
# puts "Parsing error: #{e.message}"
|
|
12
|
+
# end
|
|
13
|
+
#
|
|
14
|
+
# @see FrontmatterParser#call
|
|
15
|
+
class Parser < Base
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AgentSkillParser
|
|
4
|
+
module Errors
|
|
5
|
+
# Raised when frontmatter validation fails.
|
|
6
|
+
#
|
|
7
|
+
# @example Rescue pattern
|
|
8
|
+
# begin
|
|
9
|
+
# AgentSkillParser.parse("skill.md")
|
|
10
|
+
# rescue AgentSkillParser::Errors::Validation => e
|
|
11
|
+
# puts "Validation error: #{e.message}"
|
|
12
|
+
# end
|
|
13
|
+
#
|
|
14
|
+
# @see Validator#call
|
|
15
|
+
class Validation < Base
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AgentSkillParser
|
|
4
|
+
# Parsed frontmatter data from a skill file.
|
|
5
|
+
#
|
|
6
|
+
# @!attribute [r] name
|
|
7
|
+
# @return [String] skill identifier (lowercase, hyphens, no spaces)
|
|
8
|
+
# @!attribute [r] description
|
|
9
|
+
# @return [String] human-readable description
|
|
10
|
+
# @!attribute [r] license
|
|
11
|
+
# @return [String, nil] license name (optional)
|
|
12
|
+
# @!attribute [r] compatibility
|
|
13
|
+
# @return [String, nil] compatibility notes (optional)
|
|
14
|
+
# @!attribute [r] metadata
|
|
15
|
+
# @return [Hash{String => String}] custom key-value metadata
|
|
16
|
+
# @!attribute [r] allowed_tools
|
|
17
|
+
# @return [Array<AllowedTool>] list of allowed tools
|
|
18
|
+
#
|
|
19
|
+
# @example
|
|
20
|
+
# Frontmatter.new(
|
|
21
|
+
# name: "my-skill",
|
|
22
|
+
# description: "A useful skill",
|
|
23
|
+
# license: "MIT",
|
|
24
|
+
# compatibility: "v1.2.3+",
|
|
25
|
+
# metadata: { "author" => "Alice" },
|
|
26
|
+
# allowed_tools: [AllowedTool.new(name: "bash", pattern: nil)]
|
|
27
|
+
# )
|
|
28
|
+
#
|
|
29
|
+
# @see FrontmatterParser
|
|
30
|
+
Frontmatter = Data.define(:name, :description, :license, :compatibility, :metadata, :allowed_tools)
|
|
31
|
+
|
|
32
|
+
# A singleton nil object for empty frontmatter.
|
|
33
|
+
# Used when YAML frontmatter is missing or empty.
|
|
34
|
+
NilFrontmatter = Frontmatter.new(
|
|
35
|
+
name: "",
|
|
36
|
+
description: "",
|
|
37
|
+
license: nil,
|
|
38
|
+
compatibility: nil,
|
|
39
|
+
metadata: {},
|
|
40
|
+
allowed_tools: []
|
|
41
|
+
).freeze
|
|
42
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "yaml"
|
|
4
|
+
|
|
5
|
+
module AgentSkillParser
|
|
6
|
+
# Parses YAML frontmatter into a {Frontmatter} object.
|
|
7
|
+
#
|
|
8
|
+
# @example Parse frontmatter
|
|
9
|
+
# parser = FrontmatterParser.new("name: my-skill\ndescription: A skill")
|
|
10
|
+
# parser.call # => Frontmatter.new(name: "my-skill", description: "A skill", ...)
|
|
11
|
+
class FrontmatterParser
|
|
12
|
+
# @param yaml_string [String] YAML content (may be empty)
|
|
13
|
+
def initialize(yaml_string)
|
|
14
|
+
@yaml_string = yaml_string
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# @return [Frontmatter] parsed frontmatter data
|
|
18
|
+
# @raise [Errors::Parser] if YAML is invalid
|
|
19
|
+
def call
|
|
20
|
+
return AgentSkillParser::NilFrontmatter if @yaml_string.empty?
|
|
21
|
+
|
|
22
|
+
data = parse_yaml
|
|
23
|
+
build_frontmatter(data)
|
|
24
|
+
rescue Psych::SyntaxError => e
|
|
25
|
+
raise Errors::Parser, "Invalid YAML: #{e.message}"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
# @return [Hash] parsed YAML data
|
|
31
|
+
def parse_yaml
|
|
32
|
+
YAML.safe_load(@yaml_string) || {}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @param data [Hash] raw YAML data
|
|
36
|
+
# @return [Frontmatter] constructed frontmatter
|
|
37
|
+
def build_frontmatter(data)
|
|
38
|
+
allowed_tools_data = data.delete("allowed-tools")
|
|
39
|
+
metadata_data = data.delete("metadata") || {}
|
|
40
|
+
|
|
41
|
+
Frontmatter.new(
|
|
42
|
+
name: data["name"] || "",
|
|
43
|
+
description: data["description"] || "",
|
|
44
|
+
license: data["license"],
|
|
45
|
+
compatibility: data["compatibility"],
|
|
46
|
+
metadata: coerce_metadata(metadata_data),
|
|
47
|
+
allowed_tools: parse_allowed_tools(allowed_tools_data)
|
|
48
|
+
)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# @param data [Object] metadata value
|
|
52
|
+
# @return [Hash{String => String}] stringified metadata
|
|
53
|
+
def coerce_metadata(data)
|
|
54
|
+
return {} unless data.is_a?(Hash)
|
|
55
|
+
|
|
56
|
+
data.transform_values(&:to_s).freeze
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# @param data [String, Array, nil] allowed-tools value
|
|
60
|
+
# @return [Array<AllowedTool>] parsed tool list
|
|
61
|
+
def parse_allowed_tools(data)
|
|
62
|
+
return [] if data.nil? || data.empty?
|
|
63
|
+
|
|
64
|
+
case data
|
|
65
|
+
when String
|
|
66
|
+
AllowedToolsParser.new(data).call
|
|
67
|
+
when Array
|
|
68
|
+
data.flat_map { |item| AllowedToolsParser.new(item.to_s).call }.freeze
|
|
69
|
+
else
|
|
70
|
+
[]
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AgentSkillParser
|
|
4
|
+
# Main parser that orchestrates the parsing pipeline.
|
|
5
|
+
#
|
|
6
|
+
# Pipeline stages:
|
|
7
|
+
# 1. {DocumentSplitter} - Split YAML frontmatter from body
|
|
8
|
+
# 2. {FrontmatterParser} - Parse YAML into {Frontmatter}
|
|
9
|
+
# 3. {Validator} - Validate frontmatter schema
|
|
10
|
+
# 4. Construct {Skill} object
|
|
11
|
+
#
|
|
12
|
+
# @example Parse a skill file
|
|
13
|
+
# parser = Parser.new("my_skill.md")
|
|
14
|
+
# skill = parser.call
|
|
15
|
+
# skill.name # => "my-skill"
|
|
16
|
+
# skill.body # => "# My Skill..."
|
|
17
|
+
class Parser
|
|
18
|
+
# @param file_path [String] path to skill file
|
|
19
|
+
def initialize(file_path)
|
|
20
|
+
@file_path = file_path
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# @return [Skill] parsed skill object
|
|
24
|
+
# @raise [Errors::Parser] if YAML is invalid or file cannot be read
|
|
25
|
+
# @raise [Errors::Validation] if frontmatter fails validation
|
|
26
|
+
# @raise [Errno::ENOENT] if file does not exist
|
|
27
|
+
def call
|
|
28
|
+
text = File.read(@file_path)
|
|
29
|
+
raw_yaml_document = DocumentSplitter.new(text).call
|
|
30
|
+
|
|
31
|
+
raise Errors::Parser, "Missing required YAML frontmatter" if raw_yaml_document.yaml_string.empty?
|
|
32
|
+
|
|
33
|
+
frontmatter = FrontmatterParser.new(raw_yaml_document.yaml_string).call
|
|
34
|
+
Validator.new(frontmatter).call
|
|
35
|
+
|
|
36
|
+
Skill.new(frontmatter: frontmatter, body: raw_yaml_document.body)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AgentSkillParser
|
|
4
|
+
# A parsed skill with frontmatter and body.
|
|
5
|
+
#
|
|
6
|
+
# @!attribute [r] frontmatter
|
|
7
|
+
# @return [Frontmatter] parsed metadata
|
|
8
|
+
# @!attribute [r] body
|
|
9
|
+
# @return [String] markdown content after frontmatter
|
|
10
|
+
#
|
|
11
|
+
# @example
|
|
12
|
+
# Skill.new(
|
|
13
|
+
# frontmatter: Frontmatter.new(name: "skill", description: "...", ...),
|
|
14
|
+
# body: "# My Skill\n\n..."
|
|
15
|
+
# )
|
|
16
|
+
Skill = Data.define(:frontmatter, :body) do
|
|
17
|
+
# @return [String] skill name (delegates to frontmatter)
|
|
18
|
+
# @see Frontmatter#name
|
|
19
|
+
def name
|
|
20
|
+
frontmatter.name
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# @return [String] skill description (delegates to frontmatter)
|
|
24
|
+
# @see Frontmatter#description
|
|
25
|
+
def description
|
|
26
|
+
frontmatter.description
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AgentSkillParser
|
|
4
|
+
# Validates frontmatter data against schema rules.
|
|
5
|
+
#
|
|
6
|
+
# @example Successful validation
|
|
7
|
+
# fm = Frontmatter.new(name: "skill", description: "A skill", ...)
|
|
8
|
+
# Validator.new(fm).call # => nil (no error)
|
|
9
|
+
#
|
|
10
|
+
# @example Failed validation
|
|
11
|
+
# fm = Frontmatter.new(name: "Bad Name!", description: "...", ...)
|
|
12
|
+
# Validator.new(fm).call # => raises Errors::Validation
|
|
13
|
+
#
|
|
14
|
+
# @see Errors::Validation
|
|
15
|
+
class Validator
|
|
16
|
+
# @return [Integer] maximum name length
|
|
17
|
+
NAME_MAX_LENGTH = 64
|
|
18
|
+
# @return [Integer] minimum name length
|
|
19
|
+
NAME_MIN_LENGTH = 1
|
|
20
|
+
# @return [Regexp] allowed name pattern
|
|
21
|
+
NAME_PATTERN = /\A[a-z0-9-]+\z/
|
|
22
|
+
# @return [Integer] maximum description length
|
|
23
|
+
DESCRIPTION_MAX_LENGTH = 1024
|
|
24
|
+
# @return [Integer] minimum description length
|
|
25
|
+
DESCRIPTION_MIN_LENGTH = 1
|
|
26
|
+
# @return [Integer] maximum compatibility length
|
|
27
|
+
COMPATIBILITY_MAX_LENGTH = 500
|
|
28
|
+
|
|
29
|
+
# @param frontmatter [Frontmatter] parsed frontmatter data
|
|
30
|
+
def initialize(frontmatter)
|
|
31
|
+
@frontmatter = frontmatter
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# @return [void]
|
|
35
|
+
# @raise [Errors::Validation] if validation fails
|
|
36
|
+
def call
|
|
37
|
+
validate_name
|
|
38
|
+
validate_description
|
|
39
|
+
validate_compatibility
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
# @return [void]
|
|
45
|
+
# @raise [Errors::Validation] if name is invalid
|
|
46
|
+
def validate_name
|
|
47
|
+
name = @frontmatter.name
|
|
48
|
+
|
|
49
|
+
raise Errors::Validation, "Name must be at least #{NAME_MIN_LENGTH} character(s)" if name.length < NAME_MIN_LENGTH
|
|
50
|
+
|
|
51
|
+
raise Errors::Validation, "Name must be at most #{NAME_MAX_LENGTH} characters" if name.length > NAME_MAX_LENGTH
|
|
52
|
+
|
|
53
|
+
unless name.match?(NAME_PATTERN)
|
|
54
|
+
raise Errors::Validation, "Name must contain only lowercase letters, numbers, and hyphens"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
raise Errors::Validation, "Name cannot contain consecutive hyphens" if name.include?("--")
|
|
58
|
+
|
|
59
|
+
return unless name.start_with?("-") || name.end_with?("-")
|
|
60
|
+
|
|
61
|
+
raise Errors::Validation, "Name cannot start or end with a hyphen"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# @return [void]
|
|
65
|
+
# @raise [Errors::Validation] if description is invalid
|
|
66
|
+
def validate_description
|
|
67
|
+
description = @frontmatter.description
|
|
68
|
+
|
|
69
|
+
if description.length < DESCRIPTION_MIN_LENGTH
|
|
70
|
+
raise Errors::Validation, "Description must be at least #{DESCRIPTION_MIN_LENGTH} character(s)"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
return unless description.length > DESCRIPTION_MAX_LENGTH
|
|
74
|
+
|
|
75
|
+
raise Errors::Validation, "Description must be at most #{DESCRIPTION_MAX_LENGTH} characters"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# @return [void]
|
|
79
|
+
# @raise [Errors::Validation] if compatibility is too long
|
|
80
|
+
def validate_compatibility
|
|
81
|
+
return if @frontmatter.compatibility.nil?
|
|
82
|
+
|
|
83
|
+
return unless @frontmatter.compatibility.length > COMPATIBILITY_MAX_LENGTH
|
|
84
|
+
|
|
85
|
+
raise Errors::Validation, "Compatibility must be at most #{COMPATIBILITY_MAX_LENGTH} characters"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "zeitwerk"
|
|
4
|
+
require "yaml"
|
|
5
|
+
|
|
6
|
+
loader = Zeitwerk::Loader.for_gem
|
|
7
|
+
loader.setup
|
|
8
|
+
|
|
9
|
+
# Parses skill files with YAML frontmatter and markdown body.
|
|
10
|
+
#
|
|
11
|
+
# Skill file format:
|
|
12
|
+
# ```yaml
|
|
13
|
+
# ---
|
|
14
|
+
# name: my-skill
|
|
15
|
+
# description: A helpful skill
|
|
16
|
+
# license: MIT
|
|
17
|
+
# compatibility: v1.2.3+
|
|
18
|
+
# metadata:
|
|
19
|
+
# author: Alice
|
|
20
|
+
# allowed-tools: bash, search_files(\.rb$)
|
|
21
|
+
# ---
|
|
22
|
+
# # My Skill
|
|
23
|
+
#
|
|
24
|
+
# Body content here...
|
|
25
|
+
# ```
|
|
26
|
+
#
|
|
27
|
+
# @example Parse a skill file
|
|
28
|
+
# skill = AgentSkillParser.parse("my_skill.md")
|
|
29
|
+
# skill.name # => "my-skill"
|
|
30
|
+
# skill.description # => "A helpful skill"
|
|
31
|
+
#
|
|
32
|
+
# @example Handle errors
|
|
33
|
+
# begin
|
|
34
|
+
# AgentSkillParser.parse("invalid.md")
|
|
35
|
+
# rescue AgentSkillParser::Errors::Parser => e
|
|
36
|
+
# puts "Parse error: #{e.message}"
|
|
37
|
+
# rescue AgentSkillParser::Errors::Validation => e
|
|
38
|
+
# puts "Validation error: #{e.message}"
|
|
39
|
+
# end
|
|
40
|
+
module AgentSkillParser
|
|
41
|
+
# @param file_path [String] path to skill file
|
|
42
|
+
# @return [Skill] parsed skill object
|
|
43
|
+
# @raise [Errors::Parser] if YAML is invalid or file cannot be read
|
|
44
|
+
# @raise [Errors::Validation] if frontmatter fails validation
|
|
45
|
+
# @raise [Errno::ENOENT] if file does not exist
|
|
46
|
+
# @see Parser#call
|
|
47
|
+
def self.parse(file_path)
|
|
48
|
+
Parser.new(file_path).call
|
|
49
|
+
end
|
|
50
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: agent_skill_parser
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Lucian Ghinda
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: zeitwerk
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.6'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '2.6'
|
|
26
|
+
description: A Ruby gem for parsing skill files that use YAML frontmatter and markdown
|
|
27
|
+
body content. Provides document splitting, YAML parsing, schema validation, and
|
|
28
|
+
returns immutable Skill objects. Designed for agent/AI systems where skills are
|
|
29
|
+
defined as structured markdown documents with metadata.
|
|
30
|
+
email:
|
|
31
|
+
- lucian@shortruby.com
|
|
32
|
+
executables: []
|
|
33
|
+
extensions: []
|
|
34
|
+
extra_rdoc_files: []
|
|
35
|
+
files:
|
|
36
|
+
- ".yardopts"
|
|
37
|
+
- CHANGELOG.md
|
|
38
|
+
- CODE_OF_CONDUCT.md
|
|
39
|
+
- LICENSE
|
|
40
|
+
- README.md
|
|
41
|
+
- Rakefile
|
|
42
|
+
- lib/agent_skill_parser.rb
|
|
43
|
+
- lib/agent_skill_parser/allowed_tool.rb
|
|
44
|
+
- lib/agent_skill_parser/allowed_tools_parser.rb
|
|
45
|
+
- lib/agent_skill_parser/document_splitter.rb
|
|
46
|
+
- lib/agent_skill_parser/errors.rb
|
|
47
|
+
- lib/agent_skill_parser/errors/base.rb
|
|
48
|
+
- lib/agent_skill_parser/errors/parser.rb
|
|
49
|
+
- lib/agent_skill_parser/errors/validation.rb
|
|
50
|
+
- lib/agent_skill_parser/frontmatter.rb
|
|
51
|
+
- lib/agent_skill_parser/frontmatter_parser.rb
|
|
52
|
+
- lib/agent_skill_parser/parser.rb
|
|
53
|
+
- lib/agent_skill_parser/skill.rb
|
|
54
|
+
- lib/agent_skill_parser/validator.rb
|
|
55
|
+
- lib/agent_skill_parser/version.rb
|
|
56
|
+
- sig/agent_skill_parser.rbs
|
|
57
|
+
homepage: https://github.com/lucianghinda/agent_skill_parser
|
|
58
|
+
licenses:
|
|
59
|
+
- MIT
|
|
60
|
+
metadata:
|
|
61
|
+
allowed_push_host: https://rubygems.org
|
|
62
|
+
homepage_uri: https://github.com/lucianghinda/agent_skill_parser
|
|
63
|
+
source_code_uri: https://github.com/lucianghinda/agent_skill_parser
|
|
64
|
+
changelog_uri: https://github.com/lucianghinda/agent_skill_parser/blob/main/CHANGELOG.md
|
|
65
|
+
rdoc_options: []
|
|
66
|
+
require_paths:
|
|
67
|
+
- lib
|
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
|
+
requirements:
|
|
70
|
+
- - ">="
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: 3.2.0
|
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
|
+
requirements:
|
|
75
|
+
- - ">="
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '0'
|
|
78
|
+
requirements: []
|
|
79
|
+
rubygems_version: 4.0.3
|
|
80
|
+
specification_version: 4
|
|
81
|
+
summary: Parse agent skill files with YAML frontmatter and markdown body for agent/AI
|
|
82
|
+
systems
|
|
83
|
+
test_files: []
|