@sharpee/story-loader 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/errors.d.ts +20 -0
- package/errors.d.ts.map +1 -0
- package/errors.js +16 -0
- package/errors.js.map +1 -0
- package/evaluator.d.ts +102 -0
- package/evaluator.d.ts.map +1 -0
- package/evaluator.js +384 -0
- package/evaluator.js.map +1 -0
- package/event-contract.d.ts +39 -0
- package/event-contract.d.ts.map +1 -0
- package/event-contract.js +35 -0
- package/event-contract.js.map +1 -0
- package/hatch-context.d.ts +57 -0
- package/hatch-context.d.ts.map +1 -0
- package/hatch-context.js +92 -0
- package/hatch-context.js.map +1 -0
- package/index.d.ts +24 -0
- package/index.d.ts.map +1 -0
- package/index.js +44 -0
- package/index.js.map +1 -0
- package/loader.d.ts +241 -0
- package/loader.d.ts.map +1 -0
- package/loader.js +923 -0
- package/loader.js.map +1 -0
- package/package.json +50 -0
- package/runtime.d.ts +250 -0
- package/runtime.d.ts.map +1 -0
- package/runtime.js +1249 -0
- package/runtime.js.map +1 -0
- package/state-keys.d.ts +23 -0
- package/state-keys.d.ts.map +1 -0
- package/state-keys.js +26 -0
- package/state-keys.js.map +1 -0
- package/text.d.ts +19 -0
- package/text.d.ts.map +1 -0
- package/text.js +24 -0
- package/text.js.map +1 -0
package/errors.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* errors.ts — story-loader load failure type.
|
|
3
|
+
*
|
|
4
|
+
* Purpose: the single error every load-time failure throws. Loading is
|
|
5
|
+
* atomic (ADR-210): the first LoadError aborts the load; there is no
|
|
6
|
+
* partial registration to clean up because the engine discards the world.
|
|
7
|
+
*
|
|
8
|
+
* Public interface: LoadError.
|
|
9
|
+
* Owner context: @sharpee/story-loader.
|
|
10
|
+
*/
|
|
11
|
+
import type { Span } from '@sharpee/chord';
|
|
12
|
+
/** A story failed to load. Carries the `.story` span when one is known. */
|
|
13
|
+
export declare class LoadError extends Error {
|
|
14
|
+
/** Source span in the `.story` file, when attributable. */
|
|
15
|
+
readonly span?: Span | undefined;
|
|
16
|
+
constructor(message: string,
|
|
17
|
+
/** Source span in the `.story` file, when attributable. */
|
|
18
|
+
span?: Span | undefined);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=errors.d.ts.map
|
package/errors.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/story-loader/src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,2EAA2E;AAC3E,qBAAa,SAAU,SAAQ,KAAK;IAGhC,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI;gBAFpB,OAAO,EAAE,MAAM;IACf,2DAA2D;IAClD,IAAI,CAAC,EAAE,IAAI,YAAA;CAKvB"}
|
package/errors.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoadError = void 0;
|
|
4
|
+
/** A story failed to load. Carries the `.story` span when one is known. */
|
|
5
|
+
class LoadError extends Error {
|
|
6
|
+
span;
|
|
7
|
+
constructor(message,
|
|
8
|
+
/** Source span in the `.story` file, when attributable. */
|
|
9
|
+
span) {
|
|
10
|
+
super(span ? `${message} (line ${span.line})` : message);
|
|
11
|
+
this.span = span;
|
|
12
|
+
this.name = 'LoadError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.LoadError = LoadError;
|
|
16
|
+
//# sourceMappingURL=errors.js.map
|
package/errors.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/story-loader/src/errors.ts"],"names":[],"mappings":";;;AAYA,2EAA2E;AAC3E,MAAa,SAAU,SAAQ,KAAK;IAIvB;IAHX,YACE,OAAe;IACf,2DAA2D;IAClD,IAAW;QAEpB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,UAAU,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAFhD,SAAI,GAAJ,IAAI,CAAO;QAGpB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AATD,8BASC"}
|
package/evaluator.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* evaluator.ts — the Chord expression evaluator (design.md §5.5, Phase A).
|
|
3
|
+
*
|
|
4
|
+
* Purpose: evaluate IR conditions and values against a live WorldModel —
|
|
5
|
+
* an AST walk, no eval(), no runtime TS. Covers the closed selector
|
|
6
|
+
* subset cloak.story exercises: possessive access (`the player's
|
|
7
|
+
* location`, `its state`), `is <state/trait>`, `is a`, `is in`,
|
|
8
|
+
* `has`/`holds`/`wears`, named conditions, and/or/not, and
|
|
9
|
+
* `one chance in <n>` through the seeded RNG.
|
|
10
|
+
*
|
|
11
|
+
* Public interface: Evaluator, EvalContext.
|
|
12
|
+
* Owner context: @sharpee/story-loader.
|
|
13
|
+
*
|
|
14
|
+
* Invariants:
|
|
15
|
+
* - Pure reads except the RNG draw (whose cursor persists in world state
|
|
16
|
+
* under `chord.rng`, so chance streams survive save/restore — AC-5/AC-6).
|
|
17
|
+
* - Unknown constructs throw LoadError: the compiler gates should make
|
|
18
|
+
* these unreachable; reaching one is a loader bug, not author error.
|
|
19
|
+
*/
|
|
20
|
+
import type { IRCondition, IRValue, StoryIR } from '@sharpee/chord';
|
|
21
|
+
import { WorldModel } from '@sharpee/world-model';
|
|
22
|
+
export interface EvalContext {
|
|
23
|
+
world: WorldModel;
|
|
24
|
+
/** IR entity id bound to `it` (the on-clause owner), when in scope. */
|
|
25
|
+
it?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Bound context values (Phase B dispatch): grammar-slot/role name →
|
|
28
|
+
* WORLD entity id (`animal` → the pet target, `actor` → the actor).
|
|
29
|
+
*/
|
|
30
|
+
slots?: Record<string, string>;
|
|
31
|
+
/**
|
|
32
|
+
* IR entity id bound to `the match` — the innermost enclosing `each`
|
|
33
|
+
* block's current entity (ratchet E3). Nested blocks re-spread the
|
|
34
|
+
* context, so the innermost binding naturally wins; `it` is untouched.
|
|
35
|
+
*/
|
|
36
|
+
match?: string;
|
|
37
|
+
}
|
|
38
|
+
/** Resolves IR ids to world ids (implemented by ChordStory). */
|
|
39
|
+
export interface EntityIdResolver {
|
|
40
|
+
entityId(irId: string): string | undefined;
|
|
41
|
+
irIdOf(worldId: string): string | undefined;
|
|
42
|
+
/** The player's world id once created (before the engine calls setPlayer). */
|
|
43
|
+
playerWorldId(): string | undefined;
|
|
44
|
+
}
|
|
45
|
+
export declare class Evaluator {
|
|
46
|
+
private readonly ids;
|
|
47
|
+
private readonly conditions;
|
|
48
|
+
private readonly rng;
|
|
49
|
+
/** trait name → its `entity`-typed data-field names (IR→world translation). */
|
|
50
|
+
private readonly entityFields;
|
|
51
|
+
/**
|
|
52
|
+
* IR entities in declaration order — the quantifier enumeration domain
|
|
53
|
+
* and E3's pinned "creation order" (the loader instantiates in this
|
|
54
|
+
* order; save/restore cannot reorder it, so iteration and the RNG draws
|
|
55
|
+
* inside `each` bodies stay deterministic — AC-5).
|
|
56
|
+
*/
|
|
57
|
+
private readonly irEntities;
|
|
58
|
+
private readonly irEntityById;
|
|
59
|
+
constructor(ir: StoryIR, ids: EntityIdResolver, seed?: number);
|
|
60
|
+
evalCondition(cond: IRCondition, ctx: EvalContext): boolean;
|
|
61
|
+
private evalPredicate;
|
|
62
|
+
/**
|
|
63
|
+
* `<subject> is <bare-word>`: a declared state, a state adjective read
|
|
64
|
+
* live from world trait state (ratchet D1 — never stored), or the `dark`
|
|
65
|
+
* trait.
|
|
66
|
+
*/
|
|
67
|
+
private symbolHolds;
|
|
68
|
+
/**
|
|
69
|
+
* State adjectives (ratchet D1): `open`/`closed`, `locked`/`unlocked`,
|
|
70
|
+
* `on`/`off`, `worn`, `lit` — pure reads of world trait state. Null when
|
|
71
|
+
* `symbol` is not a state adjective (or the trait is absent, so the
|
|
72
|
+
* adjective cannot hold either way).
|
|
73
|
+
*/
|
|
74
|
+
private stateAdjectiveHolds;
|
|
75
|
+
evalValue(value: IRValue, ctx: EvalContext): unknown;
|
|
76
|
+
/** The named condition's body, or a loader-bug throw. */
|
|
77
|
+
private namedCondition;
|
|
78
|
+
/** True when some domain entity satisfies the open condition (short-circuit). */
|
|
79
|
+
private someMatch;
|
|
80
|
+
/**
|
|
81
|
+
* The entities satisfying a named open condition, as IR ids in
|
|
82
|
+
* declaration order — E3's pinned creation-order enumeration. Used by
|
|
83
|
+
* the runtime's `each` execution and its pre-mutation snapshot.
|
|
84
|
+
*/
|
|
85
|
+
matchesOf(name: string, ctx: EvalContext): string[];
|
|
86
|
+
/** Evaluate a value that must be an entity (world id). */
|
|
87
|
+
entityValue(value: IRValue, ctx: EvalContext): string;
|
|
88
|
+
private readField;
|
|
89
|
+
/** Read a `define trait` data field off the entity's chord trait instances. */
|
|
90
|
+
private readChordTraitField;
|
|
91
|
+
private playerId;
|
|
92
|
+
private requireWorldId;
|
|
93
|
+
/** True when `thing` is located inside `container` at any depth. */
|
|
94
|
+
private isWithin;
|
|
95
|
+
/**
|
|
96
|
+
* `one chance in <n>`: seeded draw whose cursor persists in world state,
|
|
97
|
+
* so a fixed seed yields a byte-identical stream (AC-5) and restores
|
|
98
|
+
* resume the stream (AC-6).
|
|
99
|
+
*/
|
|
100
|
+
private drawChance;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=evaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/story-loader/src/evaluator.ts"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AAC,mBAAmB;IAqC3B,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO;IA0CpD,yDAAyD;IACzD,OAAO,CAAC,cAAc;IAMtB,iFAAiF;IACjF,OAAO,CAAC,SAAS;IAOjB;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,EAAE;IAOnD,0DAA0D;IAC1D,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM;IAQrD,OAAO,CAAC,SAAS;IA4BjB,+EAA+E;IAC/E,OAAO,CAAC,mBAAmB;IAoB3B,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,cAAc;IAMtB,oEAAoE;IACpE,OAAO,CAAC,QAAQ;IAShB;;;;OAIG;IACH,OAAO,CAAC,UAAU;CAQnB"}
|
package/evaluator.js
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Evaluator = void 0;
|
|
4
|
+
const core_1 = require("@sharpee/core");
|
|
5
|
+
const world_model_1 = require("@sharpee/world-model");
|
|
6
|
+
const errors_1 = require("./errors");
|
|
7
|
+
const state_keys_1 = require("./state-keys");
|
|
8
|
+
class Evaluator {
|
|
9
|
+
ids;
|
|
10
|
+
conditions = new Map();
|
|
11
|
+
rng;
|
|
12
|
+
/** trait name → its `entity`-typed data-field names (IR→world translation). */
|
|
13
|
+
entityFields = new Map();
|
|
14
|
+
/**
|
|
15
|
+
* IR entities in declaration order — the quantifier enumeration domain
|
|
16
|
+
* and E3's pinned "creation order" (the loader instantiates in this
|
|
17
|
+
* order; save/restore cannot reorder it, so iteration and the RNG draws
|
|
18
|
+
* inside `each` bodies stay deterministic — AC-5).
|
|
19
|
+
*/
|
|
20
|
+
irEntities;
|
|
21
|
+
irEntityById = new Map();
|
|
22
|
+
constructor(ir, ids, seed) {
|
|
23
|
+
this.ids = ids;
|
|
24
|
+
for (const c of ir.conditions)
|
|
25
|
+
this.conditions.set(c.name, c.condition);
|
|
26
|
+
this.irEntities = ir.entities;
|
|
27
|
+
for (const e of ir.entities)
|
|
28
|
+
this.irEntityById.set(e.id, e);
|
|
29
|
+
for (const trait of ir.traits) {
|
|
30
|
+
this.entityFields.set(trait.name, new Set(trait.data.filter((f) => f.type === 'entity').map((f) => f.name)));
|
|
31
|
+
}
|
|
32
|
+
this.rng = (0, core_1.createSeededRandom)(seed);
|
|
33
|
+
}
|
|
34
|
+
// ------------------------------------------------------------ conditions
|
|
35
|
+
evalCondition(cond, ctx) {
|
|
36
|
+
switch (cond.kind) {
|
|
37
|
+
case 'and':
|
|
38
|
+
return cond.operands.every((o) => this.evalCondition(o, ctx));
|
|
39
|
+
case 'or':
|
|
40
|
+
return cond.operands.some((o) => this.evalCondition(o, ctx));
|
|
41
|
+
case 'not':
|
|
42
|
+
return !this.evalCondition(cond.operand, ctx);
|
|
43
|
+
case 'chance':
|
|
44
|
+
return this.drawChance(cond.n, ctx.world);
|
|
45
|
+
case 'condition': {
|
|
46
|
+
const named = this.conditions.get(cond.name);
|
|
47
|
+
if (!named)
|
|
48
|
+
throw new errors_1.LoadError(`Unknown condition \`${cond.name}\` at evaluation time.`);
|
|
49
|
+
return this.evalCondition(named, ctx);
|
|
50
|
+
}
|
|
51
|
+
case 'story-state':
|
|
52
|
+
// The story object's phase (`while after-hours`, ratchet D2).
|
|
53
|
+
return ctx.world.getStateValue(state_keys_1.CHORD_STORY_STATE_KEY) === cond.state;
|
|
54
|
+
case 'any-of':
|
|
55
|
+
// E1 (ratchet 2026-07-12): true iff some entity satisfies the
|
|
56
|
+
// named open condition; false over the empty set. Short-circuits.
|
|
57
|
+
return this.someMatch(cond.condition, ctx);
|
|
58
|
+
case 'none-of':
|
|
59
|
+
// E2: the negated existential — true over the empty set.
|
|
60
|
+
return !this.someMatch(cond.condition, ctx);
|
|
61
|
+
case 'satisfies': {
|
|
62
|
+
// `<subject> must be any <name>` membership (David, 2026-07-12):
|
|
63
|
+
// the subject satisfies the open condition — its `it` bound to
|
|
64
|
+
// the subject. A subject outside the quantification domain (no
|
|
65
|
+
// story identity) is not one of the matches: false, not a throw.
|
|
66
|
+
const named = this.namedCondition(cond.condition);
|
|
67
|
+
const subjectId = this.entityValue(cond.subject, ctx);
|
|
68
|
+
const irId = this.ids.irIdOf(subjectId);
|
|
69
|
+
if (irId === undefined)
|
|
70
|
+
return false;
|
|
71
|
+
return this.evalCondition(named, { ...ctx, it: irId });
|
|
72
|
+
}
|
|
73
|
+
case 'predicate':
|
|
74
|
+
return this.evalPredicate(cond, ctx);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
evalPredicate(cond, ctx) {
|
|
78
|
+
const raw = (result) => (cond.negated ? !result : result);
|
|
79
|
+
switch (cond.pred) {
|
|
80
|
+
case 'is': {
|
|
81
|
+
const subject = this.evalValue(cond.subject, ctx);
|
|
82
|
+
if (cond.object.kind === 'symbol') {
|
|
83
|
+
return raw(this.symbolHolds(subject, cond.object.name, ctx));
|
|
84
|
+
}
|
|
85
|
+
return raw(String(subject) === String(this.evalValue(cond.object, ctx)));
|
|
86
|
+
}
|
|
87
|
+
case 'is-a': {
|
|
88
|
+
// Classification (landed with the each package, P4): the subject's
|
|
89
|
+
// IR kind-noun compositions (`a marble`, `a room`). An entity
|
|
90
|
+
// outside the story's IR classifies as nothing.
|
|
91
|
+
const subjectId = this.entityValue(cond.subject, ctx);
|
|
92
|
+
const irId = this.ids.irIdOf(subjectId);
|
|
93
|
+
const irEntity = irId !== undefined ? this.irEntityById.get(irId) : undefined;
|
|
94
|
+
if (!irEntity)
|
|
95
|
+
return raw(false);
|
|
96
|
+
const classifier = cond.object.kind === 'symbol' ? cond.object.name : String(this.evalValue(cond.object, ctx));
|
|
97
|
+
return raw(irEntity.kinds.some((k) => k.name === classifier));
|
|
98
|
+
}
|
|
99
|
+
case 'is-in': {
|
|
100
|
+
const subjectId = this.entityValue(cond.subject, ctx);
|
|
101
|
+
const placeId = this.entityValue(cond.object, ctx);
|
|
102
|
+
return raw(this.isWithin(ctx.world, subjectId, placeId));
|
|
103
|
+
}
|
|
104
|
+
case 'is-here': {
|
|
105
|
+
// Z4 deictic — Decision 10 presence semantics, mirroring the
|
|
106
|
+
// runtime's playerPresentAt: a room subject means the player is IN
|
|
107
|
+
// it; anything else shares the player's containing room; a
|
|
108
|
+
// no-location subject is never here (false, not an error).
|
|
109
|
+
const subjectId = this.entityValue(cond.subject, ctx);
|
|
110
|
+
const playerId = ctx.world.getPlayer()?.id;
|
|
111
|
+
if (!playerId)
|
|
112
|
+
return raw(false);
|
|
113
|
+
if (subjectId === playerId)
|
|
114
|
+
return raw(true);
|
|
115
|
+
const playerRoom = ctx.world.getContainingRoom(playerId)?.id ?? ctx.world.getLocation(playerId);
|
|
116
|
+
if (ctx.world.getEntity(subjectId)?.has(world_model_1.TraitType.ROOM))
|
|
117
|
+
return raw(playerRoom === subjectId);
|
|
118
|
+
const subjectRoom = ctx.world.getContainingRoom(subjectId)?.id ?? ctx.world.getLocation(subjectId);
|
|
119
|
+
return raw(subjectRoom !== undefined && subjectRoom === playerRoom);
|
|
120
|
+
}
|
|
121
|
+
case 'has': {
|
|
122
|
+
const owner = this.entityValue(cond.subject, ctx);
|
|
123
|
+
const thing = this.entityValue(cond.object, ctx);
|
|
124
|
+
return this.isWithin(ctx.world, thing, owner);
|
|
125
|
+
}
|
|
126
|
+
case 'holds': {
|
|
127
|
+
const owner = this.entityValue(cond.subject, ctx);
|
|
128
|
+
const thing = this.entityValue(cond.object, ctx);
|
|
129
|
+
return ctx.world.getLocation(thing) === owner;
|
|
130
|
+
}
|
|
131
|
+
case 'wears': {
|
|
132
|
+
const wearer = this.entityValue(cond.subject, ctx);
|
|
133
|
+
const thing = this.entityValue(cond.object, ctx);
|
|
134
|
+
const entity = ctx.world.getEntity(thing);
|
|
135
|
+
const wearable = entity?.get(world_model_1.TraitType.WEARABLE);
|
|
136
|
+
return wearable?.worn === true && wearable.wornBy === wearer;
|
|
137
|
+
}
|
|
138
|
+
case 'can-see':
|
|
139
|
+
case 'can-reach': {
|
|
140
|
+
// Phase B semantics: co-location — subject and object share a
|
|
141
|
+
// containing room. (Full perception/reach services are a later
|
|
142
|
+
// refinement; this matches the Zoo constructs' intent.)
|
|
143
|
+
const subjectId = this.entityValue(cond.subject, ctx);
|
|
144
|
+
const objectId = this.entityValue(cond.object, ctx);
|
|
145
|
+
const subjectRoom = ctx.world.getContainingRoom(subjectId)?.id ?? ctx.world.getLocation(subjectId);
|
|
146
|
+
const objectRoom = ctx.world.getContainingRoom(objectId)?.id ?? ctx.world.getLocation(objectId);
|
|
147
|
+
return raw(subjectRoom !== undefined && subjectRoom === objectRoom);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* `<subject> is <bare-word>`: a declared state, a state adjective read
|
|
153
|
+
* live from world trait state (ratchet D1 — never stored), or the `dark`
|
|
154
|
+
* trait.
|
|
155
|
+
*/
|
|
156
|
+
symbolHolds(subject, symbol, ctx) {
|
|
157
|
+
if (typeof subject === 'string') {
|
|
158
|
+
// A state string read from a `state` field compares directly.
|
|
159
|
+
if (subject === symbol)
|
|
160
|
+
return true;
|
|
161
|
+
const entity = ctx.world.getEntity(subject);
|
|
162
|
+
if (entity) {
|
|
163
|
+
if (symbol === 'dark') {
|
|
164
|
+
const room = entity.get(world_model_1.TraitType.ROOM);
|
|
165
|
+
return room?.isDark === true;
|
|
166
|
+
}
|
|
167
|
+
const irId = this.ids.irIdOf(subject);
|
|
168
|
+
if (irId !== undefined) {
|
|
169
|
+
const state = ctx.world.getStateValue(state_keys_1.CHORD_STATE_PREFIX + irId);
|
|
170
|
+
if (state !== undefined && state === symbol)
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
const adjective = this.stateAdjectiveHolds(entity, symbol);
|
|
174
|
+
if (adjective !== null)
|
|
175
|
+
return adjective;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* State adjectives (ratchet D1): `open`/`closed`, `locked`/`unlocked`,
|
|
182
|
+
* `on`/`off`, `worn`, `lit` — pure reads of world trait state. Null when
|
|
183
|
+
* `symbol` is not a state adjective (or the trait is absent, so the
|
|
184
|
+
* adjective cannot hold either way).
|
|
185
|
+
*/
|
|
186
|
+
stateAdjectiveHolds(entity, symbol) {
|
|
187
|
+
switch (symbol) {
|
|
188
|
+
case 'open':
|
|
189
|
+
case 'closed': {
|
|
190
|
+
const openable = entity.get(world_model_1.TraitType.OPENABLE);
|
|
191
|
+
if (!openable)
|
|
192
|
+
return null;
|
|
193
|
+
return symbol === 'open' ? openable.isOpen === true : openable.isOpen !== true;
|
|
194
|
+
}
|
|
195
|
+
case 'locked':
|
|
196
|
+
case 'unlocked': {
|
|
197
|
+
const lockable = entity.get(world_model_1.TraitType.LOCKABLE);
|
|
198
|
+
if (!lockable)
|
|
199
|
+
return null;
|
|
200
|
+
return symbol === 'locked' ? lockable.isLocked === true : lockable.isLocked !== true;
|
|
201
|
+
}
|
|
202
|
+
case 'on':
|
|
203
|
+
case 'off': {
|
|
204
|
+
const switchable = entity.get(world_model_1.TraitType.SWITCHABLE);
|
|
205
|
+
if (!switchable)
|
|
206
|
+
return null;
|
|
207
|
+
return symbol === 'on' ? switchable.isOn === true : switchable.isOn !== true;
|
|
208
|
+
}
|
|
209
|
+
case 'worn': {
|
|
210
|
+
const wearable = entity.get(world_model_1.TraitType.WEARABLE);
|
|
211
|
+
if (!wearable)
|
|
212
|
+
return null;
|
|
213
|
+
return wearable.worn === true;
|
|
214
|
+
}
|
|
215
|
+
case 'lit': {
|
|
216
|
+
const source = entity.get(world_model_1.TraitType.LIGHT_SOURCE);
|
|
217
|
+
if (!source)
|
|
218
|
+
return null;
|
|
219
|
+
return source.isLit === true;
|
|
220
|
+
}
|
|
221
|
+
default:
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// ---------------------------------------------------------------- values
|
|
226
|
+
evalValue(value, ctx) {
|
|
227
|
+
switch (value.kind) {
|
|
228
|
+
case 'literal':
|
|
229
|
+
return value.valueType === 'number' ? Number(value.value) : value.value;
|
|
230
|
+
case 'symbol':
|
|
231
|
+
return value.name;
|
|
232
|
+
case 'player':
|
|
233
|
+
return this.playerId(ctx.world);
|
|
234
|
+
case 'it': {
|
|
235
|
+
if (!ctx.it)
|
|
236
|
+
throw new errors_1.LoadError('`it` used outside an entity-scoped clause.');
|
|
237
|
+
return this.requireWorldId(ctx.it);
|
|
238
|
+
}
|
|
239
|
+
case 'story':
|
|
240
|
+
// The story object is not an entity — only `change` targets it.
|
|
241
|
+
throw new errors_1.LoadError('The story object has no entity value — use `change the story to <state>`.');
|
|
242
|
+
case 'entity':
|
|
243
|
+
return this.requireWorldId(value.id);
|
|
244
|
+
case 'field': {
|
|
245
|
+
const base = this.evalValue(value.base, ctx);
|
|
246
|
+
if (typeof base !== 'string') {
|
|
247
|
+
throw new errors_1.LoadError(`Cannot read \`${value.field}\` of a non-entity value.`);
|
|
248
|
+
}
|
|
249
|
+
return this.readField(base, value.field, ctx);
|
|
250
|
+
}
|
|
251
|
+
case 'slot': {
|
|
252
|
+
const bound = ctx.slots?.[value.name];
|
|
253
|
+
if (!bound) {
|
|
254
|
+
throw new errors_1.LoadError(`Context value \`${value.name}\` is not bound here.`);
|
|
255
|
+
}
|
|
256
|
+
return bound;
|
|
257
|
+
}
|
|
258
|
+
case 'match': {
|
|
259
|
+
// The `each`-block binder (ratchet E3) — the analyzer's
|
|
260
|
+
// match-outside-each gate makes an unbound read a loader bug.
|
|
261
|
+
if (!ctx.match)
|
|
262
|
+
throw new errors_1.LoadError('`the match` used outside an `each` block.');
|
|
263
|
+
return this.requireWorldId(ctx.match);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
// ------------------------------------------------------------ quantifiers
|
|
268
|
+
/** The named condition's body, or a loader-bug throw. */
|
|
269
|
+
namedCondition(name) {
|
|
270
|
+
const named = this.conditions.get(name);
|
|
271
|
+
if (!named)
|
|
272
|
+
throw new errors_1.LoadError(`Unknown condition \`${name}\` at evaluation time.`);
|
|
273
|
+
return named;
|
|
274
|
+
}
|
|
275
|
+
/** True when some domain entity satisfies the open condition (short-circuit). */
|
|
276
|
+
someMatch(name, ctx) {
|
|
277
|
+
const named = this.namedCondition(name);
|
|
278
|
+
return this.irEntities.some((e) => this.ids.entityId(e.id) !== undefined && this.evalCondition(named, { ...ctx, it: e.id }));
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* The entities satisfying a named open condition, as IR ids in
|
|
282
|
+
* declaration order — E3's pinned creation-order enumeration. Used by
|
|
283
|
+
* the runtime's `each` execution and its pre-mutation snapshot.
|
|
284
|
+
*/
|
|
285
|
+
matchesOf(name, ctx) {
|
|
286
|
+
const named = this.namedCondition(name);
|
|
287
|
+
return this.irEntities
|
|
288
|
+
.filter((e) => this.ids.entityId(e.id) !== undefined && this.evalCondition(named, { ...ctx, it: e.id }))
|
|
289
|
+
.map((e) => e.id);
|
|
290
|
+
}
|
|
291
|
+
/** Evaluate a value that must be an entity (world id). */
|
|
292
|
+
entityValue(value, ctx) {
|
|
293
|
+
const result = this.evalValue(value, ctx);
|
|
294
|
+
if (typeof result !== 'string' || !ctx.world.getEntity(result)) {
|
|
295
|
+
throw new errors_1.LoadError(`Expected an entity, got \`${String(result)}\`.`);
|
|
296
|
+
}
|
|
297
|
+
return result;
|
|
298
|
+
}
|
|
299
|
+
readField(worldId, field, ctx) {
|
|
300
|
+
switch (field) {
|
|
301
|
+
case 'location':
|
|
302
|
+
return ctx.world.getLocation(worldId);
|
|
303
|
+
case 'state': {
|
|
304
|
+
const irId = this.ids.irIdOf(worldId);
|
|
305
|
+
if (irId === undefined)
|
|
306
|
+
throw new errors_1.LoadError('Cannot read `state` of a non-story entity.');
|
|
307
|
+
return ctx.world.getStateValue(state_keys_1.CHORD_STATE_PREFIX + irId);
|
|
308
|
+
}
|
|
309
|
+
default: {
|
|
310
|
+
// Chord trait data fields (Phase B): stored as own properties on
|
|
311
|
+
// the entity's `chord.trait.*` instances. ONLY fields the trait
|
|
312
|
+
// declares as `entity`-typed translate IR id → world id — a plain
|
|
313
|
+
// word value may coincide with an entity id (`kind: parrot` on the
|
|
314
|
+
// parrot itself) and must stay a symbol.
|
|
315
|
+
const value = this.readChordTraitField(worldId, field, ctx);
|
|
316
|
+
if (value !== undefined) {
|
|
317
|
+
if (value.isEntityField && typeof value.value === 'string') {
|
|
318
|
+
const asEntity = this.ids.entityId(value.value);
|
|
319
|
+
if (asEntity)
|
|
320
|
+
return asEntity;
|
|
321
|
+
}
|
|
322
|
+
return value.value;
|
|
323
|
+
}
|
|
324
|
+
throw new errors_1.LoadError(`Field \`${field}\` is not supported here.`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
/** Read a `define trait` data field off the entity's chord trait instances. */
|
|
329
|
+
readChordTraitField(worldId, field, ctx) {
|
|
330
|
+
const entity = ctx.world.getEntity(worldId);
|
|
331
|
+
if (!entity)
|
|
332
|
+
return undefined;
|
|
333
|
+
for (const trait of entity.traits.values()) {
|
|
334
|
+
if (!trait.type.startsWith(state_keys_1.CHORD_TRAIT_PREFIX))
|
|
335
|
+
continue;
|
|
336
|
+
const record = trait;
|
|
337
|
+
if (field in record) {
|
|
338
|
+
const traitName = trait.type.slice(state_keys_1.CHORD_TRAIT_PREFIX.length);
|
|
339
|
+
return { value: record[field], isEntityField: this.entityFields.get(traitName)?.has(field) ?? false };
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return undefined;
|
|
343
|
+
}
|
|
344
|
+
// --------------------------------------------------------------- helpers
|
|
345
|
+
playerId(world) {
|
|
346
|
+
const id = world.getPlayer()?.id ?? this.ids.playerWorldId();
|
|
347
|
+
if (!id)
|
|
348
|
+
throw new errors_1.LoadError('No player entity exists yet.');
|
|
349
|
+
return id;
|
|
350
|
+
}
|
|
351
|
+
requireWorldId(irId) {
|
|
352
|
+
const id = this.ids.entityId(irId);
|
|
353
|
+
if (!id)
|
|
354
|
+
throw new errors_1.LoadError(`Entity \`${irId}\` has no world instance.`);
|
|
355
|
+
return id;
|
|
356
|
+
}
|
|
357
|
+
/** True when `thing` is located inside `container` at any depth. */
|
|
358
|
+
isWithin(world, thing, container) {
|
|
359
|
+
let current = world.getLocation(thing);
|
|
360
|
+
while (current) {
|
|
361
|
+
if (current === container)
|
|
362
|
+
return true;
|
|
363
|
+
current = world.getLocation(current);
|
|
364
|
+
}
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* `one chance in <n>`: seeded draw whose cursor persists in world state,
|
|
369
|
+
* so a fixed seed yields a byte-identical stream (AC-5) and restores
|
|
370
|
+
* resume the stream (AC-6).
|
|
371
|
+
*/
|
|
372
|
+
drawChance(n, world) {
|
|
373
|
+
if (n <= 1)
|
|
374
|
+
return true;
|
|
375
|
+
const stored = world.getStateValue(state_keys_1.CHORD_RNG_KEY);
|
|
376
|
+
if (typeof stored === 'number')
|
|
377
|
+
this.rng.setSeed(stored);
|
|
378
|
+
const hit = this.rng.int(1, n) === 1;
|
|
379
|
+
world.setStateValue(state_keys_1.CHORD_RNG_KEY, this.rng.getSeed());
|
|
380
|
+
return hit;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
exports.Evaluator = Evaluator;
|
|
384
|
+
//# sourceMappingURL=evaluator.js.map
|
package/evaluator.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/story-loader/src/evaluator.ts"],"names":[],"mappings":";;;AAoBA,wCAAiE;AACjE,sDAS8B;AAC9B,qCAAqC;AACrC,6CAA4G;AA2B5G,MAAa,SAAS;IAkB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,KAAK,SAAS;gBAAE,OAAO,IAAI,CAAC;YACvC,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACK,UAAU,CAAC,CAAS,EAAE,KAAiB;QAC7C,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QACxB,MAAM,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,0BAAa,CAAC,CAAC;QAClD,IAAI,OAAO,MAAM,KAAK,QAAQ;YAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QACrC,KAAK,CAAC,aAAa,CAAC,0BAAa,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACvD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AA/XD,8BA+XC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* event-contract.ts — the event-selector map (AC-9, ADR-210 Interface
|
|
3
|
+
* Contract 2 slice): Chord event verbs → the stdlib event types/payload
|
|
4
|
+
* fields the runtime binds and filters on.
|
|
5
|
+
*
|
|
6
|
+
* SYNC ENFORCEMENT: the type-only stdlib import below makes this package's
|
|
7
|
+
* BUILD fail if stdlib renames the event payload fields the map depends on
|
|
8
|
+
* (`toRoom` on actor-moved). Renaming the event TYPE string is caught by
|
|
9
|
+
* tests/event-selector.test.ts and the golden transcript gates.
|
|
10
|
+
*
|
|
11
|
+
* Public interface: EVENT_TRIGGERS, EVENT_PAYLOAD_FIELDS,
|
|
12
|
+
* enteringDestination.
|
|
13
|
+
* Owner context: @sharpee/story-loader (type-only stdlib dep; erased at emit).
|
|
14
|
+
*/
|
|
15
|
+
import type { ActorMovedEventData } from '@sharpee/stdlib';
|
|
16
|
+
/**
|
|
17
|
+
* Chord event verb → stdlib event type it binds to. Gerund register since
|
|
18
|
+
* the ownership package (ratchet D3): entity clauses read `after entering
|
|
19
|
+
* it`, so the map keys are gerunds.
|
|
20
|
+
*/
|
|
21
|
+
export declare const EVENT_TRIGGERS: Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* Payload fields each trigger's filter reads. The mapped types are
|
|
24
|
+
* compile-time probes: if stdlib renames a field, this file stops
|
|
25
|
+
* compiling — the AC-9 CI failure.
|
|
26
|
+
*/
|
|
27
|
+
export declare const EVENT_PAYLOAD_FIELDS: {
|
|
28
|
+
entering: keyof ActorMovedEventData & 'toRoom';
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Type-guarded read of an `entering` event's destination — the runtime's
|
|
32
|
+
* consumption-side half of the AC-9 contract (no blind payload casts). The
|
|
33
|
+
* return type is chained to the stdlib payload type so a field-type change
|
|
34
|
+
* fails this build too.
|
|
35
|
+
* @param data the raw event payload (unknown shape at the seam)
|
|
36
|
+
* @returns the destination room id, or undefined when absent/mis-shaped
|
|
37
|
+
*/
|
|
38
|
+
export declare function enteringDestination(data: unknown): ActorMovedEventData['toRoom'] | undefined;
|
|
39
|
+
//# sourceMappingURL=event-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-contract.d.ts","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/story-loader/src/event-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAEjD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE;IAAE,QAAQ,EAAE,MAAM,mBAAmB,GAAG,QAAQ,CAAA;CAElF,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,mBAAmB,CAAC,QAAQ,CAAC,GAAG,SAAS,CAI5F"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EVENT_PAYLOAD_FIELDS = exports.EVENT_TRIGGERS = void 0;
|
|
4
|
+
exports.enteringDestination = enteringDestination;
|
|
5
|
+
/**
|
|
6
|
+
* Chord event verb → stdlib event type it binds to. Gerund register since
|
|
7
|
+
* the ownership package (ratchet D3): entity clauses read `after entering
|
|
8
|
+
* it`, so the map keys are gerunds.
|
|
9
|
+
*/
|
|
10
|
+
exports.EVENT_TRIGGERS = {
|
|
11
|
+
entering: 'if.event.actor_moved',
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Payload fields each trigger's filter reads. The mapped types are
|
|
15
|
+
* compile-time probes: if stdlib renames a field, this file stops
|
|
16
|
+
* compiling — the AC-9 CI failure.
|
|
17
|
+
*/
|
|
18
|
+
exports.EVENT_PAYLOAD_FIELDS = {
|
|
19
|
+
entering: 'toRoom',
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Type-guarded read of an `entering` event's destination — the runtime's
|
|
23
|
+
* consumption-side half of the AC-9 contract (no blind payload casts). The
|
|
24
|
+
* return type is chained to the stdlib payload type so a field-type change
|
|
25
|
+
* fails this build too.
|
|
26
|
+
* @param data the raw event payload (unknown shape at the seam)
|
|
27
|
+
* @returns the destination room id, or undefined when absent/mis-shaped
|
|
28
|
+
*/
|
|
29
|
+
function enteringDestination(data) {
|
|
30
|
+
if (typeof data !== 'object' || data === null)
|
|
31
|
+
return undefined;
|
|
32
|
+
const value = data[exports.EVENT_PAYLOAD_FIELDS.entering];
|
|
33
|
+
return typeof value === 'string' ? value : undefined;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=event-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-contract.js","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/story-loader/src/event-contract.ts"],"names":[],"mappings":";;;AA0CA,kDAIC;AA9BD;;;;GAIG;AACU,QAAA,cAAc,GAA2B;IACpD,QAAQ,EAAE,sBAAsB;CACjC,CAAC;AAEF;;;;GAIG;AACU,QAAA,oBAAoB,GAAuD;IACtF,QAAQ,EAAE,QAAQ;CACnB,CAAC;AAEF;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAC,IAAa;IAC/C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAChE,MAAM,KAAK,GAAI,IAAgC,CAAC,4BAAoB,CAAC,QAAQ,CAAC,CAAC;IAC/E,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC"}
|