@agentproto/code 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/code
2
+
3
+ AIP-26 `CODE.md` reference implementation. A composable schema block defining the `code` and `run` fields that declare what files compose a runnable bundle (inline, local, github, ref) and how to invoke them — together with the `code-workspace` first-class kind that other manifests reference.
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-26>
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ import { defineCode } from "@agentproto/code"
13
+
14
+ const x = defineCode({
15
+ id: "my-code",
16
+ description: "Short purpose.",
17
+ // ...
18
+ })
19
+ ```
20
+
21
+ ## License
22
+
23
+ MIT — see [LICENSE](./LICENSE).
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ import { createDoctype } from '@agentproto/define-doctype';
3
+
4
+ /**
5
+ * @agentproto/code v0.1.0-alpha
6
+ * AIP-26 CODE.md `defineCode` reference implementation.
7
+ */
8
+
9
+ var codeFrontmatterSchema = z.record(z.string(), z.any()).describe("Composable JSON Schema definitions for the `code` and `run` blocks reused across manifest formats. Other AIPs reference these by $ref into their own schemas.");
10
+ var defineCode = createDoctype({
11
+ aip: 26,
12
+ name: "code",
13
+ validate(def) {
14
+ const result = codeFrontmatterSchema.safeParse(def);
15
+ if (!result.success) {
16
+ throw new Error(
17
+ `defineCode (AIP-26): ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
18
+ );
19
+ }
20
+ },
21
+ build(def) {
22
+ return { ...def };
23
+ }
24
+ });
25
+
26
+ export { codeFrontmatterSchema, defineCode };
27
+ //# sourceMappingURL=chunk-RCJ32GFA.mjs.map
28
+ //# sourceMappingURL=chunk-RCJ32GFA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts","../src/define-code.ts"],"names":[],"mappings":";;;;;;;;AAeO,IAAM,qBAAA,GAAwB,CAAA,CAAE,MAAA,CAAO,CAAA,CAAE,MAAA,EAAO,EAAG,CAAA,CAAE,GAAA,EAAK,CAAA,CAAE,QAAA,CAAS,+JAA+J;ACEpO,IAAM,aAAa,aAAA,CAA0C;AAAA,EAClE,GAAA,EAAK,EAAA;AAAA,EACL,IAAA,EAAM,MAAA;AAAA,EACN,SAAS,GAAA,EAAK;AACZ,IAAA,MAAM,MAAA,GAAS,qBAAA,CAAsB,SAAA,CAAU,GAAG,CAAA;AAClD,IAAA,IAAI,CAAC,OAAO,OAAA,EAAS;AACnB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,qBAAA,EAAwB,OAAO,KAAA,CAAM,MAAA,CAClC,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,OACf;AAAA,IACF;AAAA,EAIF,CAAA;AAAA,EACA,MAAM,GAAA,EAAK;AAKT,IAAA,OAAO,EAAE,GAAG,GAAA,EAAI;AAAA,EAClB;AACF,CAAC","file":"chunk-RCJ32GFA.mjs","sourcesContent":["/**\n * AIP-26 CODE.md frontmatter zod schema.\n *\n * Generated from `resources/aip-26/draft/CODE.schema.json` via\n * json-schema-to-zod. Imported by both `define-code.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-code.ts`'s `validate(def)` instead.\n */\n\nimport { z } from \"zod\"\n\nexport const codeFrontmatterSchema = z.record(z.string(), z.any()).describe(\"Composable JSON Schema definitions for the `code` and `run` blocks reused across manifest formats. Other AIPs reference these by $ref into their own schemas.\")\n\nexport type CodeFrontmatter = z.infer<typeof codeFrontmatterSchema>\n","import { createDoctype } from \"@agentproto/define-doctype\"\nimport { codeFrontmatterSchema } from \"./schema.js\"\nimport type { CodeDefinition, CodeHandle } from \"./types.js\"\n\n/**\n * AIP-26 reference implementation of `defineCode`.\n *\n * Built on `createDoctype` so the cross-AIP invariants (id pattern,\n * description length, top-level freeze, \"defineCode (AIP-26): …\"\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 (`parseCodeManifest`), 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 */\nexport const defineCode = createDoctype<CodeDefinition, CodeHandle>({\n aip: 26,\n name: \"code\",\n validate(def) {\n const result = codeFrontmatterSchema.safeParse(def)\n if (!result.success) {\n throw new Error(\n `defineCode (AIP-26): ${result.error.issues\n .map((i) => `${i.path.join(\".\")}: ${i.message}`)\n .join(\"; \")}`,\n )\n }\n // TODO: spec-26-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 CodeHandle\n },\n})\n"]}
@@ -0,0 +1,33 @@
1
+ import { C as CodeDefinition } from './types-Bdv7YMnS.js';
2
+ export { a as CodeHandle } from './types-Bdv7YMnS.js';
3
+
4
+ /**
5
+ * AIP-26 reference implementation of `defineCode`.
6
+ *
7
+ * Built on `createDoctype` so the cross-AIP invariants (id pattern,
8
+ * description length, top-level freeze, "defineCode (AIP-26): …"
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 (`parseCodeManifest`), 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
+ declare const defineCode: (def: CodeDefinition) => Readonly<CodeDefinition>;
18
+
19
+ /**
20
+ * @agentproto/code — AIP-26 CODE.md `defineCode` reference impl.
21
+ *
22
+ * A composable schema block defining the `code` and `run` fields that declare what files compose a runnable bundle (inline, local, github, ref) and how to invoke them — together with the `code-workspace` first-class kind that other manifests reference.
23
+ *
24
+ * Spec: https://agentproto.sh/docs/aip-26
25
+ *
26
+ * Authoring paths:
27
+ * - TS: `defineCode({...})` → `CodeHandle`
28
+ * - MD: `parseCodeManifest(src) → codeFromManifest({...})` → `CodeHandle`
29
+ */
30
+ declare const SPEC_NAME: "agentcode/v1";
31
+ declare const SPEC_VERSION: "1.0.0-alpha";
32
+
33
+ export { CodeDefinition, SPEC_NAME, SPEC_VERSION, defineCode };
package/dist/index.mjs ADDED
@@ -0,0 +1,14 @@
1
+ export { defineCode } from './chunk-RCJ32GFA.mjs';
2
+
3
+ /**
4
+ * @agentproto/code v0.1.0-alpha
5
+ * AIP-26 CODE.md `defineCode` reference implementation.
6
+ */
7
+
8
+ // src/index.ts
9
+ var SPEC_NAME = "agentcode/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":";;;;;;;;AAYO,IAAM,SAAA,GAAY;AAClB,IAAM,YAAA,GAAe","file":"index.mjs","sourcesContent":["/**\n * @agentproto/code — AIP-26 CODE.md `defineCode` reference impl.\n *\n * A composable schema block defining the `code` and `run` fields that declare what files compose a runnable bundle (inline, local, github, ref) and how to invoke them — together with the `code-workspace` first-class kind that other manifests reference.\n *\n * Spec: https://agentproto.sh/docs/aip-26\n *\n * Authoring paths:\n * - TS: `defineCode({...})` → `CodeHandle`\n * - MD: `parseCodeManifest(src) → codeFromManifest({...})` → `CodeHandle`\n */\n\nexport const SPEC_NAME = \"agentcode/v1\" as const\nexport const SPEC_VERSION = \"1.0.0-alpha\" as const\n\nexport { defineCode } from \"./define-code.js\"\nexport type { CodeDefinition, CodeHandle } from \"./types.js\"\n"]}
@@ -0,0 +1,43 @@
1
+ import { z } from 'zod';
2
+ import { a as CodeHandle } from '../types-Bdv7YMnS.js';
3
+
4
+ /**
5
+ * AIP-26 CODE.md frontmatter zod schema.
6
+ *
7
+ * Generated from `resources/aip-26/draft/CODE.schema.json` via
8
+ * json-schema-to-zod. Imported by both `define-code.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-code.ts`'s `validate(def)` instead.
15
+ */
16
+
17
+ declare const codeFrontmatterSchema: z.ZodRecord<z.ZodString, z.ZodAny>;
18
+ type CodeFrontmatter = z.infer<typeof codeFrontmatterSchema>;
19
+
20
+ /**
21
+ * AIP-26 CODE.md sidecar parser + manifest-to-handle constructor.
22
+ *
23
+ * Mirror of `@agentproto/tool/manifest` and `@agentproto/driver/manifest`:
24
+ * the .md provides metadata; the TS module supplies any spec-specific
25
+ * runtime bits (schemas, execute bodies, …) that can't live in
26
+ * frontmatter. Both inputs end up in `defineCode` so the cross-AIP
27
+ * invariants run uniformly.
28
+ *
29
+ *
30
+ * The frontmatter zod schema below was generated from
31
+ * `resources/aip-26/draft/CODE.schema.json` via json-schema-to-zod.
32
+ * Re-run scaffold-aip to refresh after spec changes (or hand-tune
33
+ * any constraint the converter doesn't capture cleanly).
34
+ */
35
+
36
+ interface CodeManifest {
37
+ frontmatter: CodeFrontmatter;
38
+ body: string;
39
+ }
40
+ declare function parseCodeManifest(source: string): CodeManifest;
41
+ declare function codeFromManifest(manifest: CodeManifest): CodeHandle;
42
+
43
+ export { type CodeFrontmatter, type CodeManifest, codeFromManifest, codeFrontmatterSchema, parseCodeManifest };
@@ -0,0 +1,28 @@
1
+ import { codeFrontmatterSchema, defineCode } from '../chunk-RCJ32GFA.mjs';
2
+ export { codeFrontmatterSchema } from '../chunk-RCJ32GFA.mjs';
3
+ import matter from 'gray-matter';
4
+
5
+ /**
6
+ * @agentproto/code v0.1.0-alpha
7
+ * AIP-26 CODE.md `defineCode` reference implementation.
8
+ */
9
+ function parseCodeManifest(source) {
10
+ const parsed = matter(source);
11
+ if (Object.keys(parsed.data).length === 0) {
12
+ throw new Error("parseCodeManifest: missing or empty frontmatter");
13
+ }
14
+ const result = codeFrontmatterSchema.safeParse(parsed.data);
15
+ if (!result.success) {
16
+ throw new Error(
17
+ `parseCodeManifest: 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 codeFromManifest(manifest) {
23
+ return defineCode(manifest.frontmatter);
24
+ }
25
+
26
+ export { codeFromManifest, parseCodeManifest };
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,kBAAkB,MAAA,EAA8B;AAC9D,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,iDAAiD,CAAA;AAAA,EACnE;AACA,EAAA,MAAM,MAAA,GAAS,qBAAA,CAAsB,SAAA,CAAU,MAAA,CAAO,IAAI,CAAA;AAC1D,EAAA,IAAI,CAAC,OAAO,OAAA,EAAS;AACnB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,8CAAA,EAA4C,OAAO,KAAA,CAAM,MAAA,CACtD,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,iBAAiB,QAAA,EAAoC;AAKnE,EAAA,OAAO,UAAA,CAAW,SAAS,WAAwC,CAAA;AACrE","file":"index.mjs","sourcesContent":["/**\n * AIP-26 CODE.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 `defineCode` so the cross-AIP\n * invariants run uniformly.\n *\n *\n * The frontmatter zod schema below was generated from\n * `resources/aip-26/draft/CODE.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 { codeFrontmatterSchema, type CodeFrontmatter } from \"../schema.js\"\nimport { defineCode } from \"../define-code.js\"\nimport type { CodeDefinition, CodeHandle } from \"../types.js\"\n\n// Re-export so consumers can import the schema + inferred type either\n// from \"@@agentproto/code/manifest\" or directly from \"@@agentproto/code/schema\".\nexport { codeFrontmatterSchema, type CodeFrontmatter }\n\nexport interface CodeManifest {\n frontmatter: CodeFrontmatter\n body: string\n}\n\nexport function parseCodeManifest(source: string): CodeManifest {\n const parsed = matter(source)\n if (Object.keys(parsed.data).length === 0) {\n throw new Error(\"parseCodeManifest: missing or empty frontmatter\")\n }\n const result = codeFrontmatterSchema.safeParse(parsed.data)\n if (!result.success) {\n throw new Error(\n `parseCodeManifest: 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 codeFromManifest(manifest: CodeManifest): CodeHandle {\n // The zod-validated frontmatter is structurally compatible with\n // CodeDefinition; 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 defineCode(manifest.frontmatter as unknown as CodeDefinition)\n}\n"]}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * AIP-26 CodeDefinition + CodeHandle.
3
+ *
4
+ * `CodeDefinition` was generated from
5
+ * `resources/aip-26/draft/CODE.schema.json` via json-schema-to-typescript.
6
+ * `CodeHandle` is the readonly view of the same shape; tighten it
7
+ * by hand for fields that get defaults applied in build().
8
+ */
9
+ /**
10
+ * Composable JSON Schema definitions for the `code` and `run` blocks reused across manifest formats. Other AIPs reference these by $ref into their own schemas.
11
+ */
12
+ interface CodeDefinition {
13
+ }
14
+ type CodeHandle = Readonly<CodeDefinition>;
15
+
16
+ export type { CodeDefinition as C, CodeHandle as a };
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@agentproto/code",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "@agentproto/code — AIP-26 CODE.md reference implementation. A composable schema block defining the `code` and `run` fields that declare what files compose a runnable bundle (inline, local, github, ref) and how to invoke them — together with the `code-workspace` first-class kind that other manifests reference.",
5
+ "keywords": [
6
+ "agentproto",
7
+ "aip-26",
8
+ "code",
9
+ "defineCode",
10
+ "open-standard",
11
+ "agentic"
12
+ ],
13
+ "homepage": "https://agentproto.sh/docs/aip-26",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/agentproto/ts",
17
+ "directory": "packages/code"
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
+ }