@verevoir/recipes 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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — 2026-06-04
4
+
5
+ Initial release (STDIO-278).
6
+
7
+ - `parseSkill(idHint, raw)` — parse a recipe descriptor `.md` (flat frontmatter + instruction body) into a `SkillDescriptor`. Hand-written, no YAML dependency. Throws `SkillParseError` on a missing frontmatter fence, a missing required field (`id`/`name`/`description`), or an `id` that doesn't match the filename stem.
8
+ - `isReasoningSkill(skill)` — true when the recipe has no native `handler` (the ones worth exposing as prompts / inline-LLM tools).
9
+ - `renderSkillPrompt(skill, args)` — the instructions plus the supplied non-empty inputs, as the body a host model executes.
10
+ - Types: `SkillDescriptor`, `SkillInput`, `SkillInputType`, `SkillModelClass`, `SkillParseError`.
11
+
12
+ Extracted from the duplicated parsers in the aigency web app and `@verevoir/mcp` so both surfaces share one format definition. Zero runtime dependencies; ESM, Node >= 20.
package/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.
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # @verevoir/recipes
2
+
3
+ The **recipe-descriptor format and parser** — shared plumbing for every surface
4
+ that loads recipes. A recipe is a single `.md` file: flat frontmatter declaring
5
+ a parameterised procedure (typed inputs → instructions → a result), plus an
6
+ instruction body. A host compiles it to a chat-time tool, an MCP prompt, or runs
7
+ it inline.
8
+
9
+ Zero runtime dependencies. The parser is hand-written (no YAML dep), matching
10
+ the descriptor convention used across the foundation.
11
+
12
+ > This package is the **plumbing**, not the content. The recipes themselves
13
+ > (the instructions an LLM runs) live wherever a project keeps them — typically
14
+ > a guardrails repo — and are loaded at runtime. A different corpus is a
15
+ > different set of recipes, with no code change.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ npm install @verevoir/recipes
21
+ ```
22
+
23
+ ## The format
24
+
25
+ ```
26
+ ---
27
+ id: analyse_contract_risk
28
+ name: Analyse Contract Risk
29
+ description: Surface risky clauses with severity and mitigations.
30
+ tags: [contract, risk, legal]
31
+ model_class: reasoning
32
+ inputs:
33
+ - contract_text: string (required) — the full contract text to analyse
34
+ - party: string — which party you are advising
35
+ output: contract-risk — risk findings with severity, rationale, and mitigations
36
+ ---
37
+ You are a commercial contracts risk reviewer. Identify risky clauses…
38
+ ```
39
+
40
+ - `id` (required) — canonical id; must equal the filename stem.
41
+ - `name`, `description` (required) — human label + one-line summary.
42
+ - `tags` — inline list, for discovery.
43
+ - `model_class` — `reasoning` (default) or `extraction`; the tier an inline run uses.
44
+ - `inputs` — block list of `- <name>: <type> (required) — <description>`. Type defaults to `string`; `(required)` is optional; the em-dash (or `--`) precedes the description.
45
+ - `output` — `<kind> — <description>` of what the recipe produces.
46
+ - `handler` — when set, the recipe is **deterministic code** (e.g. `fetch_url`), not a reasoning prompt.
47
+ - `agent` — optional A2A endpoint an executor may delegate to.
48
+ - The body after the closing `---` is the instructions.
49
+
50
+ ## Usage
51
+
52
+ ```ts
53
+ import { parseSkill, isReasoningSkill, renderSkillPrompt } from '@verevoir/recipes';
54
+
55
+ const recipe = parseSkill('analyse_contract_risk', markdown);
56
+
57
+ // Reasoning recipes are the ones worth exposing as a prompt / inline tool;
58
+ // handler-backed ones are deterministic code the host usually already has.
59
+ if (isReasoningSkill(recipe)) {
60
+ // Render the prompt a host model executes: instructions + supplied inputs.
61
+ const prompt = renderSkillPrompt(recipe, { contract_text: text });
62
+ // → feed `prompt` to your model, or wrap as an MCP prompt / chat tool.
63
+ }
64
+ ```
65
+
66
+ `parseSkill` throws `SkillParseError` on a malformed descriptor (no frontmatter
67
+ fence, missing required field, or an `id` that doesn't match the filename).
68
+
69
+ ## API
70
+
71
+ - `parseSkill(idHint: string, raw: string): SkillDescriptor` — parse one descriptor.
72
+ - `isReasoningSkill(skill: SkillDescriptor): boolean` — true when there's no native `handler`.
73
+ - `renderSkillPrompt(skill, args): string` — instructions + the supplied non-empty inputs.
74
+ - Types: `SkillDescriptor`, `SkillInput`, `SkillInputType`, `SkillModelClass`, `SkillParseError`.
75
+
76
+ ## Naming
77
+
78
+ The function/type names keep the `Skill*` prefix (the descriptors originated as
79
+ Agent-Oriented-Architecture "skills"); the package is named **recipes** to avoid
80
+ collision with the host's _capability_ concept and with model-provider "Skills".
@@ -0,0 +1,57 @@
1
+ export declare class SkillParseError extends Error {
2
+ }
3
+ /** The model tier an inline (LLM) skill runs at. Named semantically on the
4
+ * descriptor (`model_class: reasoning | extraction`); absent → reasoning. */
5
+ export type SkillModelClass = 'reasoning' | 'extraction';
6
+ export type SkillInputType = 'string' | 'number' | 'boolean' | 'array' | 'object';
7
+ export interface SkillInput {
8
+ /** Argument name. */
9
+ name: string;
10
+ /** Declared type; defaults to `string`. */
11
+ type: SkillInputType;
12
+ /** Whether the argument is required. */
13
+ required: boolean;
14
+ /** Human description. */
15
+ description: string;
16
+ }
17
+ export interface SkillDescriptor {
18
+ /** Canonical id; matches the descriptor filename stem. */
19
+ id: string;
20
+ /** Human-facing capability name. */
21
+ name: string;
22
+ /** One-line capability summary. */
23
+ description: string;
24
+ /** Discovery tags. */
25
+ tags: string[];
26
+ /** Typed input contract. */
27
+ inputs: SkillInput[];
28
+ /** Standard output: a resource kind label + a description of what the skill
29
+ * produces. */
30
+ output: {
31
+ kind: string;
32
+ description: string;
33
+ };
34
+ /** Model tier for inline execution. Absent on the descriptor → reasoning. */
35
+ modelClass: SkillModelClass;
36
+ /** Native handler name. When set, the skill is deterministic code (e.g.
37
+ * `fetch_url`) rather than an LLM prompt. */
38
+ handler?: string;
39
+ /** Optional A2A agent endpoint the executor may delegate to. */
40
+ agentUrl?: string;
41
+ /** The instruction body — the system prompt for inline runs / the prompt a
42
+ * host model executes. */
43
+ instructions: string;
44
+ }
45
+ /** Parse a skill descriptor `.md` (frontmatter + instruction body) into a
46
+ * SkillDescriptor. Hand-parsed, no YAML dependency. `idHint` is the filename
47
+ * stem; the descriptor's `id` must match it. */
48
+ export declare function parseSkill(idHint: string, raw: string): SkillDescriptor;
49
+ /** Reasoning skills (no native handler) are the ones worth exposing as a
50
+ * prompt or inline-LLM tool; a handler-backed skill is deterministic code a
51
+ * host usually already has. */
52
+ export declare function isReasoningSkill(skill: SkillDescriptor): boolean;
53
+ /** Render the prompt body a host model executes: the skill's instructions
54
+ * followed by the supplied argument values. Only non-empty args are included,
55
+ * so optional arguments left blank don't clutter the prompt. */
56
+ export declare function renderSkillPrompt(skill: SkillDescriptor, args: Record<string, string | undefined>): string;
57
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwBA,qBAAa,eAAgB,SAAQ,KAAK;CAAG;AAE7C;6EAC6E;AAC7E,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,YAAY,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAElF,MAAM,WAAW,UAAU;IACzB,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,cAAc,CAAC;IACrB,wCAAwC;IACxC,QAAQ,EAAE,OAAO,CAAC;IAClB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,0DAA0D;IAC1D,EAAE,EAAE,MAAM,CAAC;IACX,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,4BAA4B;IAC5B,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB;mBACe;IACf,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,6EAA6E;IAC7E,UAAU,EAAE,eAAe,CAAC;IAC5B;iDAC6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;8BAC0B;IAC1B,YAAY,EAAE,MAAM,CAAC;CACtB;AAiGD;;gDAEgD;AAChD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,eAAe,CAkEvE;AAED;;+BAE+B;AAC/B,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAEhE;AAED;;gEAEgE;AAChE,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACvC,MAAM,CAUR"}
package/dist/index.js ADDED
@@ -0,0 +1,189 @@
1
+ // @verevoir/skills — the skill-descriptor format and parser, shared by every
2
+ // surface that loads skills: the aigency web app (compiles them to chat-time
3
+ // tools) and the MCP server (exposes the reasoning ones as prompts).
4
+ //
5
+ // A skill is a `.md` file with flat frontmatter + an instruction body. The
6
+ // frontmatter is deliberately flat so it parses without a YAML dependency.
7
+ // `inputs` is the one structured field — a block list of typed params — which
8
+ // maps to a tool's input_schema or a prompt's arguments.
9
+ //
10
+ // Example descriptor:
11
+ //
12
+ // ---
13
+ // id: evaluate_cv
14
+ // name: Evaluate CV
15
+ // description: Score a CV against role criteria.
16
+ // tags: [cv, evaluation]
17
+ // model_class: reasoning
18
+ // inputs:
19
+ // - cv_text: string (required) — the candidate's CV text
20
+ // - criteria: string — the role criteria to score against
21
+ // output: evaluation — per-criterion scores and a recommendation
22
+ // ---
23
+ // <instruction body…>
24
+ export class SkillParseError extends Error {
25
+ }
26
+ const REQUIRED_KEYS = ['id', 'name', 'description'];
27
+ const VALID_TYPES = new Set([
28
+ 'string',
29
+ 'number',
30
+ 'boolean',
31
+ 'array',
32
+ 'object',
33
+ ]);
34
+ function splitFrontmatter(raw) {
35
+ const lines = raw.split('\n');
36
+ if (lines[0]?.trim() !== '---') {
37
+ throw new SkillParseError("descriptor must begin with a '---' fence");
38
+ }
39
+ const end = lines.indexOf('---', 1);
40
+ if (end === -1) {
41
+ throw new SkillParseError("descriptor frontmatter has no closing '---'");
42
+ }
43
+ return {
44
+ frontmatter: lines.slice(1, end),
45
+ body: lines
46
+ .slice(end + 1)
47
+ .join('\n')
48
+ .trim(),
49
+ };
50
+ }
51
+ function scalarOrInlineList(value) {
52
+ const v = value.trim();
53
+ if (v.startsWith('[') && v.endsWith(']')) {
54
+ return v
55
+ .slice(1, -1)
56
+ .split(',')
57
+ .map((s) => unquote(s.trim()))
58
+ .filter(Boolean);
59
+ }
60
+ return unquote(v);
61
+ }
62
+ function unquote(value) {
63
+ const wrapped = (value.startsWith('"') && value.endsWith('"')) ||
64
+ (value.startsWith("'") && value.endsWith("'"));
65
+ return wrapped ? value.slice(1, -1) : value;
66
+ }
67
+ // Parse one `inputs:` block-list line into a SkillInput. Tolerant of an
68
+ // em-dash or a `--`/`-` description separator; defaults type to string.
69
+ // - <name>: <type> (required) — <description>
70
+ function parseInputLine(line) {
71
+ const item = line.trim().replace(/^-\s+/, '').trim();
72
+ if (!item)
73
+ return null;
74
+ const colon = item.indexOf(':');
75
+ if (colon === -1)
76
+ return null;
77
+ const name = item.slice(0, colon).trim();
78
+ const rest = item.slice(colon + 1).trim();
79
+ if (!name)
80
+ return null;
81
+ let description = '';
82
+ let meta = rest;
83
+ const dash = rest.search(/\s+(—|--)\s+/);
84
+ if (dash !== -1) {
85
+ meta = rest.slice(0, dash).trim();
86
+ description = rest.replace(/^.*?\s+(—|--)\s+/, '').trim();
87
+ }
88
+ const required = /\(required\)/i.test(meta);
89
+ const typeToken = meta
90
+ .replace(/\(required\)/i, '')
91
+ .trim()
92
+ .split(/\s+/)[0];
93
+ const type = VALID_TYPES.has(typeToken)
94
+ ? typeToken
95
+ : 'string';
96
+ return { name, type, required, description };
97
+ }
98
+ function parseOutput(value) {
99
+ const v = value.trim();
100
+ const dash = v.search(/\s+(—|--)\s+/);
101
+ if (dash === -1) {
102
+ return { kind: v || 'result', description: '' };
103
+ }
104
+ return {
105
+ kind: v.slice(0, dash).trim() || 'result',
106
+ description: v.replace(/^.*?\s+(—|--)\s+/, '').trim(),
107
+ };
108
+ }
109
+ /** Parse a skill descriptor `.md` (frontmatter + instruction body) into a
110
+ * SkillDescriptor. Hand-parsed, no YAML dependency. `idHint` is the filename
111
+ * stem; the descriptor's `id` must match it. */
112
+ export function parseSkill(idHint, raw) {
113
+ const { frontmatter, body } = splitFrontmatter(raw);
114
+ const scalars = {};
115
+ const tags = [];
116
+ const inputs = [];
117
+ for (let i = 0; i < frontmatter.length; i++) {
118
+ const line = frontmatter[i];
119
+ if (!line.trim())
120
+ continue;
121
+ if (line.trim() === 'inputs:') {
122
+ for (let j = i + 1; j < frontmatter.length; j++) {
123
+ const next = frontmatter[j];
124
+ if (!/^\s*-\s+/.test(next)) {
125
+ i = j - 1;
126
+ break;
127
+ }
128
+ const parsed = parseInputLine(next);
129
+ if (parsed)
130
+ inputs.push(parsed);
131
+ i = j;
132
+ }
133
+ continue;
134
+ }
135
+ const colon = line.indexOf(':');
136
+ if (colon === -1)
137
+ continue;
138
+ const key = line.slice(0, colon).trim();
139
+ const value = line.slice(colon + 1);
140
+ if (key === 'tags') {
141
+ const parsed = scalarOrInlineList(value);
142
+ if (Array.isArray(parsed))
143
+ tags.push(...parsed);
144
+ continue;
145
+ }
146
+ const parsed = scalarOrInlineList(value);
147
+ scalars[key] = Array.isArray(parsed) ? parsed.join(', ') : parsed;
148
+ }
149
+ for (const k of REQUIRED_KEYS) {
150
+ if (!scalars[k]) {
151
+ throw new SkillParseError(`descriptor missing required field: ${k}`);
152
+ }
153
+ }
154
+ if (scalars.id !== idHint) {
155
+ throw new SkillParseError(`skill id '${scalars.id}' does not match filename '${idHint}' — rename one to match`);
156
+ }
157
+ const modelClass = scalars.model_class?.trim() === 'extraction' ? 'extraction' : 'reasoning';
158
+ return {
159
+ id: scalars.id,
160
+ name: scalars.name,
161
+ description: scalars.description,
162
+ tags,
163
+ inputs,
164
+ output: parseOutput(scalars.output ?? ''),
165
+ modelClass,
166
+ handler: scalars.handler?.trim() || undefined,
167
+ agentUrl: scalars.agent?.trim() || undefined,
168
+ instructions: body,
169
+ };
170
+ }
171
+ /** Reasoning skills (no native handler) are the ones worth exposing as a
172
+ * prompt or inline-LLM tool; a handler-backed skill is deterministic code a
173
+ * host usually already has. */
174
+ export function isReasoningSkill(skill) {
175
+ return !skill.handler;
176
+ }
177
+ /** Render the prompt body a host model executes: the skill's instructions
178
+ * followed by the supplied argument values. Only non-empty args are included,
179
+ * so optional arguments left blank don't clutter the prompt. */
180
+ export function renderSkillPrompt(skill, args) {
181
+ const supplied = skill.inputs
182
+ .map((input) => ({ input, value: args[input.name]?.trim() }))
183
+ .filter((x) => x.value);
184
+ if (supplied.length === 0)
185
+ return skill.instructions;
186
+ const inputBlock = supplied.map(({ input, value }) => `### ${input.name}\n${value}`).join('\n\n');
187
+ return `${skill.instructions}\n\n---\n\n## Inputs\n\n${inputBlock}`;
188
+ }
189
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAC7E,qEAAqE;AACrE,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,8EAA8E;AAC9E,yDAAyD;AACzD,EAAE;AACF,sBAAsB;AACtB,EAAE;AACF,QAAQ;AACR,oBAAoB;AACpB,sBAAsB;AACtB,mDAAmD;AACnD,2BAA2B;AAC3B,2BAA2B;AAC3B,YAAY;AACZ,6DAA6D;AAC7D,8DAA8D;AAC9D,mEAAmE;AACnE,QAAQ;AACR,wBAAwB;AAExB,MA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AAI,SAAS;QAC7C,QAAQ,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,SAAS;QAC5C,YAAY,EAAE,IAAI;KACnB,CAAC;AACJ,CAAC;AAED;;+BAE+B;AAC/B,MAAM,UAAU,gBAAgB,CAAC,KAAsB;IACrD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;AACxB,CAAC;AAED;;gEAEgE;AAChE,MAAM,UAAU,iBAAiB,CAC/B,KAAsB,EACtB,IAAwC;IAExC,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM;SAC1B,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;SAC5D,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAE1B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,YAAY,CAAC;IAErD,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAElG,OAAO,GAAG,KAAK,CAAC,YAAY,2BAA2B,UAAU,EAAE,CAAC;AACtE,CAAC"}
package/llms.txt ADDED
@@ -0,0 +1,38 @@
1
+ # @verevoir/recipes
2
+
3
+ Recipe-descriptor format + zero-dependency parser. A recipe is a flat-frontmatter
4
+ `.md`: a parameterised procedure (typed inputs → instructions → result) a host
5
+ compiles to a chat-time tool, an MCP prompt, or runs inline. Plumbing only — the
6
+ recipe content lives in a project's corpus (e.g. a guardrails repo) and is loaded
7
+ at runtime; a different corpus is a different recipe set with no code change.
8
+
9
+ ## Format
10
+
11
+ `.md` with flat frontmatter (no YAML dep) + an instruction body:
12
+ - `id` (required, = filename stem), `name` (required), `description` (required)
13
+ - `tags`: inline list `[a, b]`
14
+ - `model_class`: `reasoning` (default) | `extraction`
15
+ - `inputs`: block list `- <name>: <type> (required) — <description>` (type defaults string)
16
+ - `output`: `<kind> — <description>`
17
+ - `handler`: present ⇒ deterministic code, not a reasoning prompt
18
+ - `agent`: optional A2A endpoint
19
+ - body after closing `---` = instructions
20
+
21
+ ## API
22
+
23
+ - `parseSkill(idHint, raw): SkillDescriptor` — throws `SkillParseError` on malformed input (no fence / missing required key / id≠filename).
24
+ - `isReasoningSkill(skill): boolean` — true when no `handler` (the ones worth exposing as prompts/inline tools).
25
+ - `renderSkillPrompt(skill, args): string` — instructions + supplied non-empty inputs, as the body a host model executes.
26
+ - Types: `SkillDescriptor`, `SkillInput` (`{name,type,required,description}`), `SkillInputType`, `SkillModelClass` (`'reasoning'|'extraction'`).
27
+
28
+ ## Consumers
29
+
30
+ The aigency web app (compiles recipes to chat tools) and `@verevoir/mcp` (exposes
31
+ reasoning recipes as MCP prompts) parse with this one library — one format, many
32
+ surfaces.
33
+
34
+ ## Notes
35
+
36
+ - ESM only, Node >= 20. Apache-2.0.
37
+ - Function/type names keep the `Skill*` prefix (AOA origin); the package is
38
+ `recipes` to avoid colliding with the host *capability* concept.
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@verevoir/recipes",
3
+ "version": "0.1.0",
4
+ "description": "Recipe-descriptor format + zero-dependency parser: a flat-frontmatter .md describes a parameterised procedure (typed inputs → instructions → result) that a host compiles to a chat-time tool or an MCP prompt.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE",
19
+ "llms.txt",
20
+ "CHANGELOG.md"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsc -p tsconfig.build.json",
24
+ "test": "vitest run",
25
+ "typecheck": "tsc --noEmit",
26
+ "lint": "prettier --check .",
27
+ "format": "prettier --write .",
28
+ "prepublishOnly": "npm run typecheck && npm test && npm run build"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^25.8.0",
32
+ "prettier": "^3",
33
+ "typescript": "^5",
34
+ "vitest": "^4"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/verevoir/recipes.git"
42
+ },
43
+ "engines": {
44
+ "node": ">=20"
45
+ }
46
+ }