world-building-framework 0.2.0 → 0.2.2
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/README.md +46 -3
- package/dist/cli/commands/create.d.ts +1 -7
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.js +8 -4
- package/dist/cli/commands/publish.js +1 -1
- package/dist/cli/commands/refresh.js +5 -1
- package/dist/cli/commands/render.js +1 -1
- package/dist/cli/index.js +18 -1
- package/dist/cli/managed-files.d.ts +11 -1
- package/dist/cli/managed-files.js +27 -5
- package/dist/cli/vault-path.d.ts +1 -1
- package/dist/cli/vault-path.js +5 -25
- package/dist/core/config/schema.d.ts +8 -208
- package/dist/core/config/schema.js +2 -2
- package/dist/core/query/dates.d.ts +4 -40
- package/dist/core/query/types.d.ts +5 -59
- package/dist/core/schema/describe.d.ts +29 -3
- package/dist/core/schema/describe.js +66 -18
- package/dist/core/schema/fields.d.ts +28 -220
- package/dist/core/schema/fields.js +3 -3
- package/dist/core/vault/read.js +6 -2
- package/dist/mcp/server.d.ts +20 -0
- package/dist/mcp/server.js +140 -0
- package/dist/render-pipeline/build.d.ts +5 -2
- package/dist/render-pipeline/build.js +13 -9
- package/dist/render-pipeline/index.d.ts +1 -0
- package/dist/render-pipeline/index.js +1 -0
- package/dist/render-pipeline/slugs.d.ts +3 -2
- package/dist/render-pipeline/slugs.js +4 -3
- package/dist/render-pipeline/start-page.d.ts +9 -0
- package/dist/render-pipeline/start-page.js +44 -0
- package/package.json +3 -2
- package/skills/world-vault/SKILL.md +8 -0
- package/templates/AGENTS.md +9 -1
|
@@ -2,54 +2,18 @@ import { z } from "zod";
|
|
|
2
2
|
export declare const dateBoundSchema: z.ZodObject<{
|
|
3
3
|
year: z.ZodNumber;
|
|
4
4
|
day: z.ZodOptional<z.ZodNumber>;
|
|
5
|
-
},
|
|
6
|
-
year: number;
|
|
7
|
-
day?: number | undefined;
|
|
8
|
-
}, {
|
|
9
|
-
year: number;
|
|
10
|
-
day?: number | undefined;
|
|
11
|
-
}>;
|
|
5
|
+
}, z.core.$strip>;
|
|
12
6
|
export type DateBound = z.infer<typeof dateBoundSchema>;
|
|
13
7
|
export declare const dateRangeQuerySchema: z.ZodObject<{
|
|
14
8
|
from: z.ZodOptional<z.ZodObject<{
|
|
15
9
|
year: z.ZodNumber;
|
|
16
10
|
day: z.ZodOptional<z.ZodNumber>;
|
|
17
|
-
},
|
|
18
|
-
year: number;
|
|
19
|
-
day?: number | undefined;
|
|
20
|
-
}, {
|
|
21
|
-
year: number;
|
|
22
|
-
day?: number | undefined;
|
|
23
|
-
}>>;
|
|
11
|
+
}, z.core.$strip>>;
|
|
24
12
|
to: z.ZodOptional<z.ZodObject<{
|
|
25
13
|
year: z.ZodNumber;
|
|
26
14
|
day: z.ZodOptional<z.ZodNumber>;
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
day?: number | undefined;
|
|
30
|
-
}, {
|
|
31
|
-
year: number;
|
|
32
|
-
day?: number | undefined;
|
|
33
|
-
}>>;
|
|
34
|
-
}, "strip", z.ZodTypeAny, {
|
|
35
|
-
from?: {
|
|
36
|
-
year: number;
|
|
37
|
-
day?: number | undefined;
|
|
38
|
-
} | undefined;
|
|
39
|
-
to?: {
|
|
40
|
-
year: number;
|
|
41
|
-
day?: number | undefined;
|
|
42
|
-
} | undefined;
|
|
43
|
-
}, {
|
|
44
|
-
from?: {
|
|
45
|
-
year: number;
|
|
46
|
-
day?: number | undefined;
|
|
47
|
-
} | undefined;
|
|
48
|
-
to?: {
|
|
49
|
-
year: number;
|
|
50
|
-
day?: number | undefined;
|
|
51
|
-
} | undefined;
|
|
52
|
-
}>;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
}, z.core.$strip>;
|
|
53
17
|
export type DateRangeQuery = z.infer<typeof dateRangeQuerySchema>;
|
|
54
18
|
/** An in-world date, as stored in an event's `date` field. */
|
|
55
19
|
export interface DateTuple {
|
|
@@ -6,70 +6,16 @@ import { z } from "zod";
|
|
|
6
6
|
* its `buildVariants` entries against — one definition, no separate DSL to parse.
|
|
7
7
|
*/
|
|
8
8
|
export declare const buildVariantQuerySchema: z.ZodObject<{
|
|
9
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString
|
|
9
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
10
|
dateRange: z.ZodOptional<z.ZodObject<{
|
|
11
11
|
from: z.ZodOptional<z.ZodObject<{
|
|
12
12
|
year: z.ZodNumber;
|
|
13
13
|
day: z.ZodOptional<z.ZodNumber>;
|
|
14
|
-
},
|
|
15
|
-
year: number;
|
|
16
|
-
day?: number | undefined;
|
|
17
|
-
}, {
|
|
18
|
-
year: number;
|
|
19
|
-
day?: number | undefined;
|
|
20
|
-
}>>;
|
|
14
|
+
}, z.core.$strip>>;
|
|
21
15
|
to: z.ZodOptional<z.ZodObject<{
|
|
22
16
|
year: z.ZodNumber;
|
|
23
17
|
day: z.ZodOptional<z.ZodNumber>;
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, {
|
|
28
|
-
year: number;
|
|
29
|
-
day?: number | undefined;
|
|
30
|
-
}>>;
|
|
31
|
-
}, "strip", z.ZodTypeAny, {
|
|
32
|
-
from?: {
|
|
33
|
-
year: number;
|
|
34
|
-
day?: number | undefined;
|
|
35
|
-
} | undefined;
|
|
36
|
-
to?: {
|
|
37
|
-
year: number;
|
|
38
|
-
day?: number | undefined;
|
|
39
|
-
} | undefined;
|
|
40
|
-
}, {
|
|
41
|
-
from?: {
|
|
42
|
-
year: number;
|
|
43
|
-
day?: number | undefined;
|
|
44
|
-
} | undefined;
|
|
45
|
-
to?: {
|
|
46
|
-
year: number;
|
|
47
|
-
day?: number | undefined;
|
|
48
|
-
} | undefined;
|
|
49
|
-
}>>;
|
|
50
|
-
}, "strip", z.ZodTypeAny, {
|
|
51
|
-
tags?: string[] | undefined;
|
|
52
|
-
dateRange?: {
|
|
53
|
-
from?: {
|
|
54
|
-
year: number;
|
|
55
|
-
day?: number | undefined;
|
|
56
|
-
} | undefined;
|
|
57
|
-
to?: {
|
|
58
|
-
year: number;
|
|
59
|
-
day?: number | undefined;
|
|
60
|
-
} | undefined;
|
|
61
|
-
} | undefined;
|
|
62
|
-
}, {
|
|
63
|
-
tags?: string[] | undefined;
|
|
64
|
-
dateRange?: {
|
|
65
|
-
from?: {
|
|
66
|
-
year: number;
|
|
67
|
-
day?: number | undefined;
|
|
68
|
-
} | undefined;
|
|
69
|
-
to?: {
|
|
70
|
-
year: number;
|
|
71
|
-
day?: number | undefined;
|
|
72
|
-
} | undefined;
|
|
73
|
-
} | undefined;
|
|
74
|
-
}>;
|
|
18
|
+
}, z.core.$strip>>;
|
|
19
|
+
}, z.core.$strip>>;
|
|
20
|
+
}, z.core.$strip>;
|
|
75
21
|
export type BuildVariantQuery = z.infer<typeof buildVariantQuerySchema>;
|
|
@@ -1,8 +1,34 @@
|
|
|
1
|
+
/** Example `wbf create` inputs, one per kind. A test validates them, so they can't drift from the schema either. */
|
|
2
|
+
export declare const SCHEMA_EXAMPLES: {
|
|
3
|
+
entity: {
|
|
4
|
+
frontmatter: {
|
|
5
|
+
type: string;
|
|
6
|
+
entityType: string;
|
|
7
|
+
title: string;
|
|
8
|
+
tags: string[];
|
|
9
|
+
home: string;
|
|
10
|
+
};
|
|
11
|
+
body: string;
|
|
12
|
+
};
|
|
13
|
+
event: {
|
|
14
|
+
frontmatter: {
|
|
15
|
+
type: string;
|
|
16
|
+
title: string;
|
|
17
|
+
date: {
|
|
18
|
+
year: number;
|
|
19
|
+
day: number;
|
|
20
|
+
};
|
|
21
|
+
after: string[];
|
|
22
|
+
entities: string[];
|
|
23
|
+
};
|
|
24
|
+
body: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
1
27
|
/**
|
|
2
|
-
* Prints the live, current schema: field names
|
|
3
|
-
* schemas in fields.ts, so this can't structurally drift from what
|
|
28
|
+
* Prints the live, current schema: field names and value shapes come straight
|
|
29
|
+
* from the zod schemas in fields.ts, so this can't structurally drift from what
|
|
4
30
|
* validateFrontmatter actually enforces. This is what the CLI's `schema`
|
|
5
|
-
* command exposes so
|
|
31
|
+
* command exposes so an agent always sees the real, current rules — see
|
|
6
32
|
* claude-dev/PROJECT_STRUCTURE.md.
|
|
7
33
|
*/
|
|
8
34
|
export declare function describeSchema(entityTypeVocabulary?: string[]): string;
|
|
@@ -1,45 +1,92 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { commonFieldsSchema, entityFrontmatterSchema, eventFrontmatterSchema, wikilinkSchema, } from "./fields.js";
|
|
2
3
|
const FIELD_MEANINGS = {
|
|
3
|
-
type:
|
|
4
|
-
title: "Human-readable display name (
|
|
4
|
+
type: "Top-level kind.",
|
|
5
|
+
title: "Human-readable display name (filenames are UUIDs, this is the real name).",
|
|
5
6
|
tags: "Project-defined tags used for build-time filtering.",
|
|
6
7
|
aliases: "Alternate names/spellings, for search recall and Obsidian autocomplete only — not used for link resolution.",
|
|
7
8
|
entityType: "Category (e.g. character, location). Lint-checked against this vault's declared vocabulary, if any.",
|
|
8
9
|
supersedes: "Marks this file as a new version of an existing entity — points at the file it replaces.",
|
|
9
10
|
causedBy: "The event responsible for this version existing. Required alongside supersedes, and vice versa.",
|
|
10
11
|
after: "Causal predecessor event(s) — the required ordering/branching backbone.",
|
|
11
|
-
date: "
|
|
12
|
+
date: "In-world date anchor. Give both year and day.",
|
|
12
13
|
entities: "The entities this event is tied to.",
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
/** Example `wbf create` inputs, one per kind. A test validates them, so they can't drift from the schema either. */
|
|
16
|
+
export const SCHEMA_EXAMPLES = {
|
|
17
|
+
entity: {
|
|
18
|
+
frontmatter: {
|
|
19
|
+
type: "entity",
|
|
20
|
+
entityType: "character",
|
|
21
|
+
title: "Alea Marrow",
|
|
22
|
+
tags: ["player"],
|
|
23
|
+
home: "[[66a7bd3f-a744-4565-acbe-006957625792|Port Kavas]]",
|
|
24
|
+
},
|
|
25
|
+
body: "Captain of the *Gull*.",
|
|
26
|
+
},
|
|
27
|
+
event: {
|
|
28
|
+
frontmatter: {
|
|
29
|
+
type: "event",
|
|
30
|
+
title: "The Great Storm",
|
|
31
|
+
date: { year: 150, day: 200 },
|
|
32
|
+
after: ["[[bb1ddebd-3a7c-4b6c-847a-b4de59a71e66|Alea takes command of the Gull]]"],
|
|
33
|
+
entities: ["[[adfdd8db-0bf1-4053-928f-52709232859f|Alea Marrow]]"],
|
|
34
|
+
},
|
|
35
|
+
body: "A three-day storm floods the lower docks.",
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
/** A schema's value shape in words, read from the zod schema itself. */
|
|
39
|
+
function describeShape(schema) {
|
|
40
|
+
if (schema === wikilinkSchema)
|
|
41
|
+
return "link";
|
|
42
|
+
if (schema instanceof z.ZodOptional)
|
|
43
|
+
return describeShape(schema.unwrap());
|
|
44
|
+
if (schema instanceof z.ZodLiteral)
|
|
45
|
+
return schema.values.size === 1 ? JSON.stringify([...schema.values][0]) : "literal";
|
|
46
|
+
if (schema instanceof z.ZodString)
|
|
47
|
+
return "string";
|
|
48
|
+
if (schema instanceof z.ZodNumber)
|
|
49
|
+
return schema.isInt ? "integer" : "number";
|
|
50
|
+
if (schema instanceof z.ZodArray)
|
|
51
|
+
return `list of ${describeShape(schema.element)}s`;
|
|
52
|
+
if (schema instanceof z.ZodObject) {
|
|
53
|
+
const keys = Object.entries(schema.shape).map(([key, value]) => `${key}${value instanceof z.ZodOptional ? "?" : ""}: ${describeShape(value)}`);
|
|
54
|
+
return `{ ${keys.join(", ")} }`;
|
|
55
|
+
}
|
|
56
|
+
return "value";
|
|
16
57
|
}
|
|
17
|
-
function describeFields(names) {
|
|
18
|
-
return names.map((name) =>
|
|
58
|
+
function describeFields(shape, names) {
|
|
59
|
+
return names.map((name) => {
|
|
60
|
+
const schema = shape[name];
|
|
61
|
+
const required = schema instanceof z.ZodOptional ? "optional" : "required";
|
|
62
|
+
return ` - ${name} (${describeShape(schema)}, ${required}): ${FIELD_MEANINGS[name] ?? "(see SCHEMA.md)"}`;
|
|
63
|
+
});
|
|
19
64
|
}
|
|
20
65
|
/**
|
|
21
|
-
* Prints the live, current schema: field names
|
|
22
|
-
* schemas in fields.ts, so this can't structurally drift from what
|
|
66
|
+
* Prints the live, current schema: field names and value shapes come straight
|
|
67
|
+
* from the zod schemas in fields.ts, so this can't structurally drift from what
|
|
23
68
|
* validateFrontmatter actually enforces. This is what the CLI's `schema`
|
|
24
|
-
* command exposes so
|
|
69
|
+
* command exposes so an agent always sees the real, current rules — see
|
|
25
70
|
* claude-dev/PROJECT_STRUCTURE.md.
|
|
26
71
|
*/
|
|
27
72
|
export function describeSchema(entityTypeVocabulary) {
|
|
28
|
-
const commonKeys =
|
|
73
|
+
const commonKeys = Object.keys(commonFieldsSchema.shape);
|
|
29
74
|
const excluded = new Set([...commonKeys, "type"]);
|
|
30
|
-
const entityKeys =
|
|
31
|
-
const eventKeys =
|
|
75
|
+
const entityKeys = Object.keys(entityFrontmatterSchema.shape).filter((key) => !excluded.has(key));
|
|
76
|
+
const eventKeys = Object.keys(eventFrontmatterSchema.shape).filter((key) => !excluded.has(key));
|
|
32
77
|
const lines = [
|
|
33
78
|
"Common fields (every file):",
|
|
34
|
-
|
|
79
|
+
` - type ("entity" or "event", required): ${FIELD_MEANINGS.type}`,
|
|
80
|
+
...describeFields(commonFieldsSchema.shape, commonKeys),
|
|
35
81
|
"",
|
|
36
82
|
"Entity-only fields:",
|
|
37
|
-
...describeFields(entityKeys),
|
|
83
|
+
...describeFields(entityFrontmatterSchema.shape, entityKeys),
|
|
38
84
|
"",
|
|
39
85
|
"Event-only fields:",
|
|
40
|
-
...describeFields(eventKeys),
|
|
86
|
+
...describeFields(eventFrontmatterSchema.shape, eventKeys),
|
|
41
87
|
"",
|
|
42
|
-
'
|
|
88
|
+
'A link is a string "[[uuid|Display Name]]". A list field takes a list even for one link: after: ["[[uuid|Name]]"].',
|
|
89
|
+
"Any other frontmatter field whose value is a link is automatically a relation.",
|
|
43
90
|
];
|
|
44
91
|
if (entityTypeVocabulary && entityTypeVocabulary.length > 0) {
|
|
45
92
|
lines.push("", `This vault's declared entityType vocabulary: ${entityTypeVocabulary.join(", ")}`);
|
|
@@ -47,5 +94,6 @@ export function describeSchema(entityTypeVocabulary) {
|
|
|
47
94
|
else {
|
|
48
95
|
lines.push("", "This vault has not declared an entityType vocabulary — any entityType value is accepted.");
|
|
49
96
|
}
|
|
97
|
+
lines.push("", "Example input for `wbf create` (replace the UUIDs with real ids, e.g. from `wbf search`):", ` entity: ${JSON.stringify(SCHEMA_EXAMPLES.entity)}`, ` event: ${JSON.stringify(SCHEMA_EXAMPLES.event)}`);
|
|
50
98
|
return lines.join("\n");
|
|
51
99
|
}
|
|
@@ -1,249 +1,57 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
/** Any field whose value looks like this is auto-detected as a graph edge (SCHEMA.md rule 2) — no fixed vocabulary of relation-field names. */
|
|
3
|
-
export declare const wikilinkSchema: z.
|
|
3
|
+
export declare const wikilinkSchema: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
4
4
|
export declare const inWorldDateSchema: z.ZodObject<{
|
|
5
5
|
year: z.ZodNumber;
|
|
6
6
|
day: z.ZodNumber;
|
|
7
|
-
},
|
|
8
|
-
year: number;
|
|
9
|
-
day: number;
|
|
10
|
-
}, {
|
|
11
|
-
year: number;
|
|
12
|
-
day: number;
|
|
13
|
-
}>;
|
|
7
|
+
}, z.core.$strip>;
|
|
14
8
|
/** Fields every knowledge file carries (SCHEMA.md "Common frontmatter"). */
|
|
15
9
|
export declare const commonFieldsSchema: z.ZodObject<{
|
|
16
10
|
title: z.ZodString;
|
|
17
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString
|
|
18
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString
|
|
19
|
-
},
|
|
20
|
-
title: string;
|
|
21
|
-
tags?: string[] | undefined;
|
|
22
|
-
aliases?: string[] | undefined;
|
|
23
|
-
}, {
|
|
24
|
-
title: string;
|
|
25
|
-
tags?: string[] | undefined;
|
|
26
|
-
aliases?: string[] | undefined;
|
|
27
|
-
}>;
|
|
11
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
|
+
aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
+
}, z.core.$strip>;
|
|
28
14
|
export declare const entityFrontmatterSchema: z.ZodObject<{
|
|
29
15
|
title: z.ZodString;
|
|
30
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString
|
|
31
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString
|
|
32
|
-
} & {
|
|
16
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
17
|
+
aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
18
|
type: z.ZodLiteral<"entity">;
|
|
34
19
|
entityType: z.ZodOptional<z.ZodString>;
|
|
35
|
-
supersedes: z.ZodOptional<z.
|
|
36
|
-
causedBy: z.ZodOptional<z.
|
|
37
|
-
},
|
|
38
|
-
title: z.ZodString;
|
|
39
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
40
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
41
|
-
} & {
|
|
42
|
-
type: z.ZodLiteral<"entity">;
|
|
43
|
-
entityType: z.ZodOptional<z.ZodString>;
|
|
44
|
-
supersedes: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
45
|
-
causedBy: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
46
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
47
|
-
title: z.ZodString;
|
|
48
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
49
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
50
|
-
} & {
|
|
51
|
-
type: z.ZodLiteral<"entity">;
|
|
52
|
-
entityType: z.ZodOptional<z.ZodString>;
|
|
53
|
-
supersedes: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
54
|
-
causedBy: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
55
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
20
|
+
supersedes: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
|
|
21
|
+
causedBy: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
|
|
22
|
+
}, z.core.$loose>;
|
|
56
23
|
export declare const eventFrontmatterSchema: z.ZodObject<{
|
|
57
24
|
title: z.ZodString;
|
|
58
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString
|
|
59
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString
|
|
60
|
-
} & {
|
|
61
|
-
type: z.ZodLiteral<"event">;
|
|
62
|
-
after: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
63
|
-
date: z.ZodOptional<z.ZodObject<{
|
|
64
|
-
year: z.ZodNumber;
|
|
65
|
-
day: z.ZodNumber;
|
|
66
|
-
}, "strip", z.ZodTypeAny, {
|
|
67
|
-
year: number;
|
|
68
|
-
day: number;
|
|
69
|
-
}, {
|
|
70
|
-
year: number;
|
|
71
|
-
day: number;
|
|
72
|
-
}>>;
|
|
73
|
-
entities: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
74
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
75
|
-
title: z.ZodString;
|
|
76
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
77
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
78
|
-
} & {
|
|
79
|
-
type: z.ZodLiteral<"event">;
|
|
80
|
-
after: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
81
|
-
date: z.ZodOptional<z.ZodObject<{
|
|
82
|
-
year: z.ZodNumber;
|
|
83
|
-
day: z.ZodNumber;
|
|
84
|
-
}, "strip", z.ZodTypeAny, {
|
|
85
|
-
year: number;
|
|
86
|
-
day: number;
|
|
87
|
-
}, {
|
|
88
|
-
year: number;
|
|
89
|
-
day: number;
|
|
90
|
-
}>>;
|
|
91
|
-
entities: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
92
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
93
|
-
title: z.ZodString;
|
|
94
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
95
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
96
|
-
} & {
|
|
97
|
-
type: z.ZodLiteral<"event">;
|
|
98
|
-
after: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
99
|
-
date: z.ZodOptional<z.ZodObject<{
|
|
100
|
-
year: z.ZodNumber;
|
|
101
|
-
day: z.ZodNumber;
|
|
102
|
-
}, "strip", z.ZodTypeAny, {
|
|
103
|
-
year: number;
|
|
104
|
-
day: number;
|
|
105
|
-
}, {
|
|
106
|
-
year: number;
|
|
107
|
-
day: number;
|
|
108
|
-
}>>;
|
|
109
|
-
entities: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
110
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
111
|
-
export declare const knowledgeFileFrontmatterSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
112
|
-
title: z.ZodString;
|
|
113
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
114
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
115
|
-
} & {
|
|
116
|
-
type: z.ZodLiteral<"entity">;
|
|
117
|
-
entityType: z.ZodOptional<z.ZodString>;
|
|
118
|
-
supersedes: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
119
|
-
causedBy: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
120
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
121
|
-
title: z.ZodString;
|
|
122
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
123
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
124
|
-
} & {
|
|
125
|
-
type: z.ZodLiteral<"entity">;
|
|
126
|
-
entityType: z.ZodOptional<z.ZodString>;
|
|
127
|
-
supersedes: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
128
|
-
causedBy: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
129
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
130
|
-
title: z.ZodString;
|
|
131
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
132
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
133
|
-
} & {
|
|
134
|
-
type: z.ZodLiteral<"entity">;
|
|
135
|
-
entityType: z.ZodOptional<z.ZodString>;
|
|
136
|
-
supersedes: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
137
|
-
causedBy: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
138
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
139
|
-
title: z.ZodString;
|
|
140
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
141
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
142
|
-
} & {
|
|
143
|
-
type: z.ZodLiteral<"event">;
|
|
144
|
-
after: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
145
|
-
date: z.ZodOptional<z.ZodObject<{
|
|
146
|
-
year: z.ZodNumber;
|
|
147
|
-
day: z.ZodNumber;
|
|
148
|
-
}, "strip", z.ZodTypeAny, {
|
|
149
|
-
year: number;
|
|
150
|
-
day: number;
|
|
151
|
-
}, {
|
|
152
|
-
year: number;
|
|
153
|
-
day: number;
|
|
154
|
-
}>>;
|
|
155
|
-
entities: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
156
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
157
|
-
title: z.ZodString;
|
|
158
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
159
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
160
|
-
} & {
|
|
161
|
-
type: z.ZodLiteral<"event">;
|
|
162
|
-
after: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
163
|
-
date: z.ZodOptional<z.ZodObject<{
|
|
164
|
-
year: z.ZodNumber;
|
|
165
|
-
day: z.ZodNumber;
|
|
166
|
-
}, "strip", z.ZodTypeAny, {
|
|
167
|
-
year: number;
|
|
168
|
-
day: number;
|
|
169
|
-
}, {
|
|
170
|
-
year: number;
|
|
171
|
-
day: number;
|
|
172
|
-
}>>;
|
|
173
|
-
entities: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
174
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
175
|
-
title: z.ZodString;
|
|
176
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
177
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
178
|
-
} & {
|
|
179
|
-
type: z.ZodLiteral<"event">;
|
|
180
|
-
after: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
181
|
-
date: z.ZodOptional<z.ZodObject<{
|
|
182
|
-
year: z.ZodNumber;
|
|
183
|
-
day: z.ZodNumber;
|
|
184
|
-
}, "strip", z.ZodTypeAny, {
|
|
185
|
-
year: number;
|
|
186
|
-
day: number;
|
|
187
|
-
}, {
|
|
188
|
-
year: number;
|
|
189
|
-
day: number;
|
|
190
|
-
}>>;
|
|
191
|
-
entities: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
192
|
-
}, z.ZodTypeAny, "passthrough">>]>, z.objectOutputType<{
|
|
193
|
-
title: z.ZodString;
|
|
194
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
195
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
196
|
-
} & {
|
|
197
|
-
type: z.ZodLiteral<"entity">;
|
|
198
|
-
entityType: z.ZodOptional<z.ZodString>;
|
|
199
|
-
supersedes: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
200
|
-
causedBy: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
201
|
-
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
202
|
-
title: z.ZodString;
|
|
203
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
204
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
205
|
-
} & {
|
|
25
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
|
+
aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
206
27
|
type: z.ZodLiteral<"event">;
|
|
207
|
-
after: z.ZodOptional<z.ZodArray<z.
|
|
28
|
+
after: z.ZodOptional<z.ZodArray<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>>;
|
|
208
29
|
date: z.ZodOptional<z.ZodObject<{
|
|
209
30
|
year: z.ZodNumber;
|
|
210
31
|
day: z.ZodNumber;
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
year: number;
|
|
216
|
-
day: number;
|
|
217
|
-
}>>;
|
|
218
|
-
entities: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
219
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
32
|
+
}, z.core.$strip>>;
|
|
33
|
+
entities: z.ZodOptional<z.ZodArray<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>>;
|
|
34
|
+
}, z.core.$loose>;
|
|
35
|
+
export declare const knowledgeFileFrontmatterSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
220
36
|
title: z.ZodString;
|
|
221
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString
|
|
222
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString
|
|
223
|
-
} & {
|
|
37
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
38
|
+
aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
224
39
|
type: z.ZodLiteral<"entity">;
|
|
225
40
|
entityType: z.ZodOptional<z.ZodString>;
|
|
226
|
-
supersedes: z.ZodOptional<z.
|
|
227
|
-
causedBy: z.ZodOptional<z.
|
|
228
|
-
}, z.
|
|
41
|
+
supersedes: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
|
|
42
|
+
causedBy: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
|
|
43
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
229
44
|
title: z.ZodString;
|
|
230
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString
|
|
231
|
-
aliases: z.ZodOptional<z.ZodArray<z.ZodString
|
|
232
|
-
} & {
|
|
45
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
46
|
+
aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
233
47
|
type: z.ZodLiteral<"event">;
|
|
234
|
-
after: z.ZodOptional<z.ZodArray<z.
|
|
48
|
+
after: z.ZodOptional<z.ZodArray<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>>;
|
|
235
49
|
date: z.ZodOptional<z.ZodObject<{
|
|
236
50
|
year: z.ZodNumber;
|
|
237
51
|
day: z.ZodNumber;
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}, {
|
|
242
|
-
year: number;
|
|
243
|
-
day: number;
|
|
244
|
-
}>>;
|
|
245
|
-
entities: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
246
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
52
|
+
}, z.core.$strip>>;
|
|
53
|
+
entities: z.ZodOptional<z.ZodArray<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>>;
|
|
54
|
+
}, z.core.$loose>], "type">;
|
|
247
55
|
export type EntityFrontmatter = z.infer<typeof entityFrontmatterSchema>;
|
|
248
56
|
export type EventFrontmatter = z.infer<typeof eventFrontmatterSchema>;
|
|
249
57
|
export type KnowledgeFileFrontmatter = z.infer<typeof knowledgeFileFrontmatterSchema>;
|
|
@@ -21,7 +21,7 @@ export const entityFrontmatterSchema = commonFieldsSchema
|
|
|
21
21
|
supersedes: wikilinkSchema.optional(),
|
|
22
22
|
causedBy: wikilinkSchema.optional(),
|
|
23
23
|
})
|
|
24
|
-
.
|
|
24
|
+
.loose();
|
|
25
25
|
export const eventFrontmatterSchema = commonFieldsSchema
|
|
26
26
|
.extend({
|
|
27
27
|
type: z.literal("event"),
|
|
@@ -29,13 +29,13 @@ export const eventFrontmatterSchema = commonFieldsSchema
|
|
|
29
29
|
date: inWorldDateSchema.optional(),
|
|
30
30
|
entities: z.array(wikilinkSchema).optional(),
|
|
31
31
|
})
|
|
32
|
-
.
|
|
32
|
+
.loose();
|
|
33
33
|
export const knowledgeFileFrontmatterSchema = z
|
|
34
34
|
.discriminatedUnion("type", [entityFrontmatterSchema, eventFrontmatterSchema])
|
|
35
35
|
.superRefine((data, ctx) => {
|
|
36
36
|
if (data.type === "entity" && Boolean(data.supersedes) !== Boolean(data.causedBy)) {
|
|
37
37
|
ctx.addIssue({
|
|
38
|
-
code:
|
|
38
|
+
code: "custom",
|
|
39
39
|
message: '"supersedes" and "causedBy" must both be present, or both absent',
|
|
40
40
|
path: ["causedBy"],
|
|
41
41
|
});
|
package/dist/core/vault/read.js
CHANGED
|
@@ -42,8 +42,12 @@ export async function findVaultFilePath(vaultDir, id) {
|
|
|
42
42
|
}
|
|
43
43
|
/** Reads and parses one vault file by id. Never validates — see write.ts. */
|
|
44
44
|
export async function readVaultFile(vaultDir, id) {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
// Looked up among the vault's UUID-named files, never joined into a path: an
|
|
46
|
+
// id like "../notes" must not reach a file outside the vault.
|
|
47
|
+
const filePath = await findVaultFilePath(vaultDir, id);
|
|
48
|
+
if (!filePath)
|
|
49
|
+
throw new Error(`No file with id "${id}" in this vault.`);
|
|
50
|
+
return parseVaultFile(id, await readFile(filePath, "utf8"));
|
|
47
51
|
}
|
|
48
52
|
/**
|
|
49
53
|
* Reads every vault file: UUID-named `.md` files anywhere under vaultDir.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
/**
|
|
3
|
+
* What every agent connecting to the server is told up front: the
|
|
4
|
+
* world-vault skill's rules (skills/world-vault/SKILL.md), in terms of this
|
|
5
|
+
* server's tools instead of CLI commands.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MCP_INSTRUCTIONS = "This server reads and writes a world built with the World Building Framework: a vault of entity and event files, named by UUID. Use only these tools to read or change it; they validate everything before it's written.\n\n1. Call `schema` before writing anything. It lists every field, its shape, and an example input.\n2. Call `search` before creating something, to avoid duplicates and to get the UUIDs you link with.\n3. Links are always \"[[<uuid>|<current title>]]\", in frontmatter and in body text. Never a bare [[Name]].\n4. Before `create` or `update`, show the user the frontmatter and body you're about to write, and wait for their go-ahead.\n5. `update` is for corrections only (a typo, a wrong tag, a missing link). Call `read` first and send the file's complete new content: any field you leave out is removed. Changing a title rewrites links showing the old title in other files.\n6. A change in the story is never an update. Create a new entity file with `supersedes` (a link to the entity's latest version) and `causedBy` (a link to the event that caused the change). Other files keep linking to the entity's first file.\n7. Each published wiki (see `list_variants`) includes or leaves out whole files by their tags, and shows an included file in full. Keep secrets in their own files with narrower tags, never in the text of a file a wider audience sees.\n\nErrors in a result block a write; warnings don't, but mention them to the user.";
|
|
8
|
+
export interface McpServerOptions {
|
|
9
|
+
/** World folder; else WBF_VAULT_DIR, else the server's working folder if it has a world.config.json. */
|
|
10
|
+
vault?: string;
|
|
11
|
+
/** This framework's version, reported to clients. */
|
|
12
|
+
version: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The `wbf mcp` server (claude-dev/DISTRIBUTION_PLAN.md, component 6): the
|
|
16
|
+
* CLI's vault commands as MCP tools, for agents without a terminal. Each tool
|
|
17
|
+
* calls the same function as its CLI command; only `read` is extra, since an
|
|
18
|
+
* agent without a shell can't open a file to prepare an `update`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createMcpServer(options: McpServerOptions): McpServer;
|