@agentproto/knowledge 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 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/knowledge
2
+
3
+ AIP-10 `KNOWLEDGE.md` reference implementation. A filesystem-first knowledge-base format where an LLM curates, links, and lints a markdown wiki on top of immutable raw sources, turning agent knowledge into a compounding artifact instead of a per-query retrieval miss.
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-10>
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ import { defineKnowledge } from "@agentproto/knowledge"
13
+
14
+ const x = defineKnowledge({
15
+ id: "my-knowledge",
16
+ description: "Short purpose.",
17
+ // ...
18
+ })
19
+ ```
20
+
21
+ ## License
22
+
23
+ MIT — see [LICENSE](./LICENSE).
@@ -0,0 +1,50 @@
1
+ import { z } from 'zod';
2
+ import { createDoctype } from '@agentproto/define-doctype';
3
+
4
+ /**
5
+ * @agentproto/knowledge v0.1.0-alpha
6
+ * AIP-10 KNOWLEDGE.md `defineKnowledge` reference implementation.
7
+ */
8
+
9
+ var knowledgeFrontmatterSchema = z.discriminatedUnion("schema", [
10
+ z.object({ "schema": z.literal("knowledge.entry/v1").describe("Discriminator for curated wiki entries. Mutable doctype."), "slug": z.string().regex(new RegExp("^[a-z][a-z0-9-]*[a-z0-9]$")).min(2).max(96).describe("Stable kebab-case identifier. Used as the wikilink target ([[slug]]) and as the entry's path stem."), "kind": z.string().regex(new RegExp("^[a-z][a-z0-9-]*$")).min(2).max(32).describe("Entry kind. The wiki's KNOWLEDGE.md (entityTypes) and AGENTS.md schema together define the allowed values; common ones are 'entity', 'concept', 'summary', 'comparison', 'timeline'."), "title": z.string().min(1).max(200).describe("Human-readable page title."), "sources": z.array(z.string().regex(new RegExp("^[a-z0-9][a-z0-9-]*$")).min(2).max(96).describe("Source id (NOT path). The host resolves ids against the source registry.")).describe("Provenance \u2014 list of source ids that back the claims in this entry's body.").default([]), "confidence": z.number().gte(0).lte(1).describe("Curation agent's confidence in the entry's claims. Advisory; downstream consumers may weight it against source authority and recency.").default(1), "updated_at": z.string().datetime({ offset: true }).describe("ISO 8601 timestamp of the last patch to this entry. MUST be set on every write."), "supersedes": z.array(z.string().regex(new RegExp("^[a-z][a-z0-9-]*[a-z0-9]$"))).describe("Slugs of earlier entries that this one replaces. Resolution rules live in the wiki's KNOWLEDGE.md curation.conflictResolution policy.").default([]), "contradicts": z.array(z.string().regex(new RegExp("^[a-z][a-z0-9-]*[a-z0-9]$"))).describe("Slugs of entries whose claims conflict with this one and that the contradiction policy could not auto-resolve. Surfaces in lint.").default([]), "links": z.array(z.string().regex(new RegExp("^[a-z][a-z0-9-]*[a-z0-9]$"))).describe("OPTIONAL hint to the link resolver \u2014 slugs this entry links to. The resolver also walks the body for [[slug]] and markdown links; this field is for entries whose links are computed.").default([]), "tags": z.array(z.string().regex(new RegExp("^[a-z][a-z0-9-]*$"))).describe("Free-form tags; consumed by retrieval, search, and grouping in _index.md.").default([]), "metadata": z.record(z.string(), z.any()).describe("Vendor-specific extensions. Hosts MUST tolerate unknown keys; the spec's normative fields MUST NOT change meaning.").default({}) }).strict(),
11
+ z.object({ "schema": z.literal("knowledge.source/v1").describe("Discriminator for raw sources. Immutable doctype \u2014 once registered, the host MUST refuse mutations to the file's bytes."), "id": z.string().regex(new RegExp("^[a-z0-9][a-z0-9-]*$")).min(2).max(96).describe("Stable kebab-case source id, ISO-prefixed when possible (e.g. '2026-04-27-investor-call'). Entries reference sources by id, never by path."), "path": z.string().regex(new RegExp("^sources/")).describe("Path to the raw bytes, relative to the wiki root. MUST start with 'sources/'. The host pins this file once defineSource succeeds."), "title": z.string().min(1).max(200).describe("Human-readable source title."), "captured_at": z.string().datetime({ offset: true }).describe("ISO 8601 timestamp of when the source entered the wiki."), "captured_by": z.string().max(200).describe("OPTIONAL \u2014 author or operator who pinned the source. May be a user identifier, an agent id, or an upstream system name.").optional(), "content_hash": z.string().regex(new RegExp("^(sha256|sha512|blake3):[A-Fa-f0-9]+$")).describe("Cryptographic hash of the file bytes. sha256 is required by the spec; other algorithms MAY appear in additional sidecar fields. Once set, the file is pinned."), "authority": z.enum(["primary", "secondary", "rumour"]).describe("Source authority class. 'primary' = first-party document or recording; 'secondary' = derived analysis; 'rumour' = unverified claim. Consumed by contradiction policy.").default("secondary"), "language": z.string().regex(new RegExp("^[a-z]{2}(-[A-Z]{2})?$")).describe("OPTIONAL \u2014 BCP-47 language code of the source. Useful for ingest pipelines that pick a translator.").optional(), "superseded_by": z.string().regex(new RegExp("^[a-z0-9][a-z0-9-]*$")).describe("OPTIONAL \u2014 id of a newer source that replaces this one. The host writes this; agents do not edit the source file's bytes to 'correct' it. Tombstones the source for contradiction-policy purposes while preserving the original bytes.").optional(), "tags": z.array(z.string().regex(new RegExp("^[a-z][a-z0-9-]*$"))).default([]), "metadata": z.record(z.string(), z.any()).describe("Vendor-specific extensions. Hosts MUST tolerate unknown keys.").default({}) }).strict(),
12
+ z.object({ "schema": z.literal("knowledge.workspace/v1").describe("Discriminator for the workspace manifest doctype."), "name": z.string().regex(new RegExp("^[a-z][a-z0-9-]*[a-z0-9]$")).min(2).max(96).describe("Stable kebab-case identifier for the workspace or view."), "title": z.string().min(1).max(200).describe("Human-readable workspace title."), "description": z.string().min(1).max(2e3).describe("One-paragraph statement of purpose: what this workspace (or view) is for and who uses it."), "version": z.string().regex(new RegExp("^[0-9]+\\.[0-9]+\\.[0-9]+(-[A-Za-z0-9.-]+)?$")).describe("Semantic version of the WORKSPACE shape. Bump on entityTypes / lints / source / curation changes. Independent of the wiki's content version."), "extends": z.string().regex(new RegExp("^(\\.\\./|\\./)[^\\s]+/KNOWLEDGE\\.md$")).min(1).max(512).describe("OPTIONAL \u2014 relative path to a parent KNOWLEDGE.md. Presence of this field makes the manifest a VIEW; absence makes it a WORKSPACE ROOT. Recursive composition: parents may themselves declare `extends`. Maximum chain depth is 8.").optional(), "appliesTo": z.array(z.string().regex(new RegExp("^(ws://(operators|companies|skills)/[a-z][a-z0-9-]*|\\.\\./[^\\s]+)$")).describe("Either a ws:// ref to an AIP-9 operator / AIP-6 company / AIP-3 skill, or a relative path to a consumer workspace folder.")).refine((arr) => arr.every((item, i) => arr.indexOf(item) == i), { message: "All items must be unique!" }).describe("OPTIONAL \u2014 list of consumers this VIEW adapts the workspace for. Hosts MUST refuse the view if any binding does not resolve. Not inherited; views declare their own scope.").optional(), "curator": z.string().regex(new RegExp("^ws://operators/[a-z][a-z0-9-]*$")).describe("OPTIONAL \u2014 AIP-9 operator that curates this workspace. The host activates this operator for ingest, curation, and lint passes.").optional(), "governance": z.string().min(1).max(512).describe("OPTIONAL \u2014 AIP-7 policy or audit binding. May be a path to an AIP-7 policy file or a ws:// ref. Schema-poisoning mitigations and source-mutation audits flow through this ref.").optional(), "entityTypes": z.array(z.object({ "name": z.string().regex(new RegExp("^[A-Z][A-Za-z0-9]*$")).describe("PascalCase type name. Merge key when composing with extends parent."), "fields": z.array(z.string().regex(new RegExp("^[a-z][A-Za-z0-9_]*$"))).describe("Canonical fields for this entity type. Child views append fields to parent's set.").default([]), "icon": z.string().max(8).describe("OPTIONAL \u2014 display hint, typically a single emoji.").optional(), "description": z.string().max(1e3).describe("OPTIONAL \u2014 prose describing what entries of this type capture.").optional(), "parent": z.string().regex(new RegExp("^[A-Z][A-Za-z0-9]*$")).describe("OPTIONAL \u2014 name of another LOCAL entity type that this one extends. Used for subtyping (e.g. Investor extends Person).").optional() }).strict()).describe("Entity types this workspace recognizes. Merge-by-name against the extends parent: a child entry with the same name replaces the parent's; new names are appended.").default([]), "lints": z.array(z.object({ "id": z.string().regex(new RegExp("^[a-z][a-z0-9-]*$")).describe("Stable kebab-case lint id. Merge key when composing with extends parent."), "kind": z.enum(["require-source", "max-age", "min-confidence", "broken-ref", "orphan", "custom"]).describe("Lint algorithm. 'custom' delegates to a host-defined check identified by `id`."), "appliesTo": z.string().regex(new RegExp("^([A-Z][A-Za-z0-9]*|\\*)$")).describe("Entity type name (e.g. 'Concept') or '*' for all entries."), "severity": z.enum(["error", "warn", "info"]).describe("Lint severity. Child views may soften (warn -> info) but governance policies may forbid that."), "params": z.record(z.string(), z.any()).describe("Kind-specific parameters. e.g. { days: 90 } for 'max-age'; { min: 0.6 } for 'min-confidence'.").default({}) }).strict()).describe("Lint rules. Merge-by-id against the extends parent: a child entry with the same id replaces the parent's; new ids are appended.").default([]), "sources": z.object({ "retention": z.string().regex(new RegExp("^(forever|days:[0-9]+)$")).describe("Source retention. 'forever' (default) or 'days:<n>' for time-limited.").optional(), "signing": z.enum(["required", "optional", "none"]).describe("Whether sources must carry an AIP-7 signature. Composes with AIP-7 governance.").optional(), "hashAlgo": z.enum(["sha256", "sha512", "blake3"]).describe("Default content-hash algorithm for new sources.").optional(), "authorityDefault": z.enum(["primary", "secondary", "rumour"]).describe("Default authority assigned to new sources when defineSource omits the field.").optional() }).strict().describe("Source registry policy. Each leaf field overrides independently across the extends chain.").optional(), "curation": z.object({ "tone": z.string().max(200).describe("Free-form tone hint for the curator agent (e.g. 'academic', 'sales', 'neutral').").optional(), "depth": z.enum(["shallow", "medium", "deep"]).describe("How exhaustive the curator agent should be when distilling sources into entries.").optional(), "autoLink": z.enum(["byName", "manual", "off"]).describe("Auto-linking policy: 'byName' walks bodies for entity names and inserts wikilinks; 'manual' leaves links to the agent; 'off' disables auto-linking entirely.").optional(), "conflictResolution": z.enum(["defer", "recency", "authority", "observation-count", "keep-both"]).describe("How the curator agent resolves contradictions when sources disagree.").optional(), "newEntryThreshold": z.string().max(1e3).describe("Prose hint for when to promote a mention into a full entry (vs leaving it as a body reference).").optional() }).strict().describe("Curation policy. Each leaf field overrides independently across the extends chain.").optional(), "queryHints": z.object({ "preferRecent": z.boolean().describe("When ranking results, weight recency higher.").optional(), "preferAuthoritative": z.boolean().describe("When ranking results, weight authority='primary' higher.").optional(), "scopeTo": z.array(z.string().regex(new RegExp("^[A-Z][A-Za-z0-9]*$"))).refine((arr) => arr.every((item, i) => arr.indexOf(item) == i), { message: "All items must be unique!" }).describe("Default query scope \u2014 entity types this view focuses on. Replaced wholesale by child if present.").optional() }).strict().describe("Hints for how consumers should retrieve from this view.").optional(), "display": z.object({ "homePage": z.string().regex(new RegExp("^[a-z][a-z0-9-]*[a-z0-9]$")).describe("OPTIONAL \u2014 slug of the entry to use as the workspace landing page.").optional(), "defaultGrouping": z.enum(["kind", "tag", "source"]).describe("Default _index.md grouping.").optional() }).strict().describe("Display hints for UIs that render the workspace. Runtime-agnostic.").optional(), "metadata": z.record(z.string(), z.any()).describe("Vendor-specific extensions, namespaced under <vendor>. Deep-merged across the extends chain.").default({}) }).strict().describe("Workspace manifest doctype. Used both as the root manifest of a wiki (no `extends`) and as a per-consumer view (with `extends`). The same schema validates both modes; the host distinguishes by checking whether `extends` is set.")
13
+ ]).describe("Validates the YAML frontmatter portion of an AIP-10 entry, source, or workspace manifest. The doctype is selected via the `schema` discriminator: 'knowledge.entry/v1' (curated, mutable), 'knowledge.source/v1' (raw, immutable), or 'knowledge.workspace/v1' (workspace manifest or per-context view).");
14
+ var defineKnowledge = createDoctype({
15
+ aip: 10,
16
+ name: "knowledge",
17
+ // AIP-10 has three branches with different identity fields:
18
+ // entry → slug
19
+ // source → id
20
+ // workspace → name
21
+ // Dispatch on the `schema` discriminator so the cross-AIP id-pattern
22
+ // check runs against the right token.
23
+ readIdentity: (def) => {
24
+ switch (def.schema) {
25
+ case "knowledge.entry/v1":
26
+ return def.slug;
27
+ case "knowledge.source/v1":
28
+ return def.id;
29
+ case "knowledge.workspace/v1":
30
+ return def.name;
31
+ default:
32
+ return "";
33
+ }
34
+ },
35
+ validate(def) {
36
+ const result = knowledgeFrontmatterSchema.safeParse(def);
37
+ if (!result.success) {
38
+ throw new Error(
39
+ `defineKnowledge (AIP-10): ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
40
+ );
41
+ }
42
+ },
43
+ build(def) {
44
+ return { ...def };
45
+ }
46
+ });
47
+
48
+ export { defineKnowledge, knowledgeFrontmatterSchema };
49
+ //# sourceMappingURL=chunk-27YWFJ6J.mjs.map
50
+ //# sourceMappingURL=chunk-27YWFJ6J.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts","../src/define-knowledge.ts"],"names":[],"mappings":";;;;;;;;AAeO,IAAM,0BAAA,GAA6B,CAAA,CAAE,kBAAA,CAAmB,QAAA,EAAU;AAAA,EACvE,CAAA,CAAE,OAAO,EAAE,QAAA,EAAU,EAAE,OAAA,CAAQ,oBAAoB,CAAA,CAAE,QAAA,CAAS,0DAA0D,CAAA,EAAG,QAAQ,CAAA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,IAAI,CAAC,OAAO,OAAA,EAAS;AACnB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,0BAAA,EAA6B,OAAO,KAAA,CAAM,MAAA,CACvC,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-27YWFJ6J.mjs","sourcesContent":["/**\n * AIP-10 KNOWLEDGE.md frontmatter zod schema.\n *\n * Generated from `resources/aip-10/draft/KNOWLEDGE.schema.json` via\n * json-schema-to-zod. Imported by both `define-knowledge.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-knowledge.ts`'s `validate(def)` instead.\n */\n\nimport { z } from \"zod\"\n\nexport const knowledgeFrontmatterSchema = z.discriminatedUnion(\"schema\", [\n z.object({ \"schema\": z.literal(\"knowledge.entry/v1\").describe(\"Discriminator for curated wiki entries. Mutable doctype.\"), \"slug\": z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*[a-z0-9]$\")).min(2).max(96).describe(\"Stable kebab-case identifier. Used as the wikilink target ([[slug]]) and as the entry's path stem.\"), \"kind\": z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*$\")).min(2).max(32).describe(\"Entry kind. The wiki's KNOWLEDGE.md (entityTypes) and AGENTS.md schema together define the allowed values; common ones are 'entity', 'concept', 'summary', 'comparison', 'timeline'.\"), \"title\": z.string().min(1).max(200).describe(\"Human-readable page title.\"), \"sources\": z.array(z.string().regex(new RegExp(\"^[a-z0-9][a-z0-9-]*$\")).min(2).max(96).describe(\"Source id (NOT path). The host resolves ids against the source registry.\")).describe(\"Provenance — list of source ids that back the claims in this entry's body.\").default([] as never), \"confidence\": z.number().gte(0).lte(1).describe(\"Curation agent's confidence in the entry's claims. Advisory; downstream consumers may weight it against source authority and recency.\").default(1), \"updated_at\": z.string().datetime({ offset: true }).describe(\"ISO 8601 timestamp of the last patch to this entry. MUST be set on every write.\"), \"supersedes\": z.array(z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*[a-z0-9]$\"))).describe(\"Slugs of earlier entries that this one replaces. Resolution rules live in the wiki's KNOWLEDGE.md curation.conflictResolution policy.\").default([] as never), \"contradicts\": z.array(z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*[a-z0-9]$\"))).describe(\"Slugs of entries whose claims conflict with this one and that the contradiction policy could not auto-resolve. Surfaces in lint.\").default([] as never), \"links\": z.array(z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*[a-z0-9]$\"))).describe(\"OPTIONAL hint to the link resolver — slugs this entry links to. The resolver also walks the body for [[slug]] and markdown links; this field is for entries whose links are computed.\").default([] as never), \"tags\": z.array(z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*$\"))).describe(\"Free-form tags; consumed by retrieval, search, and grouping in _index.md.\").default([] as never), \"metadata\": z.record(z.string(), z.any()).describe(\"Vendor-specific extensions. Hosts MUST tolerate unknown keys; the spec's normative fields MUST NOT change meaning.\").default({} as never) }).strict(),\n z.object({ \"schema\": z.literal(\"knowledge.source/v1\").describe(\"Discriminator for raw sources. Immutable doctype — once registered, the host MUST refuse mutations to the file's bytes.\"), \"id\": z.string().regex(new RegExp(\"^[a-z0-9][a-z0-9-]*$\")).min(2).max(96).describe(\"Stable kebab-case source id, ISO-prefixed when possible (e.g. '2026-04-27-investor-call'). Entries reference sources by id, never by path.\"), \"path\": z.string().regex(new RegExp(\"^sources/\")).describe(\"Path to the raw bytes, relative to the wiki root. MUST start with 'sources/'. The host pins this file once defineSource succeeds.\"), \"title\": z.string().min(1).max(200).describe(\"Human-readable source title.\"), \"captured_at\": z.string().datetime({ offset: true }).describe(\"ISO 8601 timestamp of when the source entered the wiki.\"), \"captured_by\": z.string().max(200).describe(\"OPTIONAL — author or operator who pinned the source. May be a user identifier, an agent id, or an upstream system name.\").optional(), \"content_hash\": z.string().regex(new RegExp(\"^(sha256|sha512|blake3):[A-Fa-f0-9]+$\")).describe(\"Cryptographic hash of the file bytes. sha256 is required by the spec; other algorithms MAY appear in additional sidecar fields. Once set, the file is pinned.\"), \"authority\": z.enum([\"primary\",\"secondary\",\"rumour\"]).describe(\"Source authority class. 'primary' = first-party document or recording; 'secondary' = derived analysis; 'rumour' = unverified claim. Consumed by contradiction policy.\").default(\"secondary\"), \"language\": z.string().regex(new RegExp(\"^[a-z]{2}(-[A-Z]{2})?$\")).describe(\"OPTIONAL — BCP-47 language code of the source. Useful for ingest pipelines that pick a translator.\").optional(), \"superseded_by\": z.string().regex(new RegExp(\"^[a-z0-9][a-z0-9-]*$\")).describe(\"OPTIONAL — id of a newer source that replaces this one. The host writes this; agents do not edit the source file's bytes to 'correct' it. Tombstones the source for contradiction-policy purposes while preserving the original bytes.\").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-specific extensions. Hosts MUST tolerate unknown keys.\").default({} as never) }).strict(),\n z.object({ \"schema\": z.literal(\"knowledge.workspace/v1\").describe(\"Discriminator for the workspace manifest doctype.\"), \"name\": z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*[a-z0-9]$\")).min(2).max(96).describe(\"Stable kebab-case identifier for the workspace or view.\"), \"title\": z.string().min(1).max(200).describe(\"Human-readable workspace title.\"), \"description\": z.string().min(1).max(2000).describe(\"One-paragraph statement of purpose: what this workspace (or view) is for and who uses it.\"), \"version\": z.string().regex(new RegExp(\"^[0-9]+\\\\.[0-9]+\\\\.[0-9]+(-[A-Za-z0-9.-]+)?$\")).describe(\"Semantic version of the WORKSPACE shape. Bump on entityTypes / lints / source / curation changes. Independent of the wiki's content version.\"), \"extends\": z.string().regex(new RegExp(\"^(\\\\.\\\\./|\\\\./)[^\\\\s]+/KNOWLEDGE\\\\.md$\")).min(1).max(512).describe(\"OPTIONAL — relative path to a parent KNOWLEDGE.md. Presence of this field makes the manifest a VIEW; absence makes it a WORKSPACE ROOT. Recursive composition: parents may themselves declare `extends`. Maximum chain depth is 8.\").optional(), \"appliesTo\": z.array(z.string().regex(new RegExp(\"^(ws://(operators|companies|skills)/[a-z][a-z0-9-]*|\\\\.\\\\./[^\\\\s]+)$\")).describe(\"Either a ws:// ref to an AIP-9 operator / AIP-6 company / AIP-3 skill, or a relative path to a consumer workspace folder.\")).refine((arr) => arr.every((item, i) => arr.indexOf(item) == i), { message: \"All items must be unique!\" }).describe(\"OPTIONAL — list of consumers this VIEW adapts the workspace for. Hosts MUST refuse the view if any binding does not resolve. Not inherited; views declare their own scope.\").optional(), \"curator\": z.string().regex(new RegExp(\"^ws://operators/[a-z][a-z0-9-]*$\")).describe(\"OPTIONAL — AIP-9 operator that curates this workspace. The host activates this operator for ingest, curation, and lint passes.\").optional(), \"governance\": z.string().min(1).max(512).describe(\"OPTIONAL — AIP-7 policy or audit binding. May be a path to an AIP-7 policy file or a ws:// ref. Schema-poisoning mitigations and source-mutation audits flow through this ref.\").optional(), \"entityTypes\": z.array(z.object({ \"name\": z.string().regex(new RegExp(\"^[A-Z][A-Za-z0-9]*$\")).describe(\"PascalCase type name. Merge key when composing with extends parent.\"), \"fields\": z.array(z.string().regex(new RegExp(\"^[a-z][A-Za-z0-9_]*$\"))).describe(\"Canonical fields for this entity type. Child views append fields to parent's set.\").default([] as never), \"icon\": z.string().max(8).describe(\"OPTIONAL — display hint, typically a single emoji.\").optional(), \"description\": z.string().max(1000).describe(\"OPTIONAL — prose describing what entries of this type capture.\").optional(), \"parent\": z.string().regex(new RegExp(\"^[A-Z][A-Za-z0-9]*$\")).describe(\"OPTIONAL — name of another LOCAL entity type that this one extends. Used for subtyping (e.g. Investor extends Person).\").optional() }).strict()).describe(\"Entity types this workspace recognizes. Merge-by-name against the extends parent: a child entry with the same name replaces the parent's; new names are appended.\").default([] as never), \"lints\": z.array(z.object({ \"id\": z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*$\")).describe(\"Stable kebab-case lint id. Merge key when composing with extends parent.\"), \"kind\": z.enum([\"require-source\",\"max-age\",\"min-confidence\",\"broken-ref\",\"orphan\",\"custom\"]).describe(\"Lint algorithm. 'custom' delegates to a host-defined check identified by `id`.\"), \"appliesTo\": z.string().regex(new RegExp(\"^([A-Z][A-Za-z0-9]*|\\\\*)$\")).describe(\"Entity type name (e.g. 'Concept') or '*' for all entries.\"), \"severity\": z.enum([\"error\",\"warn\",\"info\"]).describe(\"Lint severity. Child views may soften (warn -> info) but governance policies may forbid that.\"), \"params\": z.record(z.string(), z.any()).describe(\"Kind-specific parameters. e.g. { days: 90 } for 'max-age'; { min: 0.6 } for 'min-confidence'.\").default({} as never) }).strict()).describe(\"Lint rules. Merge-by-id against the extends parent: a child entry with the same id replaces the parent's; new ids are appended.\").default([] as never), \"sources\": z.object({ \"retention\": z.string().regex(new RegExp(\"^(forever|days:[0-9]+)$\")).describe(\"Source retention. 'forever' (default) or 'days:<n>' for time-limited.\").optional(), \"signing\": z.enum([\"required\",\"optional\",\"none\"]).describe(\"Whether sources must carry an AIP-7 signature. Composes with AIP-7 governance.\").optional(), \"hashAlgo\": z.enum([\"sha256\",\"sha512\",\"blake3\"]).describe(\"Default content-hash algorithm for new sources.\").optional(), \"authorityDefault\": z.enum([\"primary\",\"secondary\",\"rumour\"]).describe(\"Default authority assigned to new sources when defineSource omits the field.\").optional() }).strict().describe(\"Source registry policy. Each leaf field overrides independently across the extends chain.\").optional(), \"curation\": z.object({ \"tone\": z.string().max(200).describe(\"Free-form tone hint for the curator agent (e.g. 'academic', 'sales', 'neutral').\").optional(), \"depth\": z.enum([\"shallow\",\"medium\",\"deep\"]).describe(\"How exhaustive the curator agent should be when distilling sources into entries.\").optional(), \"autoLink\": z.enum([\"byName\",\"manual\",\"off\"]).describe(\"Auto-linking policy: 'byName' walks bodies for entity names and inserts wikilinks; 'manual' leaves links to the agent; 'off' disables auto-linking entirely.\").optional(), \"conflictResolution\": z.enum([\"defer\",\"recency\",\"authority\",\"observation-count\",\"keep-both\"]).describe(\"How the curator agent resolves contradictions when sources disagree.\").optional(), \"newEntryThreshold\": z.string().max(1000).describe(\"Prose hint for when to promote a mention into a full entry (vs leaving it as a body reference).\").optional() }).strict().describe(\"Curation policy. Each leaf field overrides independently across the extends chain.\").optional(), \"queryHints\": z.object({ \"preferRecent\": z.boolean().describe(\"When ranking results, weight recency higher.\").optional(), \"preferAuthoritative\": z.boolean().describe(\"When ranking results, weight authority='primary' higher.\").optional(), \"scopeTo\": z.array(z.string().regex(new RegExp(\"^[A-Z][A-Za-z0-9]*$\"))).refine((arr) => arr.every((item, i) => arr.indexOf(item) == i), { message: \"All items must be unique!\" }).describe(\"Default query scope — entity types this view focuses on. Replaced wholesale by child if present.\").optional() }).strict().describe(\"Hints for how consumers should retrieve from this view.\").optional(), \"display\": z.object({ \"homePage\": z.string().regex(new RegExp(\"^[a-z][a-z0-9-]*[a-z0-9]$\")).describe(\"OPTIONAL — slug of the entry to use as the workspace landing page.\").optional(), \"defaultGrouping\": z.enum([\"kind\",\"tag\",\"source\"]).describe(\"Default _index.md grouping.\").optional() }).strict().describe(\"Display hints for UIs that render the workspace. Runtime-agnostic.\").optional(), \"metadata\": z.record(z.string(), z.any()).describe(\"Vendor-specific extensions, namespaced under <vendor>. Deep-merged across the extends chain.\").default({} as never) }).strict().describe(\"Workspace manifest doctype. Used both as the root manifest of a wiki (no `extends`) and as a per-consumer view (with `extends`). The same schema validates both modes; the host distinguishes by checking whether `extends` is set.\"),\n]).describe(\"Validates the YAML frontmatter portion of an AIP-10 entry, source, or workspace manifest. The doctype is selected via the `schema` discriminator: 'knowledge.entry/v1' (curated, mutable), 'knowledge.source/v1' (raw, immutable), or 'knowledge.workspace/v1' (workspace manifest or per-context view).\")\n\nexport type KnowledgeFrontmatter = z.infer<typeof knowledgeFrontmatterSchema>\n","import { createDoctype } from \"@agentproto/define-doctype\"\nimport { knowledgeFrontmatterSchema } from \"./schema.js\"\nimport type { KnowledgeDefinition, KnowledgeHandle } from \"./types.js\"\n\n/**\n * AIP-10 reference implementation of `defineKnowledge`.\n *\n * Built on `createDoctype` so the cross-AIP invariants (id pattern,\n * description length, top-level freeze, \"defineKnowledge (AIP-10): …\"\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 (`parseKnowledgeManifest`), 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 defineKnowledge = createDoctype<KnowledgeDefinition, KnowledgeHandle>({\n aip: 10,\n name: \"knowledge\",\n // AIP-10 has three branches with different identity fields:\n // entry → slug\n // source → id\n // workspace → name\n // Dispatch on the `schema` discriminator so the cross-AIP id-pattern\n // check runs against the right token.\n readIdentity: (def: KnowledgeDefinition) => {\n switch (def.schema) {\n case \"knowledge.entry/v1\":\n return def.slug\n case \"knowledge.source/v1\":\n return def.id\n case \"knowledge.workspace/v1\":\n return def.name\n default:\n return \"\"\n }\n },\n validate(def) {\n const result = knowledgeFrontmatterSchema.safeParse(def)\n if (!result.success) {\n throw new Error(\n `defineKnowledge (AIP-10): ${result.error.issues\n .map((i) => `${i.path.join(\".\")}: ${i.message}`)\n .join(\"; \")}`,\n )\n }\n // TODO: spec-10-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 KnowledgeHandle\n },\n})\n"]}
@@ -0,0 +1,32 @@
1
+ import { K as KnowledgeDefinition, a as KnowledgeHandle } from './types-7B2qkOIb.js';
2
+
3
+ /**
4
+ * AIP-10 reference implementation of `defineKnowledge`.
5
+ *
6
+ * Built on `createDoctype` so the cross-AIP invariants (id pattern,
7
+ * description length, top-level freeze, "defineKnowledge (AIP-10): …"
8
+ * error prefix) run uniformly with every other AIP defineX.
9
+ *
10
+ * Field-level validation runs the schema-derived zod from
11
+ * `./schema.ts` against the input. Same source of truth as the .md
12
+ * path uses (`parseKnowledgeManifest`), so a malformed TS-authored
13
+ * definition fails with the same diagnostic as a malformed manifest.
14
+ * Cross-field rules go in `validate(def)` after the zod check.
15
+ */
16
+ declare const defineKnowledge: (def: KnowledgeDefinition) => KnowledgeHandle;
17
+
18
+ /**
19
+ * @agentproto/knowledge — AIP-10 KNOWLEDGE.md `defineKnowledge` reference impl.
20
+ *
21
+ * A filesystem-first knowledge-base format where an LLM curates, links, and lints a markdown wiki on top of immutable raw sources, turning agent knowledge into a compounding artifact instead of a per-query retrieval miss.
22
+ *
23
+ * Spec: https://agentproto.sh/docs/aip-10
24
+ *
25
+ * Authoring paths:
26
+ * - TS: `defineKnowledge({...})` → `KnowledgeHandle`
27
+ * - MD: `parseKnowledgeManifest(src) → knowledgeFromManifest({...})` → `KnowledgeHandle`
28
+ */
29
+ declare const SPEC_NAME: "agentknowledge/v1";
30
+ declare const SPEC_VERSION: "1.0.0-alpha";
31
+
32
+ export { KnowledgeDefinition, KnowledgeHandle, SPEC_NAME, SPEC_VERSION, defineKnowledge };
package/dist/index.mjs ADDED
@@ -0,0 +1,14 @@
1
+ export { defineKnowledge } from './chunk-27YWFJ6J.mjs';
2
+
3
+ /**
4
+ * @agentproto/knowledge v0.1.0-alpha
5
+ * AIP-10 KNOWLEDGE.md `defineKnowledge` reference implementation.
6
+ */
7
+
8
+ // src/index.ts
9
+ var SPEC_NAME = "agentknowledge/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/knowledge — AIP-10 KNOWLEDGE.md `defineKnowledge` reference impl.\n *\n * A filesystem-first knowledge-base format where an LLM curates, links, and lints a markdown wiki on top of immutable raw sources, turning agent knowledge into a compounding artifact instead of a per-query retrieval miss.\n *\n * Spec: https://agentproto.sh/docs/aip-10\n *\n * Authoring paths:\n * - TS: `defineKnowledge({...})` → `KnowledgeHandle`\n * - MD: `parseKnowledgeManifest(src) → knowledgeFromManifest({...})` → `KnowledgeHandle`\n */\n\nexport const SPEC_NAME = \"agentknowledge/v1\" as const\nexport const SPEC_VERSION = \"1.0.0-alpha\" as const\n\nexport { defineKnowledge } from \"./define-knowledge.js\"\nexport type { KnowledgeDefinition, KnowledgeHandle } from \"./types.js\"\n"]}
@@ -0,0 +1,161 @@
1
+ import { z } from 'zod';
2
+ import { a as KnowledgeHandle } from '../types-7B2qkOIb.js';
3
+
4
+ /**
5
+ * AIP-10 KNOWLEDGE.md frontmatter zod schema.
6
+ *
7
+ * Generated from `resources/aip-10/draft/KNOWLEDGE.schema.json` via
8
+ * json-schema-to-zod. Imported by both `define-knowledge.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-knowledge.ts`'s `validate(def)` instead.
15
+ */
16
+
17
+ declare const knowledgeFrontmatterSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
18
+ schema: z.ZodLiteral<"knowledge.entry/v1">;
19
+ slug: z.ZodString;
20
+ kind: z.ZodString;
21
+ title: z.ZodString;
22
+ sources: z.ZodDefault<z.ZodArray<z.ZodString>>;
23
+ confidence: z.ZodDefault<z.ZodNumber>;
24
+ updated_at: z.ZodString;
25
+ supersedes: z.ZodDefault<z.ZodArray<z.ZodString>>;
26
+ contradicts: z.ZodDefault<z.ZodArray<z.ZodString>>;
27
+ links: z.ZodDefault<z.ZodArray<z.ZodString>>;
28
+ tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
29
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
30
+ }, z.core.$strict>, z.ZodObject<{
31
+ schema: z.ZodLiteral<"knowledge.source/v1">;
32
+ id: z.ZodString;
33
+ path: z.ZodString;
34
+ title: z.ZodString;
35
+ captured_at: z.ZodString;
36
+ captured_by: z.ZodOptional<z.ZodString>;
37
+ content_hash: z.ZodString;
38
+ authority: z.ZodDefault<z.ZodEnum<{
39
+ primary: "primary";
40
+ secondary: "secondary";
41
+ rumour: "rumour";
42
+ }>>;
43
+ language: z.ZodOptional<z.ZodString>;
44
+ superseded_by: z.ZodOptional<z.ZodString>;
45
+ tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
46
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
47
+ }, z.core.$strict>, z.ZodObject<{
48
+ schema: z.ZodLiteral<"knowledge.workspace/v1">;
49
+ name: z.ZodString;
50
+ title: z.ZodString;
51
+ description: z.ZodString;
52
+ version: z.ZodString;
53
+ extends: z.ZodOptional<z.ZodString>;
54
+ appliesTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
55
+ curator: z.ZodOptional<z.ZodString>;
56
+ governance: z.ZodOptional<z.ZodString>;
57
+ entityTypes: z.ZodDefault<z.ZodArray<z.ZodObject<{
58
+ name: z.ZodString;
59
+ fields: z.ZodDefault<z.ZodArray<z.ZodString>>;
60
+ icon: z.ZodOptional<z.ZodString>;
61
+ description: z.ZodOptional<z.ZodString>;
62
+ parent: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strict>>>;
64
+ lints: z.ZodDefault<z.ZodArray<z.ZodObject<{
65
+ id: z.ZodString;
66
+ kind: z.ZodEnum<{
67
+ custom: "custom";
68
+ "require-source": "require-source";
69
+ "max-age": "max-age";
70
+ "min-confidence": "min-confidence";
71
+ "broken-ref": "broken-ref";
72
+ orphan: "orphan";
73
+ }>;
74
+ appliesTo: z.ZodString;
75
+ severity: z.ZodEnum<{
76
+ error: "error";
77
+ warn: "warn";
78
+ info: "info";
79
+ }>;
80
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
81
+ }, z.core.$strict>>>;
82
+ sources: z.ZodOptional<z.ZodObject<{
83
+ retention: z.ZodOptional<z.ZodString>;
84
+ signing: z.ZodOptional<z.ZodEnum<{
85
+ optional: "optional";
86
+ required: "required";
87
+ none: "none";
88
+ }>>;
89
+ hashAlgo: z.ZodOptional<z.ZodEnum<{
90
+ sha256: "sha256";
91
+ sha512: "sha512";
92
+ blake3: "blake3";
93
+ }>>;
94
+ authorityDefault: z.ZodOptional<z.ZodEnum<{
95
+ primary: "primary";
96
+ secondary: "secondary";
97
+ rumour: "rumour";
98
+ }>>;
99
+ }, z.core.$strict>>;
100
+ curation: z.ZodOptional<z.ZodObject<{
101
+ tone: z.ZodOptional<z.ZodString>;
102
+ depth: z.ZodOptional<z.ZodEnum<{
103
+ shallow: "shallow";
104
+ medium: "medium";
105
+ deep: "deep";
106
+ }>>;
107
+ autoLink: z.ZodOptional<z.ZodEnum<{
108
+ byName: "byName";
109
+ manual: "manual";
110
+ off: "off";
111
+ }>>;
112
+ conflictResolution: z.ZodOptional<z.ZodEnum<{
113
+ authority: "authority";
114
+ defer: "defer";
115
+ recency: "recency";
116
+ "observation-count": "observation-count";
117
+ "keep-both": "keep-both";
118
+ }>>;
119
+ newEntryThreshold: z.ZodOptional<z.ZodString>;
120
+ }, z.core.$strict>>;
121
+ queryHints: z.ZodOptional<z.ZodObject<{
122
+ preferRecent: z.ZodOptional<z.ZodBoolean>;
123
+ preferAuthoritative: z.ZodOptional<z.ZodBoolean>;
124
+ scopeTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
125
+ }, z.core.$strict>>;
126
+ display: z.ZodOptional<z.ZodObject<{
127
+ homePage: z.ZodOptional<z.ZodString>;
128
+ defaultGrouping: z.ZodOptional<z.ZodEnum<{
129
+ kind: "kind";
130
+ tag: "tag";
131
+ source: "source";
132
+ }>>;
133
+ }, z.core.$strict>>;
134
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
135
+ }, z.core.$strict>], "schema">;
136
+ type KnowledgeFrontmatter = z.infer<typeof knowledgeFrontmatterSchema>;
137
+
138
+ /**
139
+ * AIP-10 KNOWLEDGE.md sidecar parser + manifest-to-handle constructor.
140
+ *
141
+ * Mirror of `@agentproto/tool/manifest` and `@agentproto/driver/manifest`:
142
+ * the .md provides metadata; the TS module supplies any spec-specific
143
+ * runtime bits (schemas, execute bodies, …) that can't live in
144
+ * frontmatter. Both inputs end up in `defineKnowledge` so the cross-AIP
145
+ * invariants run uniformly.
146
+ *
147
+ *
148
+ * The frontmatter zod schema below was generated from
149
+ * `resources/aip-10/draft/KNOWLEDGE.schema.json` via json-schema-to-zod.
150
+ * Re-run scaffold-aip to refresh after spec changes (or hand-tune
151
+ * any constraint the converter doesn't capture cleanly).
152
+ */
153
+
154
+ interface KnowledgeManifest {
155
+ frontmatter: KnowledgeFrontmatter;
156
+ body: string;
157
+ }
158
+ declare function parseKnowledgeManifest(source: string): KnowledgeManifest;
159
+ declare function knowledgeFromManifest(manifest: KnowledgeManifest): KnowledgeHandle;
160
+
161
+ export { type KnowledgeFrontmatter, type KnowledgeManifest, knowledgeFromManifest, knowledgeFrontmatterSchema, parseKnowledgeManifest };
@@ -0,0 +1,28 @@
1
+ import { knowledgeFrontmatterSchema, defineKnowledge } from '../chunk-27YWFJ6J.mjs';
2
+ export { knowledgeFrontmatterSchema } from '../chunk-27YWFJ6J.mjs';
3
+ import matter from 'gray-matter';
4
+
5
+ /**
6
+ * @agentproto/knowledge v0.1.0-alpha
7
+ * AIP-10 KNOWLEDGE.md `defineKnowledge` reference implementation.
8
+ */
9
+ function parseKnowledgeManifest(source) {
10
+ const parsed = matter(source);
11
+ if (Object.keys(parsed.data).length === 0) {
12
+ throw new Error("parseKnowledgeManifest: missing or empty frontmatter");
13
+ }
14
+ const result = knowledgeFrontmatterSchema.safeParse(parsed.data);
15
+ if (!result.success) {
16
+ throw new Error(
17
+ `parseKnowledgeManifest: 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 knowledgeFromManifest(manifest) {
23
+ return defineKnowledge(manifest.frontmatter);
24
+ }
25
+
26
+ export { knowledgeFromManifest, parseKnowledgeManifest };
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,uBAAuB,MAAA,EAAmC;AACxE,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,sDAAsD,CAAA;AAAA,EACxE;AACA,EAAA,MAAM,MAAA,GAAS,0BAAA,CAA2B,SAAA,CAAU,MAAA,CAAO,IAAI,CAAA;AAC/D,EAAA,IAAI,CAAC,OAAO,OAAA,EAAS;AACnB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,mDAAA,EAAiD,OAAO,KAAA,CAAM,MAAA,CAC3D,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,sBAAsB,QAAA,EAA8C;AAKlF,EAAA,OAAO,eAAA,CAAgB,SAAS,WAA6C,CAAA;AAC/E","file":"index.mjs","sourcesContent":["/**\n * AIP-10 KNOWLEDGE.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 `defineKnowledge` so the cross-AIP\n * invariants run uniformly.\n *\n *\n * The frontmatter zod schema below was generated from\n * `resources/aip-10/draft/KNOWLEDGE.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 { knowledgeFrontmatterSchema, type KnowledgeFrontmatter } from \"../schema.js\"\nimport { defineKnowledge } from \"../define-knowledge.js\"\nimport type { KnowledgeDefinition, KnowledgeHandle } from \"../types.js\"\n\n// Re-export so consumers can import the schema + inferred type either\n// from \"@@agentproto/knowledge/manifest\" or directly from \"@@agentproto/knowledge/schema\".\nexport { knowledgeFrontmatterSchema, type KnowledgeFrontmatter }\n\nexport interface KnowledgeManifest {\n frontmatter: KnowledgeFrontmatter\n body: string\n}\n\nexport function parseKnowledgeManifest(source: string): KnowledgeManifest {\n const parsed = matter(source)\n if (Object.keys(parsed.data).length === 0) {\n throw new Error(\"parseKnowledgeManifest: missing or empty frontmatter\")\n }\n const result = knowledgeFrontmatterSchema.safeParse(parsed.data)\n if (!result.success) {\n throw new Error(\n `parseKnowledgeManifest: 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 knowledgeFromManifest(manifest: KnowledgeManifest): KnowledgeHandle {\n // The zod-validated frontmatter is structurally compatible with\n // KnowledgeDefinition; 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 defineKnowledge(manifest.frontmatter as unknown as KnowledgeDefinition)\n}\n"]}
@@ -0,0 +1,293 @@
1
+ /**
2
+ * AIP-10 KnowledgeDefinition + KnowledgeHandle.
3
+ *
4
+ * `KnowledgeDefinition` was generated from
5
+ * `resources/aip-10/draft/KNOWLEDGE.schema.json` via json-schema-to-typescript.
6
+ * `KnowledgeHandle` 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-10 entry, source, or workspace manifest. The doctype is selected via the `schema` discriminator: 'knowledge.entry/v1' (curated, mutable), 'knowledge.source/v1' (raw, immutable), or 'knowledge.workspace/v1' (workspace manifest or per-context view).
11
+ */
12
+ type KnowledgeDefinition = Entry | Source | Workspace;
13
+ /**
14
+ * Workspace manifest doctype. Used both as the root manifest of a wiki (no `extends`) and as a per-consumer view (with `extends`). The same schema validates both modes; the host distinguishes by checking whether `extends` is set.
15
+ */
16
+ type Workspace = {
17
+ [k: string]: unknown;
18
+ } & {
19
+ /**
20
+ * Discriminator for the workspace manifest doctype.
21
+ */
22
+ schema: "knowledge.workspace/v1";
23
+ /**
24
+ * Stable kebab-case identifier for the workspace or view.
25
+ */
26
+ name: string;
27
+ /**
28
+ * Human-readable workspace title.
29
+ */
30
+ title: string;
31
+ /**
32
+ * One-paragraph statement of purpose: what this workspace (or view) is for and who uses it.
33
+ */
34
+ description: string;
35
+ /**
36
+ * Semantic version of the WORKSPACE shape. Bump on entityTypes / lints / source / curation changes. Independent of the wiki's content version.
37
+ */
38
+ version: string;
39
+ /**
40
+ * OPTIONAL — relative path to a parent KNOWLEDGE.md. Presence of this field makes the manifest a VIEW; absence makes it a WORKSPACE ROOT. Recursive composition: parents may themselves declare `extends`. Maximum chain depth is 8.
41
+ */
42
+ extends?: string;
43
+ /**
44
+ * OPTIONAL — list of consumers this VIEW adapts the workspace for. Hosts MUST refuse the view if any binding does not resolve. Not inherited; views declare their own scope.
45
+ */
46
+ appliesTo?: string[];
47
+ /**
48
+ * OPTIONAL — AIP-9 operator that curates this workspace. The host activates this operator for ingest, curation, and lint passes.
49
+ */
50
+ curator?: string;
51
+ /**
52
+ * OPTIONAL — AIP-7 policy or audit binding. May be a path to an AIP-7 policy file or a ws:// ref. Schema-poisoning mitigations and source-mutation audits flow through this ref.
53
+ */
54
+ governance?: string;
55
+ /**
56
+ * Entity types this workspace recognizes. Merge-by-name against the extends parent: a child entry with the same name replaces the parent's; new names are appended.
57
+ */
58
+ entityTypes?: {
59
+ /**
60
+ * PascalCase type name. Merge key when composing with extends parent.
61
+ */
62
+ name: string;
63
+ /**
64
+ * Canonical fields for this entity type. Child views append fields to parent's set.
65
+ */
66
+ fields?: string[];
67
+ /**
68
+ * OPTIONAL — display hint, typically a single emoji.
69
+ */
70
+ icon?: string;
71
+ /**
72
+ * OPTIONAL — prose describing what entries of this type capture.
73
+ */
74
+ description?: string;
75
+ /**
76
+ * OPTIONAL — name of another LOCAL entity type that this one extends. Used for subtyping (e.g. Investor extends Person).
77
+ */
78
+ parent?: string;
79
+ }[];
80
+ /**
81
+ * Lint rules. Merge-by-id against the extends parent: a child entry with the same id replaces the parent's; new ids are appended.
82
+ */
83
+ lints?: {
84
+ /**
85
+ * Stable kebab-case lint id. Merge key when composing with extends parent.
86
+ */
87
+ id: string;
88
+ /**
89
+ * Lint algorithm. 'custom' delegates to a host-defined check identified by `id`.
90
+ */
91
+ kind: "require-source" | "max-age" | "min-confidence" | "broken-ref" | "orphan" | "custom";
92
+ /**
93
+ * Entity type name (e.g. 'Concept') or '*' for all entries.
94
+ */
95
+ appliesTo: string;
96
+ /**
97
+ * Lint severity. Child views may soften (warn -> info) but governance policies may forbid that.
98
+ */
99
+ severity: "error" | "warn" | "info";
100
+ /**
101
+ * Kind-specific parameters. e.g. { days: 90 } for 'max-age'; { min: 0.6 } for 'min-confidence'.
102
+ */
103
+ params?: {
104
+ [k: string]: unknown;
105
+ };
106
+ }[];
107
+ /**
108
+ * Source registry policy. Each leaf field overrides independently across the extends chain.
109
+ */
110
+ sources?: {
111
+ /**
112
+ * Source retention. 'forever' (default) or 'days:<n>' for time-limited.
113
+ */
114
+ retention?: string;
115
+ /**
116
+ * Whether sources must carry an AIP-7 signature. Composes with AIP-7 governance.
117
+ */
118
+ signing?: "required" | "optional" | "none";
119
+ /**
120
+ * Default content-hash algorithm for new sources.
121
+ */
122
+ hashAlgo?: "sha256" | "sha512" | "blake3";
123
+ /**
124
+ * Default authority assigned to new sources when defineSource omits the field.
125
+ */
126
+ authorityDefault?: "primary" | "secondary" | "rumour";
127
+ };
128
+ /**
129
+ * Curation policy. Each leaf field overrides independently across the extends chain.
130
+ */
131
+ curation?: {
132
+ /**
133
+ * Free-form tone hint for the curator agent (e.g. 'academic', 'sales', 'neutral').
134
+ */
135
+ tone?: string;
136
+ /**
137
+ * How exhaustive the curator agent should be when distilling sources into entries.
138
+ */
139
+ depth?: "shallow" | "medium" | "deep";
140
+ /**
141
+ * Auto-linking policy: 'byName' walks bodies for entity names and inserts wikilinks; 'manual' leaves links to the agent; 'off' disables auto-linking entirely.
142
+ */
143
+ autoLink?: "byName" | "manual" | "off";
144
+ /**
145
+ * How the curator agent resolves contradictions when sources disagree.
146
+ */
147
+ conflictResolution?: "defer" | "recency" | "authority" | "observation-count" | "keep-both";
148
+ /**
149
+ * Prose hint for when to promote a mention into a full entry (vs leaving it as a body reference).
150
+ */
151
+ newEntryThreshold?: string;
152
+ };
153
+ /**
154
+ * Hints for how consumers should retrieve from this view.
155
+ */
156
+ queryHints?: {
157
+ /**
158
+ * When ranking results, weight recency higher.
159
+ */
160
+ preferRecent?: boolean;
161
+ /**
162
+ * When ranking results, weight authority='primary' higher.
163
+ */
164
+ preferAuthoritative?: boolean;
165
+ /**
166
+ * Default query scope — entity types this view focuses on. Replaced wholesale by child if present.
167
+ */
168
+ scopeTo?: string[];
169
+ };
170
+ /**
171
+ * Display hints for UIs that render the workspace. Runtime-agnostic.
172
+ */
173
+ display?: {
174
+ /**
175
+ * OPTIONAL — slug of the entry to use as the workspace landing page.
176
+ */
177
+ homePage?: string;
178
+ /**
179
+ * Default _index.md grouping.
180
+ */
181
+ defaultGrouping?: "kind" | "tag" | "source";
182
+ };
183
+ /**
184
+ * Vendor-specific extensions, namespaced under <vendor>. Deep-merged across the extends chain.
185
+ */
186
+ metadata?: {
187
+ [k: string]: unknown;
188
+ };
189
+ };
190
+ interface Entry {
191
+ /**
192
+ * Discriminator for curated wiki entries. Mutable doctype.
193
+ */
194
+ schema: "knowledge.entry/v1";
195
+ /**
196
+ * Stable kebab-case identifier. Used as the wikilink target ([[slug]]) and as the entry's path stem.
197
+ */
198
+ slug: string;
199
+ /**
200
+ * Entry kind. The wiki's KNOWLEDGE.md (entityTypes) and AGENTS.md schema together define the allowed values; common ones are 'entity', 'concept', 'summary', 'comparison', 'timeline'.
201
+ */
202
+ kind: string;
203
+ /**
204
+ * Human-readable page title.
205
+ */
206
+ title: string;
207
+ /**
208
+ * Provenance — list of source ids that back the claims in this entry's body.
209
+ */
210
+ sources?: string[];
211
+ /**
212
+ * Curation agent's confidence in the entry's claims. Advisory; downstream consumers may weight it against source authority and recency.
213
+ */
214
+ confidence?: number;
215
+ /**
216
+ * ISO 8601 timestamp of the last patch to this entry. MUST be set on every write.
217
+ */
218
+ updated_at: string;
219
+ /**
220
+ * Slugs of earlier entries that this one replaces. Resolution rules live in the wiki's KNOWLEDGE.md curation.conflictResolution policy.
221
+ */
222
+ supersedes?: string[];
223
+ /**
224
+ * Slugs of entries whose claims conflict with this one and that the contradiction policy could not auto-resolve. Surfaces in lint.
225
+ */
226
+ contradicts?: string[];
227
+ /**
228
+ * OPTIONAL hint to the link resolver — slugs this entry links to. The resolver also walks the body for [[slug]] and markdown links; this field is for entries whose links are computed.
229
+ */
230
+ links?: string[];
231
+ /**
232
+ * Free-form tags; consumed by retrieval, search, and grouping in _index.md.
233
+ */
234
+ tags?: string[];
235
+ /**
236
+ * Vendor-specific extensions. Hosts MUST tolerate unknown keys; the spec's normative fields MUST NOT change meaning.
237
+ */
238
+ metadata?: {
239
+ [k: string]: unknown;
240
+ };
241
+ }
242
+ interface Source {
243
+ /**
244
+ * Discriminator for raw sources. Immutable doctype — once registered, the host MUST refuse mutations to the file's bytes.
245
+ */
246
+ schema: "knowledge.source/v1";
247
+ /**
248
+ * Stable kebab-case source id, ISO-prefixed when possible (e.g. '2026-04-27-investor-call'). Entries reference sources by id, never by path.
249
+ */
250
+ id: string;
251
+ /**
252
+ * Path to the raw bytes, relative to the wiki root. MUST start with 'sources/'. The host pins this file once defineSource succeeds.
253
+ */
254
+ path: string;
255
+ /**
256
+ * Human-readable source title.
257
+ */
258
+ title: string;
259
+ /**
260
+ * ISO 8601 timestamp of when the source entered the wiki.
261
+ */
262
+ captured_at: string;
263
+ /**
264
+ * OPTIONAL — author or operator who pinned the source. May be a user identifier, an agent id, or an upstream system name.
265
+ */
266
+ captured_by?: string;
267
+ /**
268
+ * Cryptographic hash of the file bytes. sha256 is required by the spec; other algorithms MAY appear in additional sidecar fields. Once set, the file is pinned.
269
+ */
270
+ content_hash: string;
271
+ /**
272
+ * Source authority class. 'primary' = first-party document or recording; 'secondary' = derived analysis; 'rumour' = unverified claim. Consumed by contradiction policy.
273
+ */
274
+ authority?: "primary" | "secondary" | "rumour";
275
+ /**
276
+ * OPTIONAL — BCP-47 language code of the source. Useful for ingest pipelines that pick a translator.
277
+ */
278
+ language?: string;
279
+ /**
280
+ * OPTIONAL — id of a newer source that replaces this one. The host writes this; agents do not edit the source file's bytes to 'correct' it. Tombstones the source for contradiction-policy purposes while preserving the original bytes.
281
+ */
282
+ superseded_by?: string;
283
+ tags?: string[];
284
+ /**
285
+ * Vendor-specific extensions. Hosts MUST tolerate unknown keys.
286
+ */
287
+ metadata?: {
288
+ [k: string]: unknown;
289
+ };
290
+ }
291
+ type KnowledgeHandle = Readonly<KnowledgeDefinition>;
292
+
293
+ export type { KnowledgeDefinition as K, KnowledgeHandle as a };
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@agentproto/knowledge",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "@agentproto/knowledge — AIP-10 KNOWLEDGE.md reference implementation. A filesystem-first knowledge-base format where an LLM curates, links, and lints a markdown wiki on top of immutable raw sources, turning agent knowledge into a compounding artifact instead of a per-query retrieval miss.",
5
+ "keywords": [
6
+ "agentproto",
7
+ "aip-10",
8
+ "knowledge",
9
+ "defineKnowledge",
10
+ "open-standard",
11
+ "agentic"
12
+ ],
13
+ "homepage": "https://agentproto.sh/docs/aip-10",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/agentproto/ts",
17
+ "directory": "packages/knowledge"
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
+ }