@agentproto/canvakit 0.1.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 agentproto contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # @agentproto/canvakit
2
+
3
+ AIP-5 `TEMPLATE.md` reference implementation. A markdown + frontmatter format for templates that declare named data sources, resolve them in parallel, and re-render when data changes.
4
+
5
+ > **Status: 0.1.0-alpha.** Generated by `scripts/scaffold-aip.mjs` — `build()` and `validate()` bodies are TODOs.
6
+
7
+ Spec: <https://agentproto.sh/docs/aip-5>
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ import { defineCanvakit } from "@agentproto/canvakit"
13
+
14
+ const x = defineCanvakit({
15
+ id: "my-canvakit",
16
+ description: "Short purpose.",
17
+ // ...
18
+ })
19
+ ```
20
+
21
+ ## License
22
+
23
+ MIT — see [LICENSE](./LICENSE).
@@ -0,0 +1,30 @@
1
+ import { z } from 'zod';
2
+ import { createDoctype } from '@agentproto/define-doctype';
3
+
4
+ /**
5
+ * @agentproto/canvakit v0.1.0-alpha
6
+ * AIP-5 TEMPLATE.md `defineCanvakit` reference implementation.
7
+ */
8
+
9
+ var canvakitFrontmatterSchema = z.object({ "schema": z.literal("canvakit/v1").describe("Spec version pin. Hosts that find an unknown schema MUST refuse rather than guess.").optional(), "template": z.literal(true).describe("Required marker. Tooling that loads files by glob uses this to catch 'renamed but not a template' mistakes."), "name": z.string().regex(new RegExp("^[a-z][a-z0-9-]*[a-z0-9]$")).min(2).max(64).describe("Slug-safe machine name. Lowercase, digits, dashes."), "version": z.string().regex(new RegExp("^\\d+\\.\\d+\\.\\d+(?:[-+][a-zA-Z0-9.-]+)?$")).describe("Semver. Bump on breaking change to the rendered shape or variables contract."), "description": z.string().max(2e3).describe("One-sentence purpose for the gallery card.").optional(), "author": z.string().describe("Optional locally; required for gallery publish \u2014 (author, name, version) is the canonical key.").optional(), "renderer": z.enum(["mustache", "handlebars", "mdx"]).describe("Template engine. v1 default 'mustache' is universally supported; others are spec-legal but optional.").default("mustache"), "design": z.string().describe("Designkit fallback hint. Used only when no workspace design is active. Schemes: dk:<preset>, ws:<path>, kit:<slug>, or a bare *.md path.").optional(), "forceDesign": z.string().describe("Designkit override. Bypasses workspace selection. Same scheme grammar as 'design'.").optional(), "refreshEvery": z.union([z.enum(["manual", "on-tool-change"]), z.string().regex(new RegExp("^\\d+(ms|s|m|h)$")).describe("Duration string \u2014 e.g. 60s, 5m, 1h.")]).describe("Declarative cadence hint. Honored opportunistically; runtimes that can't honor SHOULD treat as 'manual'.").default("manual"), "variables": z.record(z.string(), z.any()).describe("Caller inputs with author defaults. Substituted into sources params before resolution.").default({}), "sources": z.record(z.string(), z.any()).describe("Named data sources resolved in parallel and merged into the render context.").default({}), "imports": z.record(z.string(), z.any()).describe("Nested canvases. Each renders in isolation; output exposed under {{{imports.<name>}}}.").default({}), "tags": z.array(z.string().regex(new RegExp("^[a-z][a-z0-9-]*$"))).default([]), "metadata": z.record(z.string(), z.any()).describe("Host-specific extension surface. Other hosts MUST tolerate unknown metadata.<host>.* keys.").default({}) }).describe("Validates the YAML frontmatter portion of an AIP-5 *.canvakit.* template.");
10
+ var defineCanvakit = createDoctype({
11
+ aip: 5,
12
+ name: "canvakit",
13
+ readIdentity: (def) => def.name,
14
+ readDescription: false,
15
+ validate(def) {
16
+ const result = canvakitFrontmatterSchema.safeParse(def);
17
+ if (!result.success) {
18
+ throw new Error(
19
+ `defineCanvakit (AIP-5): ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
20
+ );
21
+ }
22
+ },
23
+ build(def) {
24
+ return { ...def };
25
+ }
26
+ });
27
+
28
+ export { canvakitFrontmatterSchema, defineCanvakit };
29
+ //# sourceMappingURL=chunk-D44K7M6V.mjs.map
30
+ //# sourceMappingURL=chunk-D44K7M6V.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts","../src/define-canvakit.ts"],"names":[],"mappings":";;;;;;;;AAeO,IAAM,yBAAA,GAA4B,CAAA,CAAE,MAAA,CAAO,EAAE,QAAA,EAAU,EAAE,OAAA,CAAQ,aAAa,CAAA,CAAE,QAAA,CAAS,oFAAoF,CAAA,CAAE,UAAS,EAAG,UAAA,EAAY,CAAA,CAAE,OAAA,CAAQ,IAAI,CAAA,CAAE,SAAS,6GAA6G,CAAA,EAAG,MAAA,EAAQ,CAAA,CAAE,MAAA,EAAO,CAAE,MAAM,IAAI,MAAA,CAAO,2BAA2B,CAAC,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,GAAA,CAAI,EAAE,CAAA,CAAE,QAAA,CAAS,oDAAoD,GAAG,SAAA,EAAW,CAAA,CAAE,MAAA,EAAO,CAAE,KAAA,CAAM,IAAI,MA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schema.\n *\n * Generated from `resources/aip-5/draft/TEMPLATE.schema.json` via\n * json-schema-to-zod. Imported by both `define-canvakit.ts` (TS path\n * validation) and `manifest/index.ts` (.md path validation) so every\n * field-level constraint runs in both authoring paths from a single\n * source of truth — re-run scaffold-aip to refresh after spec changes.\n *\n * Cross-field rules (if/then/allOf in JSON Schema) don't translate\n * cleanly and live in `define-canvakit.ts`'s `validate(def)` instead.\n */\n\nimport { z } from \"zod\"\n\nexport const canvakitFrontmatterSchema = z.object({ \"schema\": z.literal(\"canvakit/v1\").describe(\"Spec version pin. Hosts that find an unknown schema MUST refuse rather than guess.\").optional(), \"template\": z.literal(true).describe(\"Required marker. Tooling that loads files by glob uses this to catch 'renamed but not a template' mistakes.\"), \"name\": z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*[a-z0-9]$\")).min(2).max(64).describe(\"Slug-safe machine name. Lowercase, digits, dashes.\"), \"version\": z.string().regex(new RegExp(\"^\\\\d+\\\\.\\\\d+\\\\.\\\\d+(?:[-+][a-zA-Z0-9.-]+)?$\")).describe(\"Semver. Bump on breaking change to the rendered shape or variables contract.\"), \"description\": z.string().max(2000).describe(\"One-sentence purpose for the gallery card.\").optional(), \"author\": z.string().describe(\"Optional locally; required for gallery publish — (author, name, version) is the canonical key.\").optional(), \"renderer\": z.enum([\"mustache\",\"handlebars\",\"mdx\"]).describe(\"Template engine. v1 default 'mustache' is universally supported; others are spec-legal but optional.\").default(\"mustache\"), \"design\": z.string().describe(\"Designkit fallback hint. Used only when no workspace design is active. Schemes: dk:<preset>, ws:<path>, kit:<slug>, or a bare *.md path.\").optional(), \"forceDesign\": z.string().describe(\"Designkit override. Bypasses workspace selection. Same scheme grammar as 'design'.\").optional(), \"refreshEvery\": z.union([z.enum([\"manual\",\"on-tool-change\"]), z.string().regex(new RegExp(\"^\\\\d+(ms|s|m|h)$\")).describe(\"Duration string — e.g. 60s, 5m, 1h.\")]).describe(\"Declarative cadence hint. Honored opportunistically; runtimes that can't honor SHOULD treat as 'manual'.\").default(\"manual\"), \"variables\": z.record(z.string(), z.any()).describe(\"Caller inputs with author defaults. Substituted into sources params before resolution.\").default({} as never), \"sources\": z.record(z.string(), z.any()).describe(\"Named data sources resolved in parallel and merged into the render context.\").default({} as never), \"imports\": z.record(z.string(), z.any()).describe(\"Nested canvases. Each renders in isolation; output exposed under {{{imports.<name>}}}.\").default({} as never), \"tags\": z.array(z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*$\"))).default([] as never), \"metadata\": z.record(z.string(), z.any()).describe(\"Host-specific extension surface. Other hosts MUST tolerate unknown metadata.<host>.* keys.\").default({} as never) }).describe(\"Validates the YAML frontmatter portion of an AIP-5 *.canvakit.* template.\")\n\nexport type CanvakitFrontmatter = z.infer<typeof canvakitFrontmatterSchema>\n","import { createDoctype } from \"@agentproto/define-doctype\"\nimport { canvakitFrontmatterSchema } from \"./schema.js\"\nimport type { CanvakitDefinition, CanvakitHandle } from \"./types.js\"\n\n/**\n * AIP-5 reference implementation of `defineCanvakit`.\n *\n * Built on `createDoctype` so the cross-AIP invariants (id pattern,\n * description length, top-level freeze, \"defineCanvakit (AIP-5): …\"\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 (`parseCanvakitManifest`), so a malformed TS-authored\n * definition fails with the same diagnostic as a malformed manifest.\n * Cross-field rules go in `validate(def)` after the zod check.\n *\n * Identity / description extractors detected from the JSON Schema:\n * readIdentity: def.name\n * readDescription: skipped (no string-y required field detected).\n */\nexport const defineCanvakit = createDoctype<CanvakitDefinition, CanvakitHandle>({\n aip: 5,\n name: \"canvakit\",\n readIdentity: (def) => def.name,\n readDescription: false,\n validate(def) {\n const result = canvakitFrontmatterSchema.safeParse(def)\n if (!result.success) {\n throw new Error(\n `defineCanvakit (AIP-5): ${result.error.issues\n .map((i) => `${i.path.join(\".\")}: ${i.message}`)\n .join(\"; \")}`,\n )\n }\n // TODO: spec-5-specific cross-field rules (if/then/allOf in\n // the JSON Schema) — those don't translate to zod cleanly and\n // belong here. See @agentproto/operator's autonomy=gated rule.\n },\n build(def) {\n // Default build: spread the validated definition into a fresh object.\n // Hand-tune for nested freezing (Object.freeze on arrays/objects) and\n // for fields that need defaults applied — see @agentproto/operator\n // for a reference shape.\n return { ...def } as CanvakitHandle\n },\n})\n"]}
@@ -0,0 +1,40 @@
1
+ import { C as CanvakitDefinition } from './types-DZeH88ZK.js';
2
+ export { a as CanvakitHandle } from './types-DZeH88ZK.js';
3
+
4
+ /**
5
+ * AIP-5 reference implementation of `defineCanvakit`.
6
+ *
7
+ * Built on `createDoctype` so the cross-AIP invariants (id pattern,
8
+ * description length, top-level freeze, "defineCanvakit (AIP-5): …"
9
+ * error prefix) run uniformly with every other AIP defineX.
10
+ *
11
+ * Field-level validation runs the schema-derived zod from
12
+ * `./schema.ts` against the input. Same source of truth as the .md
13
+ * path uses (`parseCanvakitManifest`), so a malformed TS-authored
14
+ * definition fails with the same diagnostic as a malformed manifest.
15
+ * Cross-field rules go in `validate(def)` after the zod check.
16
+ *
17
+ * Identity / description extractors detected from the JSON Schema:
18
+ * readIdentity: def.name
19
+ * readDescription: skipped (no string-y required field detected).
20
+ */
21
+ declare const defineCanvakit: (def: CanvakitDefinition) => Readonly<CanvakitDefinition>;
22
+
23
+ /**
24
+ * @agentproto/canvakit — AIP-5 TEMPLATE.md `defineCanvakit` reference impl.
25
+ *
26
+ * A markdown + frontmatter format for templates that declare named data sources, resolve them in parallel, and re-render when data changes.
27
+ *
28
+ * Spec: https://agentproto.sh/docs/aip-5
29
+ *
30
+ * Authoring paths:
31
+ * - TS: `defineCanvakit({...})` → `CanvakitHandle`
32
+ * - MD: `parseCanvakitManifest(src) → canvakitFromManifest({...})` → `CanvakitHandle`
33
+ *
34
+ * The RENDER engine lives in `@canvakit/core` (`render`) — the reference
35
+ * implementation of this spec. This package is the spec/definition layer only.
36
+ */
37
+ declare const SPEC_NAME: "agentcanvakit/v1";
38
+ declare const SPEC_VERSION: "1.0.0-alpha";
39
+
40
+ export { CanvakitDefinition, SPEC_NAME, SPEC_VERSION, defineCanvakit };
package/dist/index.mjs ADDED
@@ -0,0 +1,14 @@
1
+ export { defineCanvakit } from './chunk-D44K7M6V.mjs';
2
+
3
+ /**
4
+ * @agentproto/canvakit v0.1.0-alpha
5
+ * AIP-5 TEMPLATE.md `defineCanvakit` reference implementation.
6
+ */
7
+
8
+ // src/index.ts
9
+ var SPEC_NAME = "agentcanvakit/v1";
10
+ var SPEC_VERSION = "1.0.0-alpha";
11
+
12
+ export { SPEC_NAME, SPEC_VERSION };
13
+ //# sourceMappingURL=index.mjs.map
14
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;AAeO,IAAM,SAAA,GAAY;AAClB,IAAM,YAAA,GAAe","file":"index.mjs","sourcesContent":["/**\n * @agentproto/canvakit — AIP-5 TEMPLATE.md `defineCanvakit` reference impl.\n *\n * A markdown + frontmatter format for templates that declare named data sources, resolve them in parallel, and re-render when data changes.\n *\n * Spec: https://agentproto.sh/docs/aip-5\n *\n * Authoring paths:\n * - TS: `defineCanvakit({...})` → `CanvakitHandle`\n * - MD: `parseCanvakitManifest(src) → canvakitFromManifest({...})` → `CanvakitHandle`\n *\n * The RENDER engine lives in `@canvakit/core` (`render`) — the reference\n * implementation of this spec. This package is the spec/definition layer only.\n */\n\nexport const SPEC_NAME = \"agentcanvakit/v1\" as const\nexport const SPEC_VERSION = \"1.0.0-alpha\" as const\n\nexport { defineCanvakit } from \"./define-canvakit.js\"\nexport type { CanvakitDefinition, CanvakitHandle } from \"./types.js\"\n"]}
@@ -0,0 +1,66 @@
1
+ import { z } from 'zod';
2
+ import { a as CanvakitHandle } from '../types-DZeH88ZK.js';
3
+
4
+ /**
5
+ * AIP-5 TEMPLATE.md frontmatter zod schema.
6
+ *
7
+ * Generated from `resources/aip-5/draft/TEMPLATE.schema.json` via
8
+ * json-schema-to-zod. Imported by both `define-canvakit.ts` (TS path
9
+ * validation) and `manifest/index.ts` (.md path validation) so every
10
+ * field-level constraint runs in both authoring paths from a single
11
+ * source of truth — re-run scaffold-aip to refresh after spec changes.
12
+ *
13
+ * Cross-field rules (if/then/allOf in JSON Schema) don't translate
14
+ * cleanly and live in `define-canvakit.ts`'s `validate(def)` instead.
15
+ */
16
+
17
+ declare const canvakitFrontmatterSchema: z.ZodObject<{
18
+ schema: z.ZodOptional<z.ZodLiteral<"canvakit/v1">>;
19
+ template: z.ZodLiteral<true>;
20
+ name: z.ZodString;
21
+ version: z.ZodString;
22
+ description: z.ZodOptional<z.ZodString>;
23
+ author: z.ZodOptional<z.ZodString>;
24
+ renderer: z.ZodDefault<z.ZodEnum<{
25
+ mustache: "mustache";
26
+ handlebars: "handlebars";
27
+ mdx: "mdx";
28
+ }>>;
29
+ design: z.ZodOptional<z.ZodString>;
30
+ forceDesign: z.ZodOptional<z.ZodString>;
31
+ refreshEvery: z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
32
+ manual: "manual";
33
+ "on-tool-change": "on-tool-change";
34
+ }>, z.ZodString]>>;
35
+ variables: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
36
+ sources: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
37
+ imports: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
38
+ tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
39
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
40
+ }, z.core.$strip>;
41
+ type CanvakitFrontmatter = z.infer<typeof canvakitFrontmatterSchema>;
42
+
43
+ /**
44
+ * AIP-5 TEMPLATE.md sidecar parser + manifest-to-handle constructor.
45
+ *
46
+ * Mirror of `@agentproto/tool/manifest` and `@agentproto/driver/manifest`:
47
+ * the .md provides metadata; the TS module supplies any spec-specific
48
+ * runtime bits (schemas, execute bodies, …) that can't live in
49
+ * frontmatter. Both inputs end up in `defineCanvakit` so the cross-AIP
50
+ * invariants run uniformly.
51
+ *
52
+ *
53
+ * The frontmatter zod schema below was generated from
54
+ * `resources/aip-5/draft/TEMPLATE.schema.json` via json-schema-to-zod.
55
+ * Re-run scaffold-aip to refresh after spec changes (or hand-tune
56
+ * any constraint the converter doesn't capture cleanly).
57
+ */
58
+
59
+ interface CanvakitManifest {
60
+ frontmatter: CanvakitFrontmatter;
61
+ body: string;
62
+ }
63
+ declare function parseCanvakitManifest(source: string): CanvakitManifest;
64
+ declare function canvakitFromManifest(manifest: CanvakitManifest): CanvakitHandle;
65
+
66
+ export { type CanvakitFrontmatter, type CanvakitManifest, canvakitFromManifest, canvakitFrontmatterSchema, parseCanvakitManifest };
@@ -0,0 +1,28 @@
1
+ import { canvakitFrontmatterSchema, defineCanvakit } from '../chunk-D44K7M6V.mjs';
2
+ export { canvakitFrontmatterSchema } from '../chunk-D44K7M6V.mjs';
3
+ import matter from 'gray-matter';
4
+
5
+ /**
6
+ * @agentproto/canvakit v0.1.0-alpha
7
+ * AIP-5 TEMPLATE.md `defineCanvakit` reference implementation.
8
+ */
9
+ function parseCanvakitManifest(source) {
10
+ const parsed = matter(source);
11
+ if (Object.keys(parsed.data).length === 0) {
12
+ throw new Error("parseCanvakitManifest: missing or empty frontmatter");
13
+ }
14
+ const result = canvakitFrontmatterSchema.safeParse(parsed.data);
15
+ if (!result.success) {
16
+ throw new Error(
17
+ `parseCanvakitManifest: 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 canvakitFromManifest(manifest) {
23
+ return defineCanvakit(manifest.frontmatter);
24
+ }
25
+
26
+ export { canvakitFromManifest, parseCanvakitManifest };
27
+ //# sourceMappingURL=index.mjs.map
28
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/manifest/index.ts"],"names":[],"mappings":";;;;;;;;AA8BO,SAAS,sBAAsB,MAAA,EAAkC;AACtE,EAAA,MAAM,MAAA,GAAS,OAAO,MAAM,CAAA;AAC5B,EAAA,IAAI,OAAO,IAAA,CAAK,MAAA,CAAO,IAAI,CAAA,CAAE,WAAW,CAAA,EAAG;AACzC,IAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA,EACvE;AACA,EAAA,MAAM,MAAA,GAAS,yBAAA,CAA0B,SAAA,CAAU,MAAA,CAAO,IAAI,CAAA;AAC9D,EAAA,IAAI,CAAC,OAAO,OAAA,EAAS;AACnB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,kDAAA,EAAgD,OAAO,KAAA,CAAM,MAAA,CAC1D,IAAI,CAAC,CAAA,KAAM,GAAG,CAAA,CAAE,IAAA,CAAK,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,qBAAqB,QAAA,EAA4C;AAK/E,EAAA,OAAO,cAAA,CAAe,SAAS,WAA4C,CAAA;AAC7E","file":"index.mjs","sourcesContent":["/**\n * AIP-5 TEMPLATE.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 `defineCanvakit` so the cross-AIP\n * invariants run uniformly.\n *\n *\n * The frontmatter zod schema below was generated from\n * `resources/aip-5/draft/TEMPLATE.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 { canvakitFrontmatterSchema, type CanvakitFrontmatter } from \"../schema.js\"\nimport { defineCanvakit } from \"../define-canvakit.js\"\nimport type { CanvakitDefinition, CanvakitHandle } from \"../types.js\"\n\n// Re-export so consumers can import the schema + inferred type either\n// from \"@@agentproto/canvakit/manifest\" or directly from \"@@agentproto/canvakit/schema\".\nexport { canvakitFrontmatterSchema, type CanvakitFrontmatter }\n\nexport interface CanvakitManifest {\n frontmatter: CanvakitFrontmatter\n body: string\n}\n\nexport function parseCanvakitManifest(source: string): CanvakitManifest {\n const parsed = matter(source)\n if (Object.keys(parsed.data).length === 0) {\n throw new Error(\"parseCanvakitManifest: missing or empty frontmatter\")\n }\n const result = canvakitFrontmatterSchema.safeParse(parsed.data)\n if (!result.success) {\n throw new Error(\n `parseCanvakitManifest: 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 canvakitFromManifest(manifest: CanvakitManifest): CanvakitHandle {\n // The zod-validated frontmatter is structurally compatible with\n // CanvakitDefinition; 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 defineCanvakit(manifest.frontmatter as unknown as CanvakitDefinition)\n}\n"]}
@@ -0,0 +1,168 @@
1
+ /**
2
+ * AIP-5 CanvakitDefinition + CanvakitHandle.
3
+ *
4
+ * `CanvakitDefinition` was generated from
5
+ * `resources/aip-5/draft/TEMPLATE.schema.json` via json-schema-to-typescript.
6
+ * `CanvakitHandle` is the readonly view of the same shape; tighten it
7
+ * by hand for fields that get defaults applied in build().
8
+ */
9
+ /**
10
+ * Discriminated by 'kind'. One of: tool, static, file, query.
11
+ */
12
+ type Source = SourceTool | SourceStatic | SourceFile | SourceQuery;
13
+ /**
14
+ * Validates the YAML frontmatter portion of an AIP-5 *.canvakit.* template.
15
+ */
16
+ interface CanvakitDefinition {
17
+ /**
18
+ * Spec version pin. Hosts that find an unknown schema MUST refuse rather than guess.
19
+ */
20
+ schema?: "canvakit/v1";
21
+ /**
22
+ * Required marker. Tooling that loads files by glob uses this to catch 'renamed but not a template' mistakes.
23
+ */
24
+ template: true;
25
+ /**
26
+ * Slug-safe machine name. Lowercase, digits, dashes.
27
+ */
28
+ name: string;
29
+ /**
30
+ * Semver. Bump on breaking change to the rendered shape or variables contract.
31
+ */
32
+ version: string;
33
+ /**
34
+ * One-sentence purpose for the gallery card.
35
+ */
36
+ description?: string;
37
+ /**
38
+ * Optional locally; required for gallery publish — (author, name, version) is the canonical key.
39
+ */
40
+ author?: string;
41
+ /**
42
+ * Template engine. v1 default 'mustache' is universally supported; others are spec-legal but optional.
43
+ */
44
+ renderer?: "mustache" | "handlebars" | "mdx";
45
+ /**
46
+ * Designkit fallback hint. Used only when no workspace design is active. Schemes: dk:<preset>, ws:<path>, kit:<slug>, or a bare *.md path.
47
+ */
48
+ design?: string;
49
+ /**
50
+ * Designkit override. Bypasses workspace selection. Same scheme grammar as 'design'.
51
+ */
52
+ forceDesign?: string;
53
+ /**
54
+ * Declarative cadence hint. Honored opportunistically; runtimes that can't honor SHOULD treat as 'manual'.
55
+ */
56
+ refreshEvery?: ("manual" | "on-tool-change") | string;
57
+ /**
58
+ * Caller inputs with author defaults. Substituted into sources params before resolution.
59
+ */
60
+ variables?: {
61
+ [k: string]: Variable;
62
+ };
63
+ /**
64
+ * Named data sources resolved in parallel and merged into the render context.
65
+ */
66
+ sources?: {
67
+ [k: string]: Source;
68
+ };
69
+ /**
70
+ * Nested canvases. Each renders in isolation; output exposed under {{{imports.<name>}}}.
71
+ */
72
+ imports?: {
73
+ [k: string]: Import;
74
+ };
75
+ tags?: string[];
76
+ /**
77
+ * Host-specific extension surface. Other hosts MUST tolerate unknown metadata.<host>.* keys.
78
+ */
79
+ metadata?: {
80
+ [k: string]: unknown;
81
+ };
82
+ }
83
+ interface Variable {
84
+ type?: "string" | "number" | "boolean" | "object" | "array";
85
+ required?: boolean;
86
+ default?: unknown;
87
+ description?: string;
88
+ }
89
+ interface SourceTool {
90
+ kind: "tool";
91
+ /**
92
+ * Tool identifier. Flat ('searchFlights'), namespaced ('stripe.mrr'), or MCP-qualified ('mcp://server/tool'). Resolution: exact > longest wildcard > MCP.
93
+ */
94
+ ref: string;
95
+ /**
96
+ * JSON params passed verbatim to the resolver. String values may interpolate {{variables.*}}.
97
+ */
98
+ params?: {
99
+ [k: string]: unknown;
100
+ };
101
+ /**
102
+ * Legacy alias for 'params'. Hosts SHOULD accept and warn.
103
+ */
104
+ args?: {
105
+ [k: string]: unknown;
106
+ };
107
+ }
108
+ interface SourceStatic {
109
+ kind: "static";
110
+ /**
111
+ * Literal pass-through. Never fetched, never parsed.
112
+ */
113
+ value: {
114
+ [k: string]: unknown;
115
+ };
116
+ }
117
+ interface SourceFile {
118
+ kind: "file";
119
+ /**
120
+ * Filesystem path relative to the render filesystem. Parsed by extension per the format contract.
121
+ */
122
+ path: string;
123
+ /**
124
+ * Resolve `path` against a named workspace instead of the render filesystem. The host's workspace resolver supplies the filesystem (and enforces access); unconfigured cross-workspace refs surface as status:error.
125
+ */
126
+ workspace?: string;
127
+ }
128
+ interface SourceQuery {
129
+ kind: "query";
130
+ /**
131
+ * Glob or array of globs. Bare directory paths are rewritten to <path>/** /*.md.
132
+ */
133
+ include: string | [string, ...string[]];
134
+ /**
135
+ * Field predicates against parsed shape. Supports equality and operators _in, _contains, _before, _after.
136
+ */
137
+ where?: {
138
+ [k: string]: unknown;
139
+ };
140
+ /**
141
+ * field (asc) or -field (desc) on a parsed key.
142
+ */
143
+ sort?: string;
144
+ limit?: number;
145
+ /**
146
+ * Project to a subset of parsed keys.
147
+ */
148
+ fields?: string[];
149
+ /**
150
+ * Resolve the glob against a named workspace instead of the render filesystem. The host's workspace resolver supplies the filesystem (and enforces access); unconfigured cross-workspace refs surface as status:error.
151
+ */
152
+ workspace?: string;
153
+ }
154
+ interface Import {
155
+ /**
156
+ * Path to a sibling *.canvakit.* file.
157
+ */
158
+ template: string;
159
+ /**
160
+ * Values passed to the imported canvas. Imports do NOT inherit parent variables; pass explicitly.
161
+ */
162
+ variables?: {
163
+ [k: string]: unknown;
164
+ };
165
+ }
166
+ type CanvakitHandle = Readonly<CanvakitDefinition>;
167
+
168
+ export type { CanvakitDefinition as C, CanvakitHandle as a };
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@agentproto/canvakit",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "@agentproto/canvakit — AIP-5 TEMPLATE.md reference implementation. A markdown + frontmatter format for templates that declare named data sources, resolve them in parallel, and re-render when data changes.",
5
+ "keywords": [
6
+ "agentproto",
7
+ "aip-5",
8
+ "canvakit",
9
+ "defineCanvakit",
10
+ "open-standard",
11
+ "agentic"
12
+ ],
13
+ "homepage": "https://agentproto.sh/docs/aip-5",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/agentproto/ts",
17
+ "directory": "packages/canvakit"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/agentproto/ts/issues"
21
+ },
22
+ "license": "MIT",
23
+ "type": "module",
24
+ "main": "dist/index.mjs",
25
+ "module": "dist/index.mjs",
26
+ "types": "dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.mjs",
31
+ "default": "./dist/index.mjs"
32
+ },
33
+ "./manifest": {
34
+ "types": "./dist/manifest/index.d.ts",
35
+ "import": "./dist/manifest/index.mjs",
36
+ "default": "./dist/manifest/index.mjs"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "README.md",
43
+ "LICENSE"
44
+ ],
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "dependencies": {
49
+ "gray-matter": "^4.0.3",
50
+ "zod": "^4.4.3",
51
+ "@agentproto/define-doctype": "0.1.0"
52
+ },
53
+ "devDependencies": {
54
+ "@types/node": "^25.6.2",
55
+ "tsup": "^8.5.1",
56
+ "typescript": "^5.9.3",
57
+ "vitest": "^3.2.4",
58
+ "@agentproto/tooling": "0.1.0-alpha.0"
59
+ },
60
+ "scripts": {
61
+ "dev": "tsup --watch",
62
+ "build": "tsup",
63
+ "clean": "rm -rf dist",
64
+ "check-types": "tsc --noEmit",
65
+ "test": "vitest run --passWithNoTests",
66
+ "test:watch": "vitest"
67
+ }
68
+ }