chore: bootstrap nana-story M0

This commit is contained in:
Codex
2026-07-28 12:51:00 +08:00
commit 3dacc92423
71 changed files with 6840 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
374a325cf1198df128248876fe7f115b41b899777a89609f87cb4ba9e2958239
+18
View File
@@ -0,0 +1,18 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "AppInfo",
"type": "object",
"required": ["name", "version", "contractVersion"],
"properties": {
"name": {
"type": "string"
},
"version": {
"type": "string"
},
"contractVersion": {
"type": "integer"
}
},
"additionalProperties": false
}
@@ -0,0 +1,64 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "CharacterCard",
"type": "object",
"required": [
"header",
"name",
"identity",
"personality",
"values",
"boundaries",
"style",
"initial_relationship",
"judgment_rules",
"skills",
"default_expression"
],
"properties": {
"header": {
"$ref": "resource-header.schema.json"
},
"name": {
"type": "string",
"minLength": 1
},
"identity": {
"type": "string",
"minLength": 1
},
"personality": {
"type": "array",
"items": {
"type": "string"
}
},
"values": {
"type": "array",
"items": {
"type": "string"
}
},
"boundaries": {
"type": "array",
"items": {
"type": "string"
}
},
"style": {
"type": "object"
},
"initial_relationship": {
"type": "object"
},
"judgment_rules": {
"type": "array"
},
"skills": {
"type": "array"
},
"default_expression": {
"type": "string"
}
}
}
@@ -0,0 +1,42 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "DemoPackSummary",
"type": "object",
"required": [
"id",
"displayName",
"revision",
"characters",
"worldBooks",
"personas",
"plotModules",
"itemSpecs"
],
"properties": {
"id": {
"type": "string"
},
"displayName": {
"type": "string"
},
"revision": {
"type": "string"
},
"characters": {
"type": "integer"
},
"worldBooks": {
"type": "integer"
},
"personas": {
"type": "integer"
},
"plotModules": {
"type": "integer"
},
"itemSpecs": {
"type": "integer"
}
},
"additionalProperties": false
}
+38
View File
@@ -0,0 +1,38 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ItemSpec",
"type": "object",
"required": [
"header",
"name",
"description",
"tags",
"lore_refs",
"mechanics",
"hidden_facts"
],
"properties": {
"header": {
"$ref": "resource-header.schema.json"
},
"name": {
"type": "string",
"minLength": 1
},
"description": {
"type": "string"
},
"tags": {
"type": "array"
},
"lore_refs": {
"type": "array"
},
"mechanics": {
"type": "object"
},
"hidden_facts": {
"type": "array"
}
}
}
+30
View File
@@ -0,0 +1,30 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Persona",
"type": "object",
"required": ["header", "name", "identity", "traits", "skills", "initial_items"],
"properties": {
"header": {
"$ref": "resource-header.schema.json"
},
"name": {
"type": "string",
"minLength": 1
},
"identity": {
"type": "string"
},
"traits": {
"type": "array"
},
"skills": {
"type": "array"
},
"initial_items": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
+70
View File
@@ -0,0 +1,70 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "PlayerView",
"type": "object",
"required": [
"storyId",
"nodeId",
"branchId",
"sceneId",
"sceneTitle",
"characterName",
"beats",
"suggestions",
"inventory",
"knowledge",
"promises",
"relationship",
"history",
"canContinue"
],
"properties": {
"storyId": {
"type": "string"
},
"nodeId": {
"type": "string"
},
"branchId": {
"type": "string"
},
"sceneId": {
"type": "string"
},
"sceneTitle": {
"type": "string"
},
"characterName": {
"type": "string"
},
"beats": {
"type": "array",
"items": {
"type": "object",
"required": ["id", "kind", "speaker", "text", "visual"]
}
},
"suggestions": {
"type": "array"
},
"inventory": {
"type": "array"
},
"knowledge": {
"type": "array"
},
"promises": {
"type": "array"
},
"relationship": {
"type": "object"
},
"history": {
"type": "array"
},
"canContinue": {
"type": "boolean"
}
},
"additionalProperties": false
}
+25
View File
@@ -0,0 +1,25 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "PlotModule",
"type": "object",
"required": ["header", "name", "opening_event", "events"],
"properties": {
"header": {
"$ref": "resource-header.schema.json"
},
"name": {
"type": "string",
"minLength": 1
},
"opening_event": {
"type": "string",
"minLength": 1
},
"events": {
"type": "array",
"items": {
"type": "object"
}
}
}
}
@@ -0,0 +1,76 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ResourceBundle",
"type": "object",
"required": [
"id",
"schema_version",
"revision",
"display_name",
"entry_character",
"entry_persona",
"entry_plot_module",
"characters",
"world_books",
"personas",
"plot_modules",
"item_specs"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[a-z0-9_]+(?:\\.[a-z0-9_]+)+$"
},
"schema_version": {
"const": 1
},
"revision": {
"type": "string",
"pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
},
"display_name": {
"type": "string",
"minLength": 1
},
"entry_character": {
"type": "string"
},
"entry_persona": {
"type": "string"
},
"entry_plot_module": {
"type": ["string", "null"]
},
"characters": {
"type": "array",
"items": {
"$ref": "character-card.schema.json"
}
},
"world_books": {
"type": "array",
"items": {
"$ref": "world-book.schema.json"
}
},
"personas": {
"type": "array",
"items": {
"$ref": "persona.schema.json"
}
},
"plot_modules": {
"type": "array",
"items": {
"$ref": "plot-module.schema.json"
}
},
"item_specs": {
"type": "array",
"items": {
"$ref": "item-spec.schema.json"
}
}
},
"additionalProperties": false
}
@@ -0,0 +1,33 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ResourceHeader",
"type": "object",
"required": ["id", "kind", "schema_version", "revision", "content_hash", "dependencies"],
"properties": {
"id": {
"type": "string",
"pattern": "^[a-z0-9_]+(?:\\.[a-z0-9_]+)+$"
},
"kind": {
"enum": ["character", "world_book", "persona", "plot_module", "item_spec"]
},
"schema_version": {
"const": 1
},
"revision": {
"type": "string",
"pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
},
"content_hash": {
"type": "string",
"pattern": "^sha256:[0-9a-f]{64}$"
},
"dependencies": {
"type": "array",
"items": {
"type": "object"
}
}
},
"additionalProperties": false
}
@@ -0,0 +1,54 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "RuntimeState",
"type": "object",
"required": [
"story_id",
"current_node",
"current_branch",
"world_flags",
"relationships",
"relationship_states",
"promises",
"knowledge",
"items",
"clocks",
"checks"
],
"properties": {
"story_id": {
"type": "string"
},
"current_node": {
"type": "string"
},
"current_branch": {
"type": "string"
},
"world_flags": {
"type": "object"
},
"relationships": {
"type": "object"
},
"relationship_states": {
"type": "array"
},
"promises": {
"type": "array"
},
"knowledge": {
"type": "array"
},
"items": {
"type": "array"
},
"clocks": {
"type": "array"
},
"checks": {
"type": "array"
}
},
"additionalProperties": false
}
+45
View File
@@ -0,0 +1,45 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "StoryNode",
"type": "object",
"required": [
"id",
"story_id",
"branch_id",
"parent_id",
"action_id",
"user_input",
"beats",
"delta",
"state_hash"
],
"properties": {
"id": {
"type": "string"
},
"story_id": {
"type": "string"
},
"branch_id": {
"type": "string"
},
"parent_id": {
"type": ["string", "null"]
},
"action_id": {
"type": "string"
},
"user_input": {
"type": "string"
},
"beats": {
"type": "array"
},
"delta": {
"type": "object"
},
"state_hash": {
"type": "string"
}
}
}
+26
View File
@@ -0,0 +1,26 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "TurnFailure",
"type": "object",
"required": ["code", "message", "retryable"],
"properties": {
"code": {
"enum": [
"stale_node",
"invalid_input",
"invalid_model_output",
"provider_unavailable",
"cancelled",
"timed_out",
"internal"
]
},
"message": {
"type": "string"
},
"retryable": {
"type": "boolean"
}
},
"additionalProperties": false
}
+34
View File
@@ -0,0 +1,34 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "TurnRequest",
"type": "object",
"required": [
"storyId",
"branchId",
"expectedNodeId",
"actionId",
"intent",
"input"
],
"properties": {
"storyId": {
"type": "string"
},
"branchId": {
"type": "string"
},
"expectedNodeId": {
"type": "string"
},
"actionId": {
"type": "string"
},
"intent": {
"enum": ["speak_or_act", "continue", "regenerate", "push_check"]
},
"input": {
"type": "string"
}
},
"additionalProperties": false
}
+15
View File
@@ -0,0 +1,15 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "TurnResult",
"type": "object",
"required": ["committedNodeId", "playerView"],
"properties": {
"committedNodeId": {
"type": "string"
},
"playerView": {
"$ref": "player-view.schema.json"
}
},
"additionalProperties": false
}
+21
View File
@@ -0,0 +1,21 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "WorldBook",
"type": "object",
"required": ["header", "name", "entries"],
"properties": {
"header": {
"$ref": "resource-header.schema.json"
},
"name": {
"type": "string",
"minLength": 1
},
"entries": {
"type": "array",
"items": {
"type": "object"
}
}
}
}
+349
View File
@@ -0,0 +1,349 @@
// @generated by crates/nana-contracts; do not edit.
export type ResourceId = string;
export type ResourceKind =
| "character"
| "world_book"
| "persona"
| "plot_module"
| "item_spec";
export interface ResourceRef {
id: ResourceId;
kind: ResourceKind;
revision: string;
content_hash: string;
}
export interface ResourceHeader {
id: ResourceId;
kind: ResourceKind;
schema_version: number;
revision: string;
content_hash: string;
dependencies: ResourceRef[];
}
export type RelationshipDimension =
| "affinity"
| "trust"
| "hope"
| "respect"
| "intimacy"
| "attachment";
export interface RelationshipAxes {
affinity: number;
trust: number;
hope: number;
respect: number;
intimacy: number;
attachment: number;
}
export interface RelationshipAdjustment {
dimension: RelationshipDimension;
delta: number;
cause: string;
judgment_rule: string | null;
}
export interface SkillValue {
skill: string;
value: number;
}
export interface CharacterCard {
header: ResourceHeader;
name: string;
identity: string;
personality: string[];
values: string[];
boundaries: string[];
style: {
speech: string;
mannerisms: string[];
forbidden_player_assumptions: string[];
};
initial_relationship: RelationshipAxes;
judgment_rules: Array<{
tags: string[];
meaning: string;
relationship_effects: RelationshipAdjustment[];
}>;
skills: SkillValue[];
default_expression: string;
}
export interface WorldBook {
header: ResourceHeader;
name: string;
entries: Array<{
id: string;
title: string;
content: string;
keywords: string[];
tags: string[];
required_flags: string[];
}>;
}
export interface Persona {
header: ResourceHeader;
name: string;
identity: string;
traits: string[];
skills: SkillValue[];
initial_items: ResourceId[];
}
export interface PlotModule {
header: ResourceHeader;
name: string;
opening_event: string;
events: Array<{
id: string;
title: string;
tags: string[];
situation: string[];
required_flags: string[];
pressures: Array<{
id: string;
description: string;
clock_id: string | null;
clock_delta: number | null;
}>;
outcomes: Array<{
id: string;
description: string;
effects: StateOp[];
}>;
}>;
}
export interface ItemSpec {
header: ResourceHeader;
name: string;
description: string;
tags: string[];
lore_refs: string[];
mechanics: {
usable: boolean;
grants_tags: string[];
check_modifier: number | null;
};
hidden_facts: string[];
}
export interface ResourceBundle {
id: string;
schema_version: number;
revision: string;
display_name: string;
entry_character: ResourceId;
entry_persona: ResourceId;
entry_plot_module: ResourceId | null;
characters: CharacterCard[];
world_books: WorldBook[];
personas: Persona[];
plot_modules: PlotModule[];
item_specs: ItemSpec[];
}
export type PromiseStatus =
| "proposed"
| "accepted"
| "fulfilled"
| "broken"
| "released"
| "impossible";
export type PromiseWeight = "minor" | "major";
export type KnowledgeCertainty = "suspected" | "reported" | "confirmed";
export type ItemPlacement = "bag" | "worn" | "hand" | "scene" | "hidden";
export type AcquisitionMode = "initial" | "found" | "given" | "borrowed" | "stolen" | "returned";
export interface Promise {
id: string;
promiser: string;
promisee: string;
content: string;
status: PromiseStatus;
weight: PromiseWeight;
created_at: string;
accepted_at: string | null;
resolved_at: string | null;
}
export interface KnowledgeRecord {
id: string;
observer: string;
subject: string | null;
fact: string;
certainty: KnowledgeCertainty;
source: string;
learned_at: string;
last_verified_at: string | null;
}
export interface ItemInstance {
id: string;
spec_ref: ResourceId;
owner: string;
holder: string;
placement: ItemPlacement;
quantity: number;
condition: string;
state_tags: string[];
acquisition: {
mode: AcquisitionMode;
from: string | null;
at_node: string;
};
}
export interface RuntimeState {
story_id: string;
current_node: string;
current_branch: string;
world_flags: Record<string, boolean>;
relationships: Record<string, RelationshipAxes>;
relationship_states: unknown[];
promises: Promise[];
knowledge: KnowledgeRecord[];
items: ItemInstance[];
clocks: unknown[];
checks: unknown[];
}
export type StateOp =
| { op: "set_world_flag"; key: string; value: boolean }
| { op: "adjust_relationship"; from: string; to: string; adjustment: RelationshipAdjustment }
| { op: "create_promise"; promise: Promise }
| { op: "update_promise"; promise_id: string; status: PromiseStatus; resolved_at: string | null }
| { op: "add_knowledge"; record: KnowledgeRecord }
| { op: "add_item"; item: ItemInstance }
| {
op: "transfer_item";
item_id: string;
from: string;
to: string;
placement: ItemPlacement;
mode: AcquisitionMode;
}
| { op: "record_check"; check: unknown }
| { op: "advance_clock"; clock_id: string; delta: number };
export type BeatKind = "narration" | "dialogue" | "action" | "system";
export interface PresentationBeat {
id: string;
kind: BeatKind;
speaker: string | null;
text: string;
visual: {
character: string | null;
expression: string | null;
pose: string | null;
scene: string | null;
} | null;
}
export type RelationshipBand = "distant" | "guarded" | "warming" | "close" | "bonded";
export interface RelationshipView {
affinity: RelationshipBand;
trust: RelationshipBand;
hope: RelationshipBand;
respect: RelationshipBand;
intimacy: RelationshipBand;
attachment: RelationshipBand;
updatedAtNode: string | null;
}
export interface PlayerView {
storyId: string;
nodeId: string;
branchId: string;
sceneId: string;
sceneTitle: string;
characterName: string;
beats: PresentationBeat[];
suggestions: Array<{ id: string; label: string; draft: string }>;
inventory: Array<{
instanceId: string;
name: string;
description: string;
quantity: number;
placement: ItemPlacement;
condition: string;
}>;
knowledge: Array<{
id: string;
title: string;
summary: string;
certainty: KnowledgeCertainty;
}>;
promises: Array<{
id: string;
content: string;
status: PromiseStatus;
weight: PromiseWeight;
}>;
relationship: RelationshipView;
history: Array<{
id: string;
parentId: string | null;
branchId: string;
label: string;
isCurrent: boolean;
}>;
canContinue: boolean;
}
export type TurnIntent = "speak_or_act" | "continue" | "regenerate" | "push_check";
export interface TurnRequest {
storyId: string;
branchId: string;
expectedNodeId: string;
actionId: string;
intent: TurnIntent;
input: string;
}
export interface TurnResult {
committedNodeId: string;
playerView: PlayerView;
}
export type TurnFailureCode =
| "stale_node"
| "invalid_input"
| "invalid_model_output"
| "provider_unavailable"
| "cancelled"
| "timed_out"
| "internal";
export interface TurnFailure {
code: TurnFailureCode;
message: string;
retryable: boolean;
}
export interface AppInfo {
name: string;
version: string;
contractVersion: number;
}
export interface DemoPackSummary {
id: string;
displayName: string;
revision: string;
characters: number;
worldBooks: number;
personas: number;
plotModules: number;
itemSpecs: number;
}