@agentproto/playbook 0.1.0-alpha.1
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 +21 -0
- package/README.md +23 -0
- package/dist/chunk-QFIVEUBZ.mjs +38 -0
- package/dist/chunk-QFIVEUBZ.mjs.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.mjs +14 -0
- package/dist/index.mjs.map +1 -0
- package/dist/manifest/index.d.ts +71 -0
- package/dist/manifest/index.mjs +28 -0
- package/dist/manifest/index.mjs.map +1 -0
- package/dist/types-RHBIDQcG.d.ts +129 -0
- package/package.json +68 -0
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/playbook
|
|
2
|
+
|
|
3
|
+
AIP-12 `PLAYBOOK.md` reference implementation. A markdown format for prompt-overlay fragments that ride on top of an operator's persona, plus a contract for how runtimes evolve them via reflective deltas without violating locked persona traits.
|
|
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-12>
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { definePlaybook } from "@agentproto/playbook"
|
|
13
|
+
|
|
14
|
+
const x = definePlaybook({
|
|
15
|
+
id: "my-playbook",
|
|
16
|
+
description: "Short purpose.",
|
|
17
|
+
// ...
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
MIT — see [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createDoctype } from '@agentproto/define-doctype';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @agentproto/playbook v0.1.0-alpha
|
|
6
|
+
* AIP-12 PLAYBOOK.md `definePlaybook` reference implementation.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var playbookFrontmatterSchema = z.object({ "schema": z.literal("playbooks/v1"), "slug": z.string().regex(new RegExp("^[a-z][a-z0-9-]*[a-z0-9]$")).min(2).max(80), "title": z.string().min(1).max(200), "entry": z.string().describe("Optional path to the entry file exposing definePlaybook. Defaults to playbook.ts.").optional(), "targets": z.array(z.any()).min(1).describe("DEPRECATED in favor of `selector`. Legacy axis-ambiguous binding \u2014 kept valid forever.").optional(), "selector": z.record(z.string(), z.any()).describe("Typed attachment binding evaluated against the subject's dimensions. Wins over `targets`/`binds_operator` when present.").optional(), "kind": z.enum(["overlay", "block-replacement"]).default("overlay"), "block": z.string().regex(new RegExp("^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)*$")).describe("Required when kind is 'block-replacement' \u2014 the named persona block to swap.").optional(), "priority": z.number().int().gte(0).lte(100).default(50), "lock_check": z.array(z.any()).describe("Locked persona traits this overlay MUST NOT modify. Author intent \u2014 runtime enforces independently.").default([]), "ttl": z.string().regex(new RegExp("^P(?:\\d+Y)?(?:\\d+M)?(?:\\d+W)?(?:\\d+D)?(?:T(?:\\d+H)?(?:\\d+M)?(?:\\d+S)?)?$")).describe("Optional ISO 8601 duration. Auto-archives at updated_at + ttl.").optional(), "evidence": z.array(z.any()).min(1), "status": z.enum(["shadow", "active", "archived"]).default("shadow"), "supersedes": z.array(z.any()).default([]), "history": z.array(z.any()).describe("Append-only audit trail of deltas, promotions, and archivals applied to this playbook.").default([]), "binds_operator": z.string().regex(new RegExp("^[a-z][a-z0-9-]*[a-z0-9]$")).describe("Optional \u2014 the specific operator (per AIP-9) this playbook is bound to. Narrower than targets[].").optional(), "created_at": z.string().datetime({ offset: true }).optional(), "updated_at": z.string().datetime({ offset: true }).optional(), "tags": z.array(z.string().regex(new RegExp("^[a-z][a-z0-9-]*$"))).default([]), "metadata": z.record(z.string(), z.any()).describe("Vendor extensions go under metadata.<vendor>.").default({}) }).strict().and(z.any()).describe("Validates the YAML frontmatter portion of an AIP-12 PLAYBOOK.md overlay manifest.");
|
|
10
|
+
var definePlaybook = createDoctype({
|
|
11
|
+
aip: 12,
|
|
12
|
+
name: "playbook",
|
|
13
|
+
readIdentity: (def) => def.slug,
|
|
14
|
+
readDescription: (def) => def.title,
|
|
15
|
+
validate(def) {
|
|
16
|
+
const result = playbookFrontmatterSchema.safeParse(def);
|
|
17
|
+
if (!result.success) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`definePlaybook (AIP-12): ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
const hasTargets = Array.isArray(def.targets) && def.targets.length > 0;
|
|
23
|
+
const selector = def.selector;
|
|
24
|
+
const hasSelector = !!selector && typeof selector === "object" && Object.keys(selector).length > 0;
|
|
25
|
+
if (!hasTargets && !hasSelector) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
"definePlaybook (AIP-12): a binding is required \u2014 declare `selector` (preferred) or legacy `targets`"
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
build(def) {
|
|
32
|
+
return { ...def };
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export { definePlaybook, playbookFrontmatterSchema };
|
|
37
|
+
//# sourceMappingURL=chunk-QFIVEUBZ.mjs.map
|
|
38
|
+
//# sourceMappingURL=chunk-QFIVEUBZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema.ts","../src/define-playbook.ts"],"names":[],"mappings":";;;;;;;;AAeO,IAAM,yBAAA,GAA4B,CAAA,CAAE,MAAA,CAAO,EAAE,QAAA,EAAU,CAAA,CAAE,OAAA,CAAQ,cAAc,CAAA,EAAG,MAAA,EAAQ,CAAA,CAAE,MAAA,GAAS,KAAA,CAAM,IAAI,MAAA,CAAO,2BAA2B,CAAC,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,GAAA,CAAI,EAAE,CAAA,EAAG,OAAA,EAAS,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA,EAAG,OAAA,EAAS,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,CAAS,mFAAmF,CAAA,CAAE,QAAA,EAAS,EAAG,SAAA,EAAW,CAAA,CAAE,MAAM,CAAA,CAAE,GAAA,EAAK,CAAA,CAAE,GAAA,CAAI,C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OAAA,EAAS;AACnB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,yBAAA,EAA4B,OAAO,KAAA,CAAM,MAAA,CACtC,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;AAGA,IAAA,MAAM,UAAA,GAAa,MAAM,OAAA,CAAQ,GAAA,CAAI,OAAO,CAAA,IAAK,GAAA,CAAI,QAAQ,MAAA,GAAS,CAAA;AACtE,IAAA,MAAM,WAAW,GAAA,CAAI,QAAA;AACrB,IAAA,MAAM,WAAA,GACJ,CAAC,CAAC,QAAA,IACF,OAAO,QAAA,KAAa,QAAA,IACpB,MAAA,CAAO,IAAA,CAAK,QAAQ,CAAA,CAAE,MAAA,GAAS,CAAA;AACjC,IAAA,IAAI,CAAC,UAAA,IAAc,CAAC,WAAA,EAAa;AAC/B,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EAGF,CAAA;AAAA,EACA,MAAM,GAAA,EAAK;AAKT,IAAA,OAAO,EAAE,GAAG,GAAA,EAAI;AAAA,EAClB;AACF,CAAC","file":"chunk-QFIVEUBZ.mjs","sourcesContent":["/**\n * AIP-12 PLAYBOOK.md frontmatter zod schema.\n *\n * Generated from `resources/aip-12/draft/PLAYBOOK.schema.json` via\n * json-schema-to-zod. Imported by both `define-playbook.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-playbook.ts`'s `validate(def)` instead.\n */\n\nimport { z } from \"zod\"\n\nexport const playbookFrontmatterSchema = z.object({ \"schema\": z.literal(\"playbooks/v1\"), \"slug\": z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*[a-z0-9]$\")).min(2).max(80), \"title\": z.string().min(1).max(200), \"entry\": z.string().describe(\"Optional path to the entry file exposing definePlaybook. Defaults to playbook.ts.\").optional(), \"targets\": z.array(z.any()).min(1).describe(\"DEPRECATED in favor of `selector`. Legacy axis-ambiguous binding — kept valid forever.\").optional(), \"selector\": z.record(z.string(), z.any()).describe(\"Typed attachment binding evaluated against the subject's dimensions. Wins over `targets`/`binds_operator` when present.\").optional(), \"kind\": z.enum([\"overlay\",\"block-replacement\"]).default(\"overlay\"), \"block\": z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*(\\\\.[a-z][a-z0-9-]*)*$\")).describe(\"Required when kind is 'block-replacement' — the named persona block to swap.\").optional(), \"priority\": z.number().int().gte(0).lte(100).default(50), \"lock_check\": z.array(z.any()).describe(\"Locked persona traits this overlay MUST NOT modify. Author intent — runtime enforces independently.\").default([] as never), \"ttl\": z.string().regex(new RegExp(\"^P(?:\\\\d+Y)?(?:\\\\d+M)?(?:\\\\d+W)?(?:\\\\d+D)?(?:T(?:\\\\d+H)?(?:\\\\d+M)?(?:\\\\d+S)?)?$\")).describe(\"Optional ISO 8601 duration. Auto-archives at updated_at + ttl.\").optional(), \"evidence\": z.array(z.any()).min(1), \"status\": z.enum([\"shadow\",\"active\",\"archived\"]).default(\"shadow\"), \"supersedes\": z.array(z.any()).default([] as never), \"history\": z.array(z.any()).describe(\"Append-only audit trail of deltas, promotions, and archivals applied to this playbook.\").default([] as never), \"binds_operator\": z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*[a-z0-9]$\")).describe(\"Optional — the specific operator (per AIP-9) this playbook is bound to. Narrower than targets[].\").optional(), \"created_at\": z.string().datetime({ offset: true }).optional(), \"updated_at\": z.string().datetime({ offset: true }).optional(), \"tags\": z.array(z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*$\"))).default([] as never), \"metadata\": z.record(z.string(), z.any()).describe(\"Vendor extensions go under metadata.<vendor>.\").default({} as never) }).strict().and(z.any()).describe(\"Validates the YAML frontmatter portion of an AIP-12 PLAYBOOK.md overlay manifest.\")\n\nexport type PlaybookFrontmatter = z.infer<typeof playbookFrontmatterSchema>\n","import { createDoctype } from \"@agentproto/define-doctype\"\nimport { playbookFrontmatterSchema } from \"./schema.js\"\nimport type { PlaybookDefinition, PlaybookHandle } from \"./types.js\"\n\n/**\n * AIP-12 reference implementation of `definePlaybook`.\n *\n * Built on `createDoctype` so the cross-AIP invariants (id pattern,\n * description length, top-level freeze, \"definePlaybook (AIP-12): …\"\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 (`parsePlaybookManifest`), 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.slug\n * readDescription: def.title.\n */\nexport const definePlaybook = createDoctype<PlaybookDefinition, PlaybookHandle>({\n aip: 12,\n name: \"playbook\",\n readIdentity: (def) => def.slug,\n readDescription: (def) => def.title,\n validate(def) {\n const result = playbookFrontmatterSchema.safeParse(def)\n if (!result.success) {\n throw new Error(\n `definePlaybook (AIP-12): ${result.error.issues\n .map((i) => `${i.path.join(\".\")}: ${i.message}`)\n .join(\"; \")}`,\n )\n }\n // Cross-field binding rule (anyOf in the JSON Schema): at least\n // one of `selector` (preferred) / legacy `targets` must be present.\n const hasTargets = Array.isArray(def.targets) && def.targets.length > 0\n const selector = def.selector\n const hasSelector =\n !!selector &&\n typeof selector === \"object\" &&\n Object.keys(selector).length > 0\n if (!hasTargets && !hasSelector) {\n throw new Error(\n \"definePlaybook (AIP-12): a binding is required — declare `selector` (preferred) or legacy `targets`\",\n )\n }\n // TODO: remaining cross-field rules (kind=block-replacement →\n // `block` required). 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 PlaybookHandle\n },\n})\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { P as PlaybookDefinition } from './types-RHBIDQcG.js';
|
|
2
|
+
export { a as PlaybookHandle } from './types-RHBIDQcG.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AIP-12 reference implementation of `definePlaybook`.
|
|
6
|
+
*
|
|
7
|
+
* Built on `createDoctype` so the cross-AIP invariants (id pattern,
|
|
8
|
+
* description length, top-level freeze, "definePlaybook (AIP-12): …"
|
|
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 (`parsePlaybookManifest`), 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.slug
|
|
19
|
+
* readDescription: def.title.
|
|
20
|
+
*/
|
|
21
|
+
declare const definePlaybook: (def: PlaybookDefinition) => Readonly<PlaybookDefinition>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @agentproto/playbook — AIP-12 PLAYBOOK.md `definePlaybook` reference impl.
|
|
25
|
+
*
|
|
26
|
+
* A markdown format for prompt-overlay fragments that ride on top of an operator's persona, plus a contract for how runtimes evolve them via reflective deltas without violating locked persona traits.
|
|
27
|
+
*
|
|
28
|
+
* Spec: https://agentproto.sh/docs/aip-12
|
|
29
|
+
*
|
|
30
|
+
* Authoring paths:
|
|
31
|
+
* - TS: `definePlaybook({...})` → `PlaybookHandle`
|
|
32
|
+
* - MD: `parsePlaybookManifest(src) → playbookFromManifest({...})` → `PlaybookHandle`
|
|
33
|
+
*/
|
|
34
|
+
declare const SPEC_NAME: "agentplaybook/v1";
|
|
35
|
+
declare const SPEC_VERSION: "1.0.0-alpha";
|
|
36
|
+
|
|
37
|
+
export { PlaybookDefinition, SPEC_NAME, SPEC_VERSION, definePlaybook };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { definePlaybook } from './chunk-QFIVEUBZ.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @agentproto/playbook v0.1.0-alpha
|
|
5
|
+
* AIP-12 PLAYBOOK.md `definePlaybook` reference implementation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// src/index.ts
|
|
9
|
+
var SPEC_NAME = "agentplaybook/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/playbook — AIP-12 PLAYBOOK.md `definePlaybook` reference impl.\n *\n * A markdown format for prompt-overlay fragments that ride on top of an operator's persona, plus a contract for how runtimes evolve them via reflective deltas without violating locked persona traits.\n *\n * Spec: https://agentproto.sh/docs/aip-12\n *\n * Authoring paths:\n * - TS: `definePlaybook({...})` → `PlaybookHandle`\n * - MD: `parsePlaybookManifest(src) → playbookFromManifest({...})` → `PlaybookHandle`\n */\n\nexport const SPEC_NAME = \"agentplaybook/v1\" as const\nexport const SPEC_VERSION = \"1.0.0-alpha\" as const\n\nexport { definePlaybook } from \"./define-playbook.js\"\nexport type { PlaybookDefinition, PlaybookHandle } from \"./types.js\"\n"]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { a as PlaybookHandle } from '../types-RHBIDQcG.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AIP-12 PLAYBOOK.md frontmatter zod schema.
|
|
6
|
+
*
|
|
7
|
+
* Generated from `resources/aip-12/draft/PLAYBOOK.schema.json` via
|
|
8
|
+
* json-schema-to-zod. Imported by both `define-playbook.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-playbook.ts`'s `validate(def)` instead.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
declare const playbookFrontmatterSchema: z.ZodIntersection<z.ZodObject<{
|
|
18
|
+
schema: z.ZodLiteral<"playbooks/v1">;
|
|
19
|
+
slug: z.ZodString;
|
|
20
|
+
title: z.ZodString;
|
|
21
|
+
entry: z.ZodOptional<z.ZodString>;
|
|
22
|
+
targets: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
23
|
+
selector: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
24
|
+
kind: z.ZodDefault<z.ZodEnum<{
|
|
25
|
+
overlay: "overlay";
|
|
26
|
+
"block-replacement": "block-replacement";
|
|
27
|
+
}>>;
|
|
28
|
+
block: z.ZodOptional<z.ZodString>;
|
|
29
|
+
priority: z.ZodDefault<z.ZodNumber>;
|
|
30
|
+
lock_check: z.ZodDefault<z.ZodArray<z.ZodAny>>;
|
|
31
|
+
ttl: z.ZodOptional<z.ZodString>;
|
|
32
|
+
evidence: z.ZodArray<z.ZodAny>;
|
|
33
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
34
|
+
shadow: "shadow";
|
|
35
|
+
active: "active";
|
|
36
|
+
archived: "archived";
|
|
37
|
+
}>>;
|
|
38
|
+
supersedes: z.ZodDefault<z.ZodArray<z.ZodAny>>;
|
|
39
|
+
history: z.ZodDefault<z.ZodArray<z.ZodAny>>;
|
|
40
|
+
binds_operator: z.ZodOptional<z.ZodString>;
|
|
41
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
42
|
+
updated_at: z.ZodOptional<z.ZodString>;
|
|
43
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
44
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
45
|
+
}, z.core.$strict>, z.ZodAny>;
|
|
46
|
+
type PlaybookFrontmatter = z.infer<typeof playbookFrontmatterSchema>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* AIP-12 PLAYBOOK.md sidecar parser + manifest-to-handle constructor.
|
|
50
|
+
*
|
|
51
|
+
* Mirror of `@agentproto/tool/manifest` and `@agentproto/driver/manifest`:
|
|
52
|
+
* the .md provides metadata; the TS module supplies any spec-specific
|
|
53
|
+
* runtime bits (schemas, execute bodies, …) that can't live in
|
|
54
|
+
* frontmatter. Both inputs end up in `definePlaybook` so the cross-AIP
|
|
55
|
+
* invariants run uniformly.
|
|
56
|
+
*
|
|
57
|
+
*
|
|
58
|
+
* The frontmatter zod schema below was generated from
|
|
59
|
+
* `resources/aip-12/draft/PLAYBOOK.schema.json` via json-schema-to-zod.
|
|
60
|
+
* Re-run scaffold-aip to refresh after spec changes (or hand-tune
|
|
61
|
+
* any constraint the converter doesn't capture cleanly).
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
interface PlaybookManifest {
|
|
65
|
+
frontmatter: PlaybookFrontmatter;
|
|
66
|
+
body: string;
|
|
67
|
+
}
|
|
68
|
+
declare function parsePlaybookManifest(source: string): PlaybookManifest;
|
|
69
|
+
declare function playbookFromManifest(manifest: PlaybookManifest): PlaybookHandle;
|
|
70
|
+
|
|
71
|
+
export { type PlaybookFrontmatter, type PlaybookManifest, parsePlaybookManifest, playbookFromManifest, playbookFrontmatterSchema };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { playbookFrontmatterSchema, definePlaybook } from '../chunk-QFIVEUBZ.mjs';
|
|
2
|
+
export { playbookFrontmatterSchema } from '../chunk-QFIVEUBZ.mjs';
|
|
3
|
+
import matter from 'gray-matter';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @agentproto/playbook v0.1.0-alpha
|
|
7
|
+
* AIP-12 PLAYBOOK.md `definePlaybook` reference implementation.
|
|
8
|
+
*/
|
|
9
|
+
function parsePlaybookManifest(source) {
|
|
10
|
+
const parsed = matter(source);
|
|
11
|
+
if (Object.keys(parsed.data).length === 0) {
|
|
12
|
+
throw new Error("parsePlaybookManifest: missing or empty frontmatter");
|
|
13
|
+
}
|
|
14
|
+
const result = playbookFrontmatterSchema.safeParse(parsed.data);
|
|
15
|
+
if (!result.success) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
`parsePlaybookManifest: 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 playbookFromManifest(manifest) {
|
|
23
|
+
return definePlaybook(manifest.frontmatter);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { parsePlaybookManifest, playbookFromManifest };
|
|
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-12 PLAYBOOK.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 `definePlaybook` so the cross-AIP\n * invariants run uniformly.\n *\n *\n * The frontmatter zod schema below was generated from\n * `resources/aip-12/draft/PLAYBOOK.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 { playbookFrontmatterSchema, type PlaybookFrontmatter } from \"../schema.js\"\nimport { definePlaybook } from \"../define-playbook.js\"\nimport type { PlaybookDefinition, PlaybookHandle } from \"../types.js\"\n\n// Re-export so consumers can import the schema + inferred type either\n// from \"@@agentproto/playbook/manifest\" or directly from \"@@agentproto/playbook/schema\".\nexport { playbookFrontmatterSchema, type PlaybookFrontmatter }\n\nexport interface PlaybookManifest {\n frontmatter: PlaybookFrontmatter\n body: string\n}\n\nexport function parsePlaybookManifest(source: string): PlaybookManifest {\n const parsed = matter(source)\n if (Object.keys(parsed.data).length === 0) {\n throw new Error(\"parsePlaybookManifest: missing or empty frontmatter\")\n }\n const result = playbookFrontmatterSchema.safeParse(parsed.data)\n if (!result.success) {\n throw new Error(\n `parsePlaybookManifest: 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 playbookFromManifest(manifest: PlaybookManifest): PlaybookHandle {\n // The zod-validated frontmatter is structurally compatible with\n // PlaybookDefinition; 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 definePlaybook(manifest.frontmatter as unknown as PlaybookDefinition)\n}\n"]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AIP-12 PlaybookDefinition + PlaybookHandle.
|
|
3
|
+
*
|
|
4
|
+
* `PlaybookDefinition` was generated from
|
|
5
|
+
* `resources/aip-12/draft/PLAYBOOK.schema.json` via json-schema-to-typescript.
|
|
6
|
+
* `PlaybookHandle` is the readonly view of the same shape; tighten it
|
|
7
|
+
* by hand for fields that get defaults applied in build().
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Validates the YAML frontmatter portion of an AIP-12 PLAYBOOK.md overlay manifest.
|
|
11
|
+
*/
|
|
12
|
+
type PlaybookDefinition = {
|
|
13
|
+
[k: string]: unknown;
|
|
14
|
+
} & {
|
|
15
|
+
schema: "playbooks/v1";
|
|
16
|
+
slug: string;
|
|
17
|
+
title: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional path to the entry file exposing definePlaybook. Defaults to playbook.ts.
|
|
20
|
+
*/
|
|
21
|
+
entry?: string;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated In favor of `selector`. Legacy axis-ambiguous binding —
|
|
24
|
+
* runtimes compile it into a selector (see AIP-12 §Selector binding).
|
|
25
|
+
* Kept valid forever. At least one of `targets` / `selector` is required.
|
|
26
|
+
*
|
|
27
|
+
* @minItems 1
|
|
28
|
+
*/
|
|
29
|
+
targets?: [Target, ...Target[]];
|
|
30
|
+
/**
|
|
31
|
+
* Typed attachment binding evaluated against the subject's dimensions.
|
|
32
|
+
* Short form: axis → ref | ref[] (AND across keys, OR within a list).
|
|
33
|
+
* Long form: `allOf` / `anyOf` lists of `{axis, anyOf}` terms.
|
|
34
|
+
* Wins over `targets`/`binds_operator` when present.
|
|
35
|
+
*/
|
|
36
|
+
selector?: SelectorFrontmatter;
|
|
37
|
+
kind: "overlay" | "block-replacement";
|
|
38
|
+
/**
|
|
39
|
+
* Required when kind is 'block-replacement' — the named persona block to swap.
|
|
40
|
+
*/
|
|
41
|
+
block?: string;
|
|
42
|
+
priority?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Locked persona traits this overlay MUST NOT modify. Author intent — runtime enforces independently.
|
|
45
|
+
*/
|
|
46
|
+
lock_check: TraitId[];
|
|
47
|
+
/**
|
|
48
|
+
* Optional ISO 8601 duration. Auto-archives at updated_at + ttl.
|
|
49
|
+
*/
|
|
50
|
+
ttl?: string;
|
|
51
|
+
/**
|
|
52
|
+
* @minItems 1
|
|
53
|
+
*/
|
|
54
|
+
evidence: [EvidenceItem, ...EvidenceItem[]];
|
|
55
|
+
status: "shadow" | "active" | "archived";
|
|
56
|
+
supersedes?: Slug[];
|
|
57
|
+
/**
|
|
58
|
+
* Append-only audit trail of deltas, promotions, and archivals applied to this playbook.
|
|
59
|
+
*/
|
|
60
|
+
history?: HistoryEntry[];
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated As a binding — provenance only when `selector` is present.
|
|
63
|
+
* Without `selector`, runtimes compile it like a kind 'operator' target
|
|
64
|
+
* (matches BOTH identity and role axes).
|
|
65
|
+
*/
|
|
66
|
+
binds_operator?: string;
|
|
67
|
+
created_at?: string;
|
|
68
|
+
updated_at?: string;
|
|
69
|
+
tags?: string[];
|
|
70
|
+
/**
|
|
71
|
+
* Vendor extensions go under metadata.<vendor>.
|
|
72
|
+
*/
|
|
73
|
+
metadata?: {
|
|
74
|
+
[k: string]: unknown;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
type TraitId = string;
|
|
78
|
+
type Slug = string;
|
|
79
|
+
/** Axis value slug, prefixed ref (e.g. 'role/sales-rep'), or '*' (any present value). */
|
|
80
|
+
type SelectorRef = string;
|
|
81
|
+
interface SelectorTermFrontmatter {
|
|
82
|
+
axis: string;
|
|
83
|
+
/**
|
|
84
|
+
* @minItems 1
|
|
85
|
+
*/
|
|
86
|
+
anyOf: [SelectorRef, ...SelectorRef[]];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Short form: axis keys → ref | ref[]. Long form: explicit `allOf` /
|
|
90
|
+
* `anyOf` term lists for OR across axes.
|
|
91
|
+
*/
|
|
92
|
+
type SelectorFrontmatter = {
|
|
93
|
+
allOf?: SelectorTermFrontmatter[];
|
|
94
|
+
anyOf?: SelectorTermFrontmatter[];
|
|
95
|
+
} & {
|
|
96
|
+
[axis: string]: SelectorRef | SelectorRef[] | SelectorTermFrontmatter[] | undefined;
|
|
97
|
+
};
|
|
98
|
+
interface Target {
|
|
99
|
+
kind: "operator" | "role" | "skill" | "runtime";
|
|
100
|
+
/**
|
|
101
|
+
* Slug, glob, or qualified path. Examples: 'role/companion', 'operator/alice', 'skill/research', 'operator/*'.
|
|
102
|
+
*/
|
|
103
|
+
ref: string;
|
|
104
|
+
}
|
|
105
|
+
interface EvidenceItem {
|
|
106
|
+
kind: "run" | "conversation" | "work-item" | "reflection" | "human";
|
|
107
|
+
ref: string;
|
|
108
|
+
note?: string;
|
|
109
|
+
}
|
|
110
|
+
interface HistoryEntry {
|
|
111
|
+
at: string;
|
|
112
|
+
kind: "created" | "delta" | "promoted" | "archived" | "superseded" | "lock-violation";
|
|
113
|
+
summary: string;
|
|
114
|
+
/**
|
|
115
|
+
* Pointer to the run/reflection/governance ticket that produced this entry.
|
|
116
|
+
*/
|
|
117
|
+
source?: string;
|
|
118
|
+
/**
|
|
119
|
+
* User id, agent id, or system identifier responsible for the entry.
|
|
120
|
+
*/
|
|
121
|
+
by?: string;
|
|
122
|
+
/**
|
|
123
|
+
* For kind='promoted', the gate that passed.
|
|
124
|
+
*/
|
|
125
|
+
gate?: "a-b" | "scorer" | "human" | "governance";
|
|
126
|
+
}
|
|
127
|
+
type PlaybookHandle = Readonly<PlaybookDefinition>;
|
|
128
|
+
|
|
129
|
+
export type { PlaybookDefinition as P, PlaybookHandle as a };
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentproto/playbook",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "@agentproto/playbook — AIP-12 PLAYBOOK.md reference implementation. A markdown format for prompt-overlay fragments that ride on top of an operator's persona, plus a contract for how runtimes evolve them via reflective deltas without violating locked persona traits.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agentproto",
|
|
7
|
+
"aip-12",
|
|
8
|
+
"playbook",
|
|
9
|
+
"definePlaybook",
|
|
10
|
+
"open-standard",
|
|
11
|
+
"agentic"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://agentproto.sh/docs/aip-12",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/agentproto/ts",
|
|
17
|
+
"directory": "packages/playbook"
|
|
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
|
+
}
|