@agentproto/skill 0.2.5 → 0.4.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/dist/{chunk-GZK4KIZA.mjs → chunk-GK7XBTUG.mjs} +26 -5
- package/dist/chunk-GK7XBTUG.mjs.map +1 -0
- package/dist/index.d.ts +27 -4
- package/dist/index.mjs +27 -3
- package/dist/index.mjs.map +1 -1
- package/dist/manifest/index.d.ts +2 -2
- package/dist/manifest/index.mjs +1 -26
- package/dist/manifest/index.mjs.map +1 -1
- package/dist/{schema-yW7X0mwK.d.ts → schema-h9EAqfDv.d.ts} +10 -4
- package/package.json +3 -2
- package/dist/chunk-GZK4KIZA.mjs.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import matter from 'gray-matter';
|
|
1
2
|
import { z } from 'zod';
|
|
2
|
-
import { createDoctype } from '@agentproto/
|
|
3
|
+
import { createDoctype } from '@agentproto/doctype';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* @agentproto/skill v0.1.0-alpha
|
|
@@ -33,7 +34,9 @@ var executionSchema = z.object({
|
|
|
33
34
|
dependencies: z.record(z.string(), z.string()).optional()
|
|
34
35
|
}).strict().describe("Executable bindings. Required when variant=executable.");
|
|
35
36
|
var aip3ExtensionsSchema = z.object({
|
|
36
|
-
schema: z.
|
|
37
|
+
schema: z.enum(["skill/v1", "skills/v1"]).describe(
|
|
38
|
+
"Schema dispatch tag. Required for AIP-3 conformance. `skills/v1` is accepted as a legacy alias (AIP-70)."
|
|
39
|
+
),
|
|
37
40
|
variant: z.enum(["instruction", "executable", "composite"]).default("instruction").describe(
|
|
38
41
|
"Skill variant. `instruction` is prose-only (default); `executable` bundles runnable code via `execution`; `composite` references other skills via `uses`."
|
|
39
42
|
),
|
|
@@ -108,6 +111,24 @@ var defineSkill = createDoctype({
|
|
|
108
111
|
}
|
|
109
112
|
});
|
|
110
113
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
// src/manifest/index.ts
|
|
115
|
+
function parseSkillManifest(source) {
|
|
116
|
+
const parsed = matter(source);
|
|
117
|
+
if (Object.keys(parsed.data).length === 0) {
|
|
118
|
+
throw new Error("parseSkillManifest: missing or empty frontmatter");
|
|
119
|
+
}
|
|
120
|
+
const result = skillFrontmatterSchema.safeParse(parsed.data);
|
|
121
|
+
if (!result.success) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
`parseSkillManifest: invalid frontmatter \u2014 ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
return { frontmatter: result.data, body: parsed.content };
|
|
127
|
+
}
|
|
128
|
+
function skillFromManifest(manifest) {
|
|
129
|
+
return defineSkill(manifest.frontmatter);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { aip3ExtensionsSchema, defineSkill, parseSkillManifest, skillFromManifest, skillFrontmatterSchema };
|
|
133
|
+
//# sourceMappingURL=chunk-GK7XBTUG.mjs.map
|
|
134
|
+
//# sourceMappingURL=chunk-GK7XBTUG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema.ts","../src/define-skill.ts","../src/manifest/index.ts"],"names":[],"mappings":";;;;;;;;;AAuBA,IAAM,YAAA,GAAe,mDAAA;AAErB,IAAM,cAAA,GAAiB,wCAAA;AACvB,IAAM,WAAA,GAAc,mBAAA;AAEpB,IAAM,eAAA,GAAkB,EACrB,MAAA,CAAO;AAAA,EACN,QAAA,EAAU,CAAA,CACP,IAAA,CAAK,CAAC,YAAA,EAAc,YAAA,EAAc,QAAA,EAAU,OAAO,CAAC,CAAA,CACpD,QAAA,CAAS,4EAA4E,CAAA;AAAA,EACxF,IAAA,EAAM,EACH,KAAA,CAAM;AAAA,IACL,EACG,MAAA,CAAO;AAAA,MACN,MAAM,CAAA,CACH,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CAC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,KAAK,GAAG,CAAC,KAAK,CAAA,CAAE,OAAO,EAAE,CAAA,CAC9C,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,KACf;AAAA,EACF;AACA,EAAA,OAAO,EAAE,WAAA,EAAa,MAAA,CAAO,IAAA,EAAM,IAAA,EAAM,OAAO,OAAA,EAAQ;AAC1D;AAEO,SAAS,kBAAkB,QAAA,EAAsC;AAKtE,EAAA,OAAO,WAAA,CAAY,SAAS,WAAyC,CAAA;AACvE","file":"chunk-GK7XBTUG.mjs","sourcesContent":["/**\n * AIP-3 SKILL.md frontmatter zod schema.\n *\n * Mirrors `resources/aip-3/draft/SKILL.schema.json` field-for-field.\n * AIP-3 is a profile of agentskills.io — top-level fields are the\n * canonical agentskills.io frontmatter; AIP-3 extensions live under\n * `metadata.aip3.*` so a skill authored against AIP-3 remains a valid\n * agentskills.io skill in any conformant runtime.\n *\n * Both authoring paths (`define-skill.ts` for TS-authored skills and\n * `manifest/index.ts` for SKILL.md parsing) validate against this\n * schema, so every field-level constraint runs in both paths from a\n * single source of truth.\n *\n * Cross-field rules (variant=executable ⇒ execution required;\n * variant=composite ⇒ uses non-empty) live in `define-skill.ts`'s\n * `validate(def)` body — they're harder to encode in a flat zod\n * schema and want a single error path.\n */\n\nimport { z } from \"zod\"\n\n/** agentskills.io `name` rule: 1–64, kebab, no leading/trailing/consecutive `-`. */\nconst NAME_PATTERN = /^[a-z0-9](?:[a-z0-9]|-(?!-))*[a-z0-9]$|^[a-z0-9]$/\n\nconst SEMVER_PATTERN = /^\\d+\\.\\d+\\.\\d+(?:[-+][a-zA-Z0-9.-]+)?$/\nconst TAG_PATTERN = /^[a-z][a-z0-9-]*$/\n\nconst executionSchema = z\n .object({\n language: z\n .enum([\"typescript\", \"javascript\", \"python\", \"shell\"])\n .describe(\"Implementation language. Runtimes MAY refuse languages they don't support.\"),\n code: z\n .union([\n z\n .object({\n file: z\n .string()\n .min(1)\n .describe(\n \"Relative path to the entry file. SHOULD live under `scripts/`. Path traversal segments escaping the skill dir MUST be rejected.\",\n ),\n })\n .strict(),\n z\n .object({\n inline: z\n .string()\n .describe(\"Inline source. Runtimes MUST sandbox before executing.\"),\n })\n .strict(),\n ])\n .describe(\"Exactly one of { file } or { inline }. File paths are relative to SKILL.md.\"),\n entrypoint: z.string().min(1).optional(),\n runtime: z\n .object({\n provider: z.string().optional(),\n timeout: z.number().int().positive().optional(),\n memory: z.string().optional(),\n })\n .strict()\n .optional(),\n artifacts: z\n .object({\n patterns: z.array(z.string()).min(1),\n })\n .strict()\n .optional(),\n dependencies: z.record(z.string(), z.string()).optional(),\n })\n .strict()\n .describe(\"Executable bindings. Required when variant=executable.\")\n\nexport const aip3ExtensionsSchema = z\n .object({\n schema: z\n .enum([\"skill/v1\", \"skills/v1\"])\n .describe(\n \"Schema dispatch tag. Required for AIP-3 conformance. `skills/v1` is accepted as a legacy alias (AIP-70).\",\n ),\n variant: z\n .enum([\"instruction\", \"executable\", \"composite\"])\n .default(\"instruction\")\n .describe(\n \"Skill variant. `instruction` is prose-only (default); `executable` bundles runnable code via `execution`; `composite` references other skills via `uses`.\",\n ),\n version: z\n .string()\n .regex(SEMVER_PATTERN)\n .optional()\n .describe(\"Semver. Bump on breaking changes to the skill's behavior or required tools.\"),\n tags: z\n .array(z.string().regex(TAG_PATTERN))\n .max(12)\n .default([])\n .describe(\"Catalog tags. Lowercase kebab-case; no leading symbols. 3–6 tags is typical.\"),\n category: z\n .string()\n .min(1)\n .max(64)\n .optional()\n .describe(\n \"Coarse grouping (e.g. 'productivity', 'creative', 'development'). Free-form; runtimes SHOULD NOT enumerate.\",\n ),\n requires: z\n .array(z.number().int().positive())\n .default([])\n .describe(\n \"Other AIPs this skill depends on (e.g. `[9]` for the operator runtime). Runtimes MAY warn when a declared dependency is unsupported.\",\n ),\n author: z\n .string()\n .max(200)\n .optional()\n .describe(\n \"Optional. Conventional shape: 'Name <email>' or stable handle. Mirrors agentskills.io's `metadata.author` convention; if both are present, `metadata.aip3.author` wins for AIP-3 runtimes.\",\n ),\n title: z\n .string()\n .min(1)\n .max(120)\n .optional()\n .describe(\n \"Optional human-readable display title. Headless runtimes that can't render the body H1 MAY use this. The body H1 is preferred.\",\n ),\n uses: z\n .array(z.string().regex(NAME_PATTERN))\n .default([])\n .describe(\n \"Skill names this skill composes with. Required and non-empty when variant=composite.\",\n ),\n execution: executionSchema.optional(),\n })\n .loose()\n\nexport const skillFrontmatterSchema = z\n .object({\n name: z\n .string()\n .min(1)\n .max(64)\n .regex(NAME_PATTERN)\n .describe(\n \"Machine identifier. 1–64 chars, lowercase alphanumeric and hyphens only, no leading/trailing/consecutive hyphens. MUST equal the parent directory name. Inherited verbatim from agentskills.io.\",\n ),\n description: z\n .string()\n .min(1)\n .max(1024)\n .describe(\n \"One-paragraph purpose. SHOULD describe both what the skill does and when to use it. Inherited from agentskills.io (1024-char cap).\",\n ),\n license: z\n .string()\n .max(200)\n .optional()\n .describe(\n \"Optional. License identifier (SPDX or pointer to a bundled license file). Inherited from agentskills.io.\",\n ),\n compatibility: z\n .string()\n .min(1)\n .max(500)\n .optional()\n .describe(\n \"Optional. Free-form environment requirements: intended product, system packages, network access, etc. Most skills omit this.\",\n ),\n \"allowed-tools\": z\n .string()\n .optional()\n .describe(\n \"Optional. Space-separated list of pre-approved tool patterns (e.g. 'Bash(git:*) Read'). Experimental upstream — runtimes MAY ignore. The field is a request, not a grant.\",\n ),\n metadata: z\n .object({ aip3: aip3ExtensionsSchema.optional() })\n .loose()\n .default({})\n .describe(\n \"Free-form key-value mapping. Hosts and standards stash extension fields under namespaced keys (e.g. `metadata.aip3.*`, `metadata.acme.*`). Inherited from agentskills.io.\",\n ),\n })\n .loose()\n .describe(\n \"Validates the YAML frontmatter portion of an AIP-3 SKILL.md manifest. AIP-3 is a profile of agentskills.io.\",\n )\n\nexport type SkillFrontmatter = z.infer<typeof skillFrontmatterSchema>\nexport type Aip3Extensions = z.infer<typeof aip3ExtensionsSchema>\n","import { createDoctype } from \"@agentproto/doctype\"\nimport { skillFrontmatterSchema } from \"./schema.js\"\nimport type { SkillDefinition, SkillHandle } from \"./types.js\"\n\n/**\n * AIP-3 reference implementation of `defineSkill`.\n *\n * Built on `createDoctype` so the cross-AIP invariants (id pattern,\n * description length, top-level freeze, \"defineSkill (AIP-3): …\"\n * error prefix) run uniformly with every other AIP defineX.\n *\n * Field-level validation runs the schema-derived zod from\n * `./schema.ts` against the input. Same source of truth as the .md\n * path uses (`parseSkillManifest`), so a malformed TS-authored\n * definition fails with the same diagnostic as a malformed manifest.\n *\n * Cross-field rules — variant=executable requires `metadata.aip3.execution`;\n * variant=composite requires non-empty `metadata.aip3.uses` — run after\n * the zod check so callers see one consistent error path.\n *\n * Identity / description extractors detected from the JSON Schema:\n * readIdentity: def.name\n * readDescription: def.description.\n */\nexport const defineSkill = createDoctype<SkillDefinition, SkillHandle>({\n aip: 3,\n name: \"skill\",\n readIdentity: (def) => def.name,\n validate(def) {\n const result = skillFrontmatterSchema.safeParse(def)\n if (!result.success) {\n throw new Error(\n `defineSkill (AIP-3): ${result.error.issues\n .map((i) => `${i.path.join(\".\")}: ${i.message}`)\n .join(\"; \")}`,\n )\n }\n\n const aip3 = result.data.metadata?.aip3\n if (!aip3) return\n\n const variant = aip3.variant ?? \"instruction\"\n if (variant === \"executable\" && !aip3.execution) {\n throw new Error(\n \"defineSkill (AIP-3): metadata.aip3.execution is required when metadata.aip3.variant=executable\",\n )\n }\n if (variant === \"composite\" && (!aip3.uses || aip3.uses.length === 0)) {\n throw new Error(\n \"defineSkill (AIP-3): metadata.aip3.uses must be non-empty when metadata.aip3.variant=composite\",\n )\n }\n },\n build(def) {\n return { ...def } as SkillHandle\n },\n})\n","/**\n * AIP-3 SKILL.md sidecar parser + manifest-to-handle constructor.\n *\n * Mirror of `@agentproto/tool/manifest` and `@agentproto/driver/manifest`:\n * the .md provides metadata; the TS module supplies any spec-specific\n * runtime bits (schemas, execute bodies, …) that can't live in\n * frontmatter. Both inputs end up in `defineSkill` so the cross-AIP\n * invariants run uniformly.\n *\n *\n * The frontmatter zod schema below was generated from\n * `resources/aip-3/draft/SKILL.schema.json` via json-schema-to-zod.\n * Re-run scaffold-aip to refresh after spec changes (or hand-tune\n * any constraint the converter doesn't capture cleanly).\n */\n\nimport matter from \"gray-matter\"\nimport { skillFrontmatterSchema, type SkillFrontmatter } from \"../schema.js\"\nimport { defineSkill } from \"../define-skill.js\"\nimport type { SkillDefinition, SkillHandle } from \"../types.js\"\n\n// Re-export so consumers can import the schema + inferred type either\n// from \"@@agentproto/skill/manifest\" or directly from \"@@agentproto/skill/schema\".\nexport { skillFrontmatterSchema, type SkillFrontmatter }\n\nexport interface SkillManifest {\n frontmatter: SkillFrontmatter\n body: string\n}\n\nexport function parseSkillManifest(source: string): SkillManifest {\n const parsed = matter(source)\n if (Object.keys(parsed.data).length === 0) {\n throw new Error(\"parseSkillManifest: missing or empty frontmatter\")\n }\n const result = skillFrontmatterSchema.safeParse(parsed.data)\n if (!result.success) {\n throw new Error(\n `parseSkillManifest: invalid frontmatter — ${result.error.issues\n .map((i) => `${i.path.join(\".\")}: ${i.message}`)\n .join(\"; \")}`,\n )\n }\n return { frontmatter: result.data, body: parsed.content }\n}\n\nexport function skillFromManifest(manifest: SkillManifest): SkillHandle {\n // The zod-validated frontmatter is structurally compatible with\n // SkillDefinition; the cast pins the typing once the manifest\n // schema and the TS interface diverge (e.g. handle has frozen fields\n // a literal config doesn't carry yet).\n return defineSkill(manifest.frontmatter as unknown as SkillDefinition)\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { S as SkillDefinition } from './schema-
|
|
2
|
-
export { A as Aip3Extensions,
|
|
1
|
+
import { S as SkillDefinition, a as SkillHandle } from './schema-h9EAqfDv.js';
|
|
2
|
+
export { A as Aip3Extensions, b as SkillExecution, c as SkillExecutionLanguage, d as SkillFrontmatter, e as SkillVariant, f as aip3ExtensionsSchema, s as skillFrontmatterSchema } from './schema-h9EAqfDv.js';
|
|
3
|
+
import * as _agentproto_manifest from '@agentproto/manifest';
|
|
4
|
+
import { DoctypeSpec } from '@agentproto/manifest';
|
|
3
5
|
import 'zod';
|
|
4
6
|
|
|
5
7
|
/**
|
|
@@ -24,6 +26,27 @@ import 'zod';
|
|
|
24
26
|
*/
|
|
25
27
|
declare const defineSkill: (def: SkillDefinition) => Readonly<SkillDefinition>;
|
|
26
28
|
|
|
29
|
+
/**
|
|
30
|
+
* A skill handle paired with its SKILL.md body (AIP-3). The body is the
|
|
31
|
+
* instructions text, which is not frontmatter, so it travels with the handle
|
|
32
|
+
* (same shape idea as AIP-42's `AgentEntry`, with the body mandatory).
|
|
33
|
+
*/
|
|
34
|
+
interface SkillEntry {
|
|
35
|
+
readonly skill: SkillHandle;
|
|
36
|
+
readonly body: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Render a SKILL.md. The frontmatter is the handle as agentskills.io spells it
|
|
41
|
+
* (AIP-3 is a profile of it, so no top-level `schema` key); the dispatch tag
|
|
42
|
+
* under `metadata.aip3.schema` is written as the canonical `skill/v1`, never
|
|
43
|
+
* the legacy `skills/v1`.
|
|
44
|
+
*/
|
|
45
|
+
declare function renderSkillMd(entry: SkillEntry): string;
|
|
46
|
+
|
|
47
|
+
declare const skillSpec: DoctypeSpec<SkillDefinition, SkillHandle>;
|
|
48
|
+
declare const skillVerbs: _agentproto_manifest.Verbs<SkillDefinition, Readonly<SkillDefinition>>;
|
|
49
|
+
|
|
27
50
|
/**
|
|
28
51
|
* @agentproto/skill — AIP-3 SKILL.md `defineSkill` reference impl.
|
|
29
52
|
*
|
|
@@ -35,7 +58,7 @@ declare const defineSkill: (def: SkillDefinition) => Readonly<SkillDefinition>;
|
|
|
35
58
|
* - TS: `defineSkill({...})` → `SkillHandle`
|
|
36
59
|
* - MD: `parseSkillManifest(src) → skillFromManifest({...})` → `SkillHandle`
|
|
37
60
|
*/
|
|
38
|
-
declare const SPEC_NAME: "
|
|
61
|
+
declare const SPEC_NAME: "skill/v1";
|
|
39
62
|
declare const SPEC_VERSION: "2.0.0-alpha";
|
|
40
63
|
|
|
41
|
-
export { SPEC_NAME, SPEC_VERSION, SkillDefinition, defineSkill };
|
|
64
|
+
export { SPEC_NAME, SPEC_VERSION, SkillDefinition, type SkillEntry, SkillHandle, defineSkill, renderSkillMd, skillSpec, skillVerbs };
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import { defineSkill, parseSkillManifest } from './chunk-GK7XBTUG.mjs';
|
|
2
|
+
export { aip3ExtensionsSchema, defineSkill, skillFrontmatterSchema } from './chunk-GK7XBTUG.mjs';
|
|
3
|
+
import matter from 'gray-matter';
|
|
4
|
+
import { createVerbs } from '@agentproto/manifest';
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* @agentproto/skill v0.1.0-alpha
|
|
5
8
|
* AIP-3 SKILL.md `defineSkill` reference implementation.
|
|
6
9
|
*/
|
|
10
|
+
function renderSkillMd(entry) {
|
|
11
|
+
const data = JSON.parse(JSON.stringify(entry.skill));
|
|
12
|
+
const aip3 = data.metadata?.aip3;
|
|
13
|
+
if (aip3?.schema === "skills/v1") aip3.schema = "skill/v1";
|
|
14
|
+
return matter.stringify(`
|
|
15
|
+
${entry.body.trim()}
|
|
16
|
+
`, data);
|
|
17
|
+
}
|
|
18
|
+
var skillSpec = {
|
|
19
|
+
name: "skill",
|
|
20
|
+
aip: 3,
|
|
21
|
+
schemaLiteral: "skill/v1",
|
|
22
|
+
pathOf: (h) => `skills/${h.name}/SKILL.md`,
|
|
23
|
+
define: defineSkill,
|
|
24
|
+
render: (handle, body) => renderSkillMd({ skill: handle, body: body ?? "" }),
|
|
25
|
+
parse: (source) => {
|
|
26
|
+
const m = parseSkillManifest(source);
|
|
27
|
+
return { frontmatter: structuredClone(matter(source).data), body: m.body };
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var skillVerbs = createVerbs(skillSpec);
|
|
7
31
|
|
|
8
32
|
// src/index.ts
|
|
9
|
-
var SPEC_NAME = "
|
|
33
|
+
var SPEC_NAME = "skill/v1";
|
|
10
34
|
var SPEC_VERSION = "2.0.0-alpha";
|
|
11
35
|
|
|
12
|
-
export { SPEC_NAME, SPEC_VERSION };
|
|
36
|
+
export { SPEC_NAME, SPEC_VERSION, renderSkillMd, skillSpec, skillVerbs };
|
|
13
37
|
//# sourceMappingURL=index.mjs.map
|
|
14
38
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/render.ts","../src/spec.ts","../src/index.ts"],"names":["matter"],"mappings":";;;;;;;;;AASO,SAAS,cAAc,KAAA,EAA2B;AACvD,EAAA,MAAM,OAAO,IAAA,CAAK,KAAA,CAAM,KAAK,SAAA,CAAU,KAAA,CAAM,KAAK,CAAC,CAAA;AAGnD,EAAA,MAAM,IAAA,GAAO,KAAK,QAAA,EAAU,IAAA;AAC5B,EAAA,IAAI,IAAA,EAAM,MAAA,KAAW,WAAA,EAAa,IAAA,CAAK,MAAA,GAAS,UAAA;AAChD,EAAA,OAAO,OAAO,SAAA,CAAU;AAAA,EAAK,KAAA,CAAM,IAAA,CAAK,IAAA,EAAM;AAAA,CAAA,EAAM,IAAI,CAAA;AAC1D;ACHO,IAAM,SAAA,GAAuD;AAAA,EAClE,IAAA,EAAM,OAAA;AAAA,EACN,GAAA,EAAK,CAAA;AAAA,EACL,aAAA,EAAe,UAAA;AAAA,EACf,MAAA,EAAQ,CAAC,CAAA,KAAM,CAAA,OAAA,EAAU,EAAE,IAAI,CAAA,SAAA,CAAA;AAAA,EAC/B,MAAA,EAAQ,WAAA;AAAA,EACR,MAAA,EAAQ,CAAC,MAAA,EAAQ,IAAA,KAAS,aAAA,CAAc,EAAE,KAAA,EAAO,MAAA,EAAQ,IAAA,EAAM,IAAA,IAAQ,EAAA,EAAI,CAAA;AAAA,EAC3E,KAAA,EAAO,CAAC,MAAA,KAAW;AACjB,IAAA,MAAM,CAAA,GAAI,mBAAmB,MAAM,CAAA;AAGnC,IAAA,OAAO,EAAE,WAAA,EAAa,eAAA,CAAgBA,MAAAA,CAAO,MAAM,EAAE,IAAI,CAAA,EAAG,IAAA,EAAM,CAAA,CAAE,IAAA,EAAK;AAAA,EAC3E;AACF;AAEO,IAAM,UAAA,GAAa,YAAY,SAAS;;;AChBxC,IAAM,SAAA,GAAY;AAClB,IAAM,YAAA,GAAe","file":"index.mjs","sourcesContent":["import matter from \"gray-matter\"\nimport type { SkillEntry } from \"./entry.js\"\n\n/**\n * Render a SKILL.md. The frontmatter is the handle as agentskills.io spells it\n * (AIP-3 is a profile of it, so no top-level `schema` key); the dispatch tag\n * under `metadata.aip3.schema` is written as the canonical `skill/v1`, never\n * the legacy `skills/v1`.\n */\nexport function renderSkillMd(entry: SkillEntry): string {\n const data = JSON.parse(JSON.stringify(entry.skill)) as {\n metadata?: { aip3?: { schema?: string } }\n }\n const aip3 = data.metadata?.aip3\n if (aip3?.schema === \"skills/v1\") aip3.schema = \"skill/v1\"\n return matter.stringify(`\\n${entry.body.trim()}\\n`, data)\n}\n","/**\n * AIP-3 doctype spec — fed to `@agentproto/manifest.createVerbs` to derive\n * create / load / list / update / resolve / delete in one place. A skill\n * lives at `<dir>/skills/<name>/SKILL.md`.\n */\n\nimport { createVerbs, type DoctypeSpec } from \"@agentproto/manifest\"\nimport matter from \"gray-matter\"\nimport { defineSkill } from \"./define-skill.js\"\nimport { parseSkillManifest } from \"./manifest/index.js\"\nimport { renderSkillMd } from \"./render.js\"\nimport type { SkillDefinition, SkillHandle } from \"./types.js\"\n\nexport const skillSpec: DoctypeSpec<SkillDefinition, SkillHandle> = {\n name: \"skill\",\n aip: 3,\n schemaLiteral: \"skill/v1\",\n pathOf: (h) => `skills/${h.name}/SKILL.md`,\n define: defineSkill,\n render: (handle, body) => renderSkillMd({ skill: handle, body: body ?? \"\" }),\n parse: (source) => {\n const m = parseSkillManifest(source)\n // Validated above; the file's own fields come back, so an update does not\n // write schema defaults into a file that never carried them.\n return { frontmatter: structuredClone(matter(source).data), body: m.body }\n },\n}\n\nexport const skillVerbs = createVerbs(skillSpec)\n","/**\n * @agentproto/skill — AIP-3 SKILL.md `defineSkill` reference impl.\n *\n * A markdown + frontmatter format for distributing reusable agent skills as portable, version-controlled files.\n *\n * Spec: https://agentproto.sh/docs/aip-3\n *\n * Authoring paths:\n * - TS: `defineSkill({...})` → `SkillHandle`\n * - MD: `parseSkillManifest(src) → skillFromManifest({...})` → `SkillHandle`\n */\n\nexport const SPEC_NAME = \"skill/v1\" as const\nexport const SPEC_VERSION = \"2.0.0-alpha\" as const\n\nexport { defineSkill } from \"./define-skill.js\"\nexport { renderSkillMd } from \"./render.js\"\nexport { skillSpec, skillVerbs } from \"./spec.js\"\nexport { skillFrontmatterSchema, aip3ExtensionsSchema } from \"./schema.js\"\nexport type { SkillFrontmatter, Aip3Extensions } from \"./schema.js\"\nexport type { SkillEntry } from \"./entry.js\"\nexport type {\n SkillDefinition,\n SkillHandle,\n SkillVariant,\n SkillExecution,\n SkillExecutionLanguage,\n} from \"./types.js\"\n"]}
|
package/dist/manifest/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { s as skillFrontmatterSchema } from '../schema-
|
|
1
|
+
import { d as SkillFrontmatter, a as SkillHandle } from '../schema-h9EAqfDv.js';
|
|
2
|
+
export { s as skillFrontmatterSchema } from '../schema-h9EAqfDv.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/manifest/index.mjs
CHANGED
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export { skillFrontmatterSchema } from '../chunk-GZK4KIZA.mjs';
|
|
3
|
-
import matter from 'gray-matter';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @agentproto/skill v0.1.0-alpha
|
|
7
|
-
* AIP-3 SKILL.md `defineSkill` reference implementation.
|
|
8
|
-
*/
|
|
9
|
-
function parseSkillManifest(source) {
|
|
10
|
-
const parsed = matter(source);
|
|
11
|
-
if (Object.keys(parsed.data).length === 0) {
|
|
12
|
-
throw new Error("parseSkillManifest: missing or empty frontmatter");
|
|
13
|
-
}
|
|
14
|
-
const result = skillFrontmatterSchema.safeParse(parsed.data);
|
|
15
|
-
if (!result.success) {
|
|
16
|
-
throw new Error(
|
|
17
|
-
`parseSkillManifest: invalid frontmatter \u2014 ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
return { frontmatter: result.data, body: parsed.content };
|
|
21
|
-
}
|
|
22
|
-
function skillFromManifest(manifest) {
|
|
23
|
-
return defineSkill(manifest.frontmatter);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { parseSkillManifest, skillFromManifest };
|
|
1
|
+
export { parseSkillManifest, skillFromManifest, skillFrontmatterSchema } from '../chunk-GK7XBTUG.mjs';
|
|
27
2
|
//# sourceMappingURL=index.mjs.map
|
|
28
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
|
@@ -39,7 +39,7 @@ interface SkillExecution {
|
|
|
39
39
|
/** AIP-3 extensions to the agentskills.io baseline. Lives under `metadata.aip3`. */
|
|
40
40
|
interface Aip3Extensions$1 {
|
|
41
41
|
/** Schema dispatch tag. Required for AIP-3 conformance. */
|
|
42
|
-
schema: "skills/v1";
|
|
42
|
+
schema: "skill/v1" | "skills/v1";
|
|
43
43
|
/** Skill variant. Defaults to "instruction" when omitted. */
|
|
44
44
|
variant?: SkillVariant;
|
|
45
45
|
/** Semver. */
|
|
@@ -110,7 +110,10 @@ type SkillHandle = Readonly<SkillDefinition>;
|
|
|
110
110
|
*/
|
|
111
111
|
|
|
112
112
|
declare const aip3ExtensionsSchema: z.ZodObject<{
|
|
113
|
-
schema: z.
|
|
113
|
+
schema: z.ZodEnum<{
|
|
114
|
+
"skill/v1": "skill/v1";
|
|
115
|
+
"skills/v1": "skills/v1";
|
|
116
|
+
}>;
|
|
114
117
|
variant: z.ZodDefault<z.ZodEnum<{
|
|
115
118
|
instruction: "instruction";
|
|
116
119
|
executable: "executable";
|
|
@@ -155,7 +158,10 @@ declare const skillFrontmatterSchema: z.ZodObject<{
|
|
|
155
158
|
"allowed-tools": z.ZodOptional<z.ZodString>;
|
|
156
159
|
metadata: z.ZodDefault<z.ZodObject<{
|
|
157
160
|
aip3: z.ZodOptional<z.ZodObject<{
|
|
158
|
-
schema: z.
|
|
161
|
+
schema: z.ZodEnum<{
|
|
162
|
+
"skill/v1": "skill/v1";
|
|
163
|
+
"skills/v1": "skills/v1";
|
|
164
|
+
}>;
|
|
159
165
|
variant: z.ZodDefault<z.ZodEnum<{
|
|
160
166
|
instruction: "instruction";
|
|
161
167
|
executable: "executable";
|
|
@@ -197,4 +203,4 @@ declare const skillFrontmatterSchema: z.ZodObject<{
|
|
|
197
203
|
type SkillFrontmatter = z.infer<typeof skillFrontmatterSchema>;
|
|
198
204
|
type Aip3Extensions = z.infer<typeof aip3ExtensionsSchema>;
|
|
199
205
|
|
|
200
|
-
export { type Aip3Extensions as A, type SkillDefinition as S, type
|
|
206
|
+
export { type Aip3Extensions as A, type SkillDefinition as S, type SkillHandle as a, type SkillExecution as b, type SkillExecutionLanguage as c, type SkillFrontmatter as d, type SkillVariant as e, aip3ExtensionsSchema as f, skillFrontmatterSchema as s };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentproto/skill",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "@agentproto/skill — AIP-3 SKILL.md reference implementation. A markdown + frontmatter format for distributing reusable agent skills as portable, version-controlled files.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentproto",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"gray-matter": "^4.0.3",
|
|
50
50
|
"zod": "^4.6.7",
|
|
51
|
-
"@agentproto/
|
|
51
|
+
"@agentproto/manifest": "0.3.0",
|
|
52
|
+
"@agentproto/doctype": "0.2.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@types/node": "^25.9.9",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schema.ts","../src/define-skill.ts"],"names":[],"mappings":";;;;;;;;AAuBA,IAAM,YAAA,GAAe,mDAAA;AAErB,IAAM,cAAA,GAAiB,wCAAA;AACvB,IAAM,WAAA,GAAc,mBAAA;AAEpB,IAAM,eAAA,GAAkB,EACrB,MAAA,CAAO;AAAA,EACN,QAAA,EAAU,CAAA,CACP,IAAA,CAAK,CAAC,YAAA,EAAc,YAAA,EAAc,QAAA,EAAU,OAAO,CAAC,CAAA,CACpD,QAAA,CAAS,4EAA4E,CAAA;AAAA,EACxF,IAAA,EAAM,EACH,KAAA,CAAM;AAAA,IACL,EACG,MAAA,CAAO;AAAA,MACN,MAAM,CAAA,CACH,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,QAAA;AAAA,QACC;AAAA;AACF,KACH,EACA,MAAA,EAAO;AAAA,IACV,EACG,MAAA,CAAO;AAAA,MACN,MAAA,EAAQ,CAAA,CACL,MAAA,EAAO,CACP,SAAS,wDAAwD;AAAA,KACrE,EACA,MAAA;AAAO,GACX,CAAA,CACA,QAAA,CAAS,6EAA6E,CAAA;AAAA,EACzF,YAAY,CAAA,CAAE,MAAA,GAAS,GAAA,CAAI,CAAC,EAAE,QAAA,EAAS;AAAA,EACvC,OAAA,EAAS,EACN,MAAA,CAAO;AAAA,IACN,QAAA,EAAU,CAAA,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/C,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,IAAI,OAAA,KAAY,gBAAgB,CAAC,IAAA,CAAK,QAAQ,IAAA,CAAK,IAAA,CAAK,WAAW,CAAA,CAAA,EAAI;AACrE,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF,CAAA;AAAA,EACA,MAAM,GAAA,EAAK;AACT,IAAA,OAAO,EAAE,GAAG,GAAA,EAAI;AAAA,EAClB;AACF,CAAC","file":"chunk-GZK4KIZA.mjs","sourcesContent":["/**\n * AIP-3 SKILL.md frontmatter zod schema.\n *\n * Mirrors `resources/aip-3/draft/SKILL.schema.json` field-for-field.\n * AIP-3 is a profile of agentskills.io — top-level fields are the\n * canonical agentskills.io frontmatter; AIP-3 extensions live under\n * `metadata.aip3.*` so a skill authored against AIP-3 remains a valid\n * agentskills.io skill in any conformant runtime.\n *\n * Both authoring paths (`define-skill.ts` for TS-authored skills and\n * `manifest/index.ts` for SKILL.md parsing) validate against this\n * schema, so every field-level constraint runs in both paths from a\n * single source of truth.\n *\n * Cross-field rules (variant=executable ⇒ execution required;\n * variant=composite ⇒ uses non-empty) live in `define-skill.ts`'s\n * `validate(def)` body — they're harder to encode in a flat zod\n * schema and want a single error path.\n */\n\nimport { z } from \"zod\"\n\n/** agentskills.io `name` rule: 1–64, kebab, no leading/trailing/consecutive `-`. */\nconst NAME_PATTERN = /^[a-z0-9](?:[a-z0-9]|-(?!-))*[a-z0-9]$|^[a-z0-9]$/\n\nconst SEMVER_PATTERN = /^\\d+\\.\\d+\\.\\d+(?:[-+][a-zA-Z0-9.-]+)?$/\nconst TAG_PATTERN = /^[a-z][a-z0-9-]*$/\n\nconst executionSchema = z\n .object({\n language: z\n .enum([\"typescript\", \"javascript\", \"python\", \"shell\"])\n .describe(\"Implementation language. Runtimes MAY refuse languages they don't support.\"),\n code: z\n .union([\n z\n .object({\n file: z\n .string()\n .min(1)\n .describe(\n \"Relative path to the entry file. SHOULD live under `scripts/`. Path traversal segments escaping the skill dir MUST be rejected.\",\n ),\n })\n .strict(),\n z\n .object({\n inline: z\n .string()\n .describe(\"Inline source. Runtimes MUST sandbox before executing.\"),\n })\n .strict(),\n ])\n .describe(\"Exactly one of { file } or { inline }. File paths are relative to SKILL.md.\"),\n entrypoint: z.string().min(1).optional(),\n runtime: z\n .object({\n provider: z.string().optional(),\n timeout: z.number().int().positive().optional(),\n memory: z.string().optional(),\n })\n .strict()\n .optional(),\n artifacts: z\n .object({\n patterns: z.array(z.string()).min(1),\n })\n .strict()\n .optional(),\n dependencies: z.record(z.string(), z.string()).optional(),\n })\n .strict()\n .describe(\"Executable bindings. Required when variant=executable.\")\n\nexport const aip3ExtensionsSchema = z\n .object({\n schema: z\n .literal(\"skills/v1\")\n .describe(\"Schema dispatch tag. Required for AIP-3 conformance.\"),\n variant: z\n .enum([\"instruction\", \"executable\", \"composite\"])\n .default(\"instruction\")\n .describe(\n \"Skill variant. `instruction` is prose-only (default); `executable` bundles runnable code via `execution`; `composite` references other skills via `uses`.\",\n ),\n version: z\n .string()\n .regex(SEMVER_PATTERN)\n .optional()\n .describe(\"Semver. Bump on breaking changes to the skill's behavior or required tools.\"),\n tags: z\n .array(z.string().regex(TAG_PATTERN))\n .max(12)\n .default([])\n .describe(\"Catalog tags. Lowercase kebab-case; no leading symbols. 3–6 tags is typical.\"),\n category: z\n .string()\n .min(1)\n .max(64)\n .optional()\n .describe(\n \"Coarse grouping (e.g. 'productivity', 'creative', 'development'). Free-form; runtimes SHOULD NOT enumerate.\",\n ),\n requires: z\n .array(z.number().int().positive())\n .default([])\n .describe(\n \"Other AIPs this skill depends on (e.g. `[9]` for the operator runtime). Runtimes MAY warn when a declared dependency is unsupported.\",\n ),\n author: z\n .string()\n .max(200)\n .optional()\n .describe(\n \"Optional. Conventional shape: 'Name <email>' or stable handle. Mirrors agentskills.io's `metadata.author` convention; if both are present, `metadata.aip3.author` wins for AIP-3 runtimes.\",\n ),\n title: z\n .string()\n .min(1)\n .max(120)\n .optional()\n .describe(\n \"Optional human-readable display title. Headless runtimes that can't render the body H1 MAY use this. The body H1 is preferred.\",\n ),\n uses: z\n .array(z.string().regex(NAME_PATTERN))\n .default([])\n .describe(\n \"Skill names this skill composes with. Required and non-empty when variant=composite.\",\n ),\n execution: executionSchema.optional(),\n })\n .loose()\n\nexport const skillFrontmatterSchema = z\n .object({\n name: z\n .string()\n .min(1)\n .max(64)\n .regex(NAME_PATTERN)\n .describe(\n \"Machine identifier. 1–64 chars, lowercase alphanumeric and hyphens only, no leading/trailing/consecutive hyphens. MUST equal the parent directory name. Inherited verbatim from agentskills.io.\",\n ),\n description: z\n .string()\n .min(1)\n .max(1024)\n .describe(\n \"One-paragraph purpose. SHOULD describe both what the skill does and when to use it. Inherited from agentskills.io (1024-char cap).\",\n ),\n license: z\n .string()\n .max(200)\n .optional()\n .describe(\n \"Optional. License identifier (SPDX or pointer to a bundled license file). Inherited from agentskills.io.\",\n ),\n compatibility: z\n .string()\n .min(1)\n .max(500)\n .optional()\n .describe(\n \"Optional. Free-form environment requirements: intended product, system packages, network access, etc. Most skills omit this.\",\n ),\n \"allowed-tools\": z\n .string()\n .optional()\n .describe(\n \"Optional. Space-separated list of pre-approved tool patterns (e.g. 'Bash(git:*) Read'). Experimental upstream — runtimes MAY ignore. The field is a request, not a grant.\",\n ),\n metadata: z\n .object({ aip3: aip3ExtensionsSchema.optional() })\n .loose()\n .default({})\n .describe(\n \"Free-form key-value mapping. Hosts and standards stash extension fields under namespaced keys (e.g. `metadata.aip3.*`, `metadata.acme.*`). Inherited from agentskills.io.\",\n ),\n })\n .loose()\n .describe(\n \"Validates the YAML frontmatter portion of an AIP-3 SKILL.md manifest. AIP-3 is a profile of agentskills.io.\",\n )\n\nexport type SkillFrontmatter = z.infer<typeof skillFrontmatterSchema>\nexport type Aip3Extensions = z.infer<typeof aip3ExtensionsSchema>\n","import { createDoctype } from \"@agentproto/define-doctype\"\nimport { skillFrontmatterSchema } from \"./schema.js\"\nimport type { SkillDefinition, SkillHandle } from \"./types.js\"\n\n/**\n * AIP-3 reference implementation of `defineSkill`.\n *\n * Built on `createDoctype` so the cross-AIP invariants (id pattern,\n * description length, top-level freeze, \"defineSkill (AIP-3): …\"\n * error prefix) run uniformly with every other AIP defineX.\n *\n * Field-level validation runs the schema-derived zod from\n * `./schema.ts` against the input. Same source of truth as the .md\n * path uses (`parseSkillManifest`), so a malformed TS-authored\n * definition fails with the same diagnostic as a malformed manifest.\n *\n * Cross-field rules — variant=executable requires `metadata.aip3.execution`;\n * variant=composite requires non-empty `metadata.aip3.uses` — run after\n * the zod check so callers see one consistent error path.\n *\n * Identity / description extractors detected from the JSON Schema:\n * readIdentity: def.name\n * readDescription: def.description.\n */\nexport const defineSkill = createDoctype<SkillDefinition, SkillHandle>({\n aip: 3,\n name: \"skill\",\n readIdentity: (def) => def.name,\n validate(def) {\n const result = skillFrontmatterSchema.safeParse(def)\n if (!result.success) {\n throw new Error(\n `defineSkill (AIP-3): ${result.error.issues\n .map((i) => `${i.path.join(\".\")}: ${i.message}`)\n .join(\"; \")}`,\n )\n }\n\n const aip3 = result.data.metadata?.aip3\n if (!aip3) return\n\n const variant = aip3.variant ?? \"instruction\"\n if (variant === \"executable\" && !aip3.execution) {\n throw new Error(\n \"defineSkill (AIP-3): metadata.aip3.execution is required when metadata.aip3.variant=executable\",\n )\n }\n if (variant === \"composite\" && (!aip3.uses || aip3.uses.length === 0)) {\n throw new Error(\n \"defineSkill (AIP-3): metadata.aip3.uses must be non-empty when metadata.aip3.variant=composite\",\n )\n }\n },\n build(def) {\n return { ...def } as SkillHandle\n },\n})\n"]}
|