@sharpee/if-domain 5.4.1 → 5.5.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/channels/index.d.ts +3 -1
- package/channels/index.d.ts.map +1 -1
- package/channels/index.js +2 -0
- package/channels/index.js.map +1 -1
- package/channels/types.d.ts +80 -2
- package/channels/types.d.ts.map +1 -1
- package/channels/types.js.map +1 -1
- package/grammar/grammar-builder.d.ts +162 -156
- package/grammar/grammar-builder.d.ts.map +1 -1
- package/grammar/grammar-builder.js +1 -1
- package/grammar/grammar-builder.js.map +1 -1
- package/grammar/grammar-engine.d.ts +8 -10
- package/grammar/grammar-engine.d.ts.map +1 -1
- package/grammar/grammar-engine.js +129 -182
- package/grammar/grammar-engine.js.map +1 -1
- package/grammar/index.d.ts +1 -0
- package/grammar/index.d.ts.map +1 -1
- package/grammar/index.js +1 -0
- package/grammar/index.js.map +1 -1
- package/grammar/pattern-compiler.d.ts +20 -16
- package/grammar/pattern-compiler.d.ts.map +1 -1
- package/grammar/pattern-compiler.js +6 -1
- package/grammar/pattern-compiler.js.map +1 -1
- package/grammar/rule-order.d.ts +53 -0
- package/grammar/rule-order.d.ts.map +1 -0
- package/grammar/rule-order.js +47 -0
- package/grammar/rule-order.js.map +1 -0
- package/grammar/scope-builder.d.ts +10 -3
- package/grammar/scope-builder.d.ts.map +1 -1
- package/grammar/scope-builder.js +12 -13
- package/grammar/scope-builder.js.map +1 -1
- package/language-provider.d.ts +10 -1
- package/language-provider.d.ts.map +1 -1
- package/package.json +3 -3
- package/parser-contracts/parser-internals.d.ts +0 -12
- package/parser-contracts/parser-internals.d.ts.map +1 -1
- package/parser-contracts/parser-internals.js.map +1 -1
- package/parser-contracts/parser-types.d.ts +0 -12
- package/parser-contracts/parser-types.d.ts.map +1 -1
- package/parser-language-provider.d.ts +28 -35
- package/parser-language-provider.d.ts.map +1 -1
- package/sound/types.d.ts +21 -0
- package/sound/types.d.ts.map +1 -1
- package/sound/types.js +21 -1
- package/sound/types.js.map +1 -1
- package/vocabulary-contracts/vocabulary-adapters.d.ts +6 -2
- package/vocabulary-contracts/vocabulary-adapters.d.ts.map +1 -1
- package/vocabulary-contracts/vocabulary-adapters.js +8 -33
- package/vocabulary-contracts/vocabulary-adapters.js.map +1 -1
- package/vocabulary-contracts/vocabulary-registry.d.ts +9 -23
- package/vocabulary-contracts/vocabulary-registry.d.ts.map +1 -1
- package/vocabulary-contracts/vocabulary-registry.js +10 -66
- package/vocabulary-contracts/vocabulary-registry.js.map +1 -1
- package/vocabulary-contracts/vocabulary-types.d.ts +22 -25
- package/vocabulary-contracts/vocabulary-types.d.ts.map +1 -1
- package/vocabulary-contracts/vocabulary-types.js.map +1 -1
package/channels/index.d.ts
CHANGED
|
@@ -13,12 +13,14 @@
|
|
|
13
13
|
* configuration enums (§3, §4, §5).
|
|
14
14
|
* - `ClientCapabilities`, `CapabilityFlag` — capability declaration and
|
|
15
15
|
* the gating discriminator (§2, §6).
|
|
16
|
+
* - `HeadingPart`, `LocationHeadingValue` — the `location` channel's
|
|
17
|
+
* structured payload (ADR-349 D11, D12).
|
|
16
18
|
* - `ChannelDefinition`, `HelloPacket`, `CmgtPacket`, `TurnPacket`,
|
|
17
19
|
* `CommandPacket`, `WirePacket` — wire-protocol packets (§1, §11).
|
|
18
20
|
*
|
|
19
21
|
* @see ADR-163 — Channel-Service Platform
|
|
20
22
|
*/
|
|
21
|
-
export type { ChannelContentType, ChannelMode, ChannelEmitPolicy, ClientCapabilities, CapabilityFlag, ChannelProduceContext, IOChannel, IChannelRegistry, ProseEntry, PreferredLayout, ProseChannelId, } from './types.js';
|
|
23
|
+
export type { ChannelContentType, ChannelMode, ChannelEmitPolicy, ClientCapabilities, CapabilityFlag, ChannelProduceContext, IOChannel, IChannelRegistry, ChannelRegistrationPosition, ProseEntry, PreferredLayout, ProseChannelId, HeadingPart, LocationHeadingValue, } from './types.js';
|
|
22
24
|
export { PREFERRED_LAYOUT_CHANNEL, PROSE_CHANNEL_IDS } from './types.js';
|
|
23
25
|
export type { ChannelDefinition, HelloPacket, CmgtPacket, TurnPacket, CommandPacket, WirePacket, } from './wire.js';
|
|
24
26
|
//# sourceMappingURL=index.d.ts.map
|
package/channels/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/channels/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/channels/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,YAAY,EACV,kBAAkB,EAClB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAChB,2BAA2B,EAC3B,UAAU,EACV,eAAe,EACf,cAAc,EACd,WAAW,EACX,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEzE,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,UAAU,EACV,aAAa,EACb,UAAU,GACX,MAAM,WAAW,CAAC"}
|
package/channels/index.js
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* configuration enums (§3, §4, §5).
|
|
15
15
|
* - `ClientCapabilities`, `CapabilityFlag` — capability declaration and
|
|
16
16
|
* the gating discriminator (§2, §6).
|
|
17
|
+
* - `HeadingPart`, `LocationHeadingValue` — the `location` channel's
|
|
18
|
+
* structured payload (ADR-349 D11, D12).
|
|
17
19
|
* - `ChannelDefinition`, `HelloPacket`, `CmgtPacket`, `TurnPacket`,
|
|
18
20
|
* `CommandPacket`, `WirePacket` — wire-protocol packets (§1, §11).
|
|
19
21
|
*
|
package/channels/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/channels/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/channels/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAmBH,uCAAyE;AAAhE,oHAAA,wBAAwB,OAAA;AAAE,6GAAA,iBAAiB,OAAA"}
|
package/channels/types.d.ts
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* @see ADR-163 — Channel-Service Platform — §6, §7, §14
|
|
25
25
|
*/
|
|
26
26
|
import type { ISemanticEvent, Presence } from '@sharpee/core';
|
|
27
|
-
import type { ITextBlock, TextContent } from '@sharpee/text-blocks';
|
|
27
|
+
import type { IBlockSource, ITextBlock, TextContent } from '@sharpee/text-blocks';
|
|
28
28
|
/**
|
|
29
29
|
* Channel content types (ADR-163 §3).
|
|
30
30
|
*
|
|
@@ -88,6 +88,13 @@ export interface ProseEntry {
|
|
|
88
88
|
* Mirrors `ITextBlock.location`; set only alongside `presence`.
|
|
89
89
|
*/
|
|
90
90
|
readonly location?: string;
|
|
91
|
+
/**
|
|
92
|
+
* The message the entry's text was rendered from (ADR-333 D1). Mirrors
|
|
93
|
+
* `ITextBlock.source` — the same `IBlockSource` type, imported, never
|
|
94
|
+
* redeclared — so a client can address the paragraph's source by id.
|
|
95
|
+
* Absent on entries not rendered from a message.
|
|
96
|
+
*/
|
|
97
|
+
readonly source?: IBlockSource;
|
|
91
98
|
}
|
|
92
99
|
/**
|
|
93
100
|
* Wire value of the `preferred-layout` channel (ADR-300 D9).
|
|
@@ -127,6 +134,60 @@ export declare const PREFERRED_LAYOUT_CHANNEL = "preferred-layout";
|
|
|
127
134
|
export declare const PROSE_CHANNEL_IDS: readonly ["room-name", "room-description", "room-contents", "action-result", "action-blocked", "error", "game-message"];
|
|
128
135
|
/** One of the platform's prose channel ids. */
|
|
129
136
|
export type ProseChannelId = (typeof PROSE_CHANNEL_IDS)[number];
|
|
137
|
+
/**
|
|
138
|
+
* One contributor's text for the current location heading (ADR-349 D11).
|
|
139
|
+
*
|
|
140
|
+
* A heading is an ordered list of these, emitted place then enclosure. A region
|
|
141
|
+
* contributes no part (ADR-360 D6). The projection that builds them lives
|
|
142
|
+
* in `@sharpee/world-model` (`LocationHeadingBehavior.resolve`); the type lives
|
|
143
|
+
* here because the projection's producer and the wire's consumers are in
|
|
144
|
+
* different packages and must share the shape by import, never by mirroring.
|
|
145
|
+
*/
|
|
146
|
+
export interface HeadingPart {
|
|
147
|
+
/** The entity that supplied this text — the place or the enclosure. */
|
|
148
|
+
readonly ownerId: string;
|
|
149
|
+
/** The winning arm's resolved prose, pre-decoration. */
|
|
150
|
+
readonly text: string;
|
|
151
|
+
readonly role: 'place' | 'enclosure';
|
|
152
|
+
/**
|
|
153
|
+
* This contributor declared at least one conditional arm, so its text was
|
|
154
|
+
* chosen by consulting the world (ADR-364 D4; amends ADR-349 D11).
|
|
155
|
+
*
|
|
156
|
+
* Static, not a report of what happened this turn: it is true whenever any
|
|
157
|
+
* arm carries a condition, whether or not that arm won, because a heading
|
|
158
|
+
* that *can* vary is the thing auto-assertion must not pin (ADR-349 D14).
|
|
159
|
+
*
|
|
160
|
+
* **Its reader is `@sharpee/lang-en-us`**, which wraps a variable part so the
|
|
161
|
+
* realized run carries provenance to the wire. It rides `HeadingPart` because
|
|
162
|
+
* that is the only channel from the projection to the locale — and because
|
|
163
|
+
* `HeadingPart` is also the `location` channel's payload, it reaches clients
|
|
164
|
+
* too, where nothing reads it. That double duty is ADR-349's design, recorded
|
|
165
|
+
* here rather than left to be rediscovered.
|
|
166
|
+
*/
|
|
167
|
+
readonly variable?: boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Wire value of the `location` channel (ADR-349 D12).
|
|
171
|
+
*
|
|
172
|
+
* Structured, not a bare string: a client that wants to style or drop a part
|
|
173
|
+
* needs the parts, and a client that just writes a status field needs the
|
|
174
|
+
* realized text. Both ride together so neither consumer re-derives the other.
|
|
175
|
+
*
|
|
176
|
+
* `text` is the locale's realization of `parts` — the English Assembler joins
|
|
177
|
+
* them as a `Sequence` under its punctuation authority (D13), so a client
|
|
178
|
+
* displays it verbatim and never re-joins.
|
|
179
|
+
*
|
|
180
|
+
* `parts` is empty when no contributor declared a `room name` and every
|
|
181
|
+
* contributor's arms failed. In that case `text` carries the place entity's own
|
|
182
|
+
* name, which is D16a's fallback: the entity name appears only when the whole
|
|
183
|
+
* heading would otherwise be empty.
|
|
184
|
+
*/
|
|
185
|
+
export interface LocationHeadingValue {
|
|
186
|
+
/** The heading as the player reads it, already joined by the locale. */
|
|
187
|
+
readonly text: string;
|
|
188
|
+
/** The parts it was realized from, in emission order. Empty on the fallback. */
|
|
189
|
+
readonly parts: ReadonlyArray<HeadingPart>;
|
|
190
|
+
}
|
|
130
191
|
/**
|
|
131
192
|
* Channel update modes (ADR-163 §4).
|
|
132
193
|
*
|
|
@@ -281,6 +342,13 @@ export interface IOChannel<T = unknown> {
|
|
|
281
342
|
*/
|
|
282
343
|
readonly produce: (ctx: ChannelProduceContext) => T | T[] | undefined | null;
|
|
283
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* Where a NEW channel lands in registration order: immediately before
|
|
347
|
+
* the channel with the named id. See `IChannelRegistry.add`.
|
|
348
|
+
*/
|
|
349
|
+
export interface ChannelRegistrationPosition {
|
|
350
|
+
readonly before: string;
|
|
351
|
+
}
|
|
284
352
|
/**
|
|
285
353
|
* Channel registry contract (ADR-163 §7, §14).
|
|
286
354
|
*
|
|
@@ -292,6 +360,16 @@ export interface IOChannel<T = unknown> {
|
|
|
292
360
|
* id replaces the prior definition. This is how stories override
|
|
293
361
|
* standard channels (per §6).
|
|
294
362
|
*
|
|
363
|
+
* Registration order is the order `all()` returns, which is the order
|
|
364
|
+
* the manifest lists channels and the order a client dispatches a turn's
|
|
365
|
+
* payload (ADR-165). A channel that must reach the client before another
|
|
366
|
+
* — a chapter title card ahead of the prose flush, say — passes
|
|
367
|
+
* `position: { before: <id> }` and lands immediately before that id.
|
|
368
|
+
* The position is consulted only when the id is NEW: re-registering an
|
|
369
|
+
* existing id replaces it in place and keeps the place it already has,
|
|
370
|
+
* so last-write-wins and ordering never contradict each other. An
|
|
371
|
+
* unknown `before` id is an error, never a silent append.
|
|
372
|
+
*
|
|
295
373
|
* Implementations live elsewhere:
|
|
296
374
|
*
|
|
297
375
|
* - `@sharpee/stdlib` exports a populated `channelRegistry` instance
|
|
@@ -300,7 +378,7 @@ export interface IOChannel<T = unknown> {
|
|
|
300
378
|
* stories add or override channels.
|
|
301
379
|
*/
|
|
302
380
|
export interface IChannelRegistry {
|
|
303
|
-
add(channel: IOChannel): void;
|
|
381
|
+
add(channel: IOChannel, position?: ChannelRegistrationPosition): void;
|
|
304
382
|
get(id: string): IOChannel | undefined;
|
|
305
383
|
all(): readonly IOChannel[];
|
|
306
384
|
}
|
package/channels/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/channels/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/channels/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY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AAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,2BAA2B,GAAG,IAAI,CAAC;IACtE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IACvC,GAAG,IAAI,SAAS,SAAS,EAAE,CAAC;CAC7B"}
|
package/channels/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/channels/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../work/sharpee/sharpee/packages/if-domain/src/channels/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;AAoGH;;GAEG;AACU,QAAA,wBAAwB,GAAG,kBAAkB,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACU,QAAA,iBAAiB,GAAG;IAC/B,WAAW;IACX,kBAAkB;IAClB,eAAe;IACf,eAAe;IACf,gBAAgB;IAChB,OAAO;IACP,cAAc;CACN,CAAC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @description Language-agnostic interfaces for defining grammar rules
|
|
4
4
|
*/
|
|
5
5
|
import { type IEntity } from '@sharpee/core';
|
|
6
|
+
import type { NounRank } from './rule-order.js';
|
|
6
7
|
/**
|
|
7
8
|
* Slot types for grammar patterns
|
|
8
9
|
* Controls how the parser handles slot matching
|
|
@@ -12,7 +13,7 @@ export declare enum SlotType {
|
|
|
12
13
|
ENTITY = "entity",
|
|
13
14
|
/** Capture raw text without entity resolution (single token) */
|
|
14
15
|
TEXT = "text",
|
|
15
|
-
/** Capture raw text
|
|
16
|
+
/** Capture raw text; the consumer admits every extent to the end of the input and the engine's search chooses (greedy, ADR-386 D1) */
|
|
16
17
|
TEXT_GREEDY = "text_greedy",
|
|
17
18
|
/** Resolve entity but mark as instrument for the action */
|
|
18
19
|
INSTRUMENT = "instrument",
|
|
@@ -69,9 +70,7 @@ export interface ScopeBuilder {
|
|
|
69
70
|
carried(): ScopeBuilder;
|
|
70
71
|
nearby(): ScopeBuilder;
|
|
71
72
|
matching(constraint: PropertyConstraint | FunctionConstraint): ScopeBuilder;
|
|
72
|
-
kind(kind: string): ScopeBuilder;
|
|
73
73
|
orExplicitly(entityIds: string[]): ScopeBuilder;
|
|
74
|
-
orRule(ruleId: string): ScopeBuilder;
|
|
75
74
|
/**
|
|
76
75
|
* Require the entity to have a specific trait
|
|
77
76
|
* @param traitType The trait type constant (e.g., TraitType.PORTABLE)
|
|
@@ -88,7 +87,6 @@ export interface ScopeConstraint {
|
|
|
88
87
|
/** Required trait types the entity must have */
|
|
89
88
|
traitFilters: string[];
|
|
90
89
|
explicitEntities: string[];
|
|
91
|
-
includeRules: string[];
|
|
92
90
|
}
|
|
93
91
|
/**
|
|
94
92
|
* ADR-082: Typed slot value for non-entity slots
|
|
@@ -156,31 +154,30 @@ export interface PatternBuilder {
|
|
|
156
154
|
* @param slot The slot name from the pattern
|
|
157
155
|
*/
|
|
158
156
|
instrument(slot: string): PatternBuilder;
|
|
157
|
+
/**
|
|
158
|
+
* Declare an entity slot's seat (ADR-383 D2), for a line written
|
|
159
|
+
* indirect-first: `define('hand :recipient :item').seat('item', 'direct')`.
|
|
160
|
+
* Undeclared entity slots take the seats left free, in pattern order.
|
|
161
|
+
* @param slot The slot name from the pattern
|
|
162
|
+
* @param seat Where the slot's noun goes in the parsed command
|
|
163
|
+
*/
|
|
164
|
+
seat(slot: string, seat: Seat): PatternBuilder;
|
|
159
165
|
/**
|
|
160
166
|
* Map this pattern to an action
|
|
161
167
|
* @param action The action identifier
|
|
162
168
|
*/
|
|
163
169
|
mapsTo(action: string): PatternBuilder;
|
|
164
|
-
/**
|
|
165
|
-
* Add semantic mappings for verbs
|
|
166
|
-
* @param verbs Map of verb text to semantic properties
|
|
167
|
-
*/
|
|
168
|
-
withSemanticVerbs(verbs: Record<string, Partial<SemanticProperties>>): PatternBuilder;
|
|
169
|
-
/**
|
|
170
|
-
* Add semantic mappings for prepositions
|
|
171
|
-
* @param prepositions Map of preposition text to spatial relations
|
|
172
|
-
*/
|
|
173
|
-
withSemanticPrepositions(prepositions: Record<string, string>): PatternBuilder;
|
|
174
|
-
/**
|
|
175
|
-
* Add semantic mappings for directions
|
|
176
|
-
* @param directions Map of direction text to normalized directions
|
|
177
|
-
*/
|
|
178
|
-
withSemanticDirections(directions: Record<string, string>): PatternBuilder;
|
|
179
170
|
/**
|
|
180
171
|
* Set default semantic properties
|
|
181
172
|
* @param defaults Default semantic properties
|
|
182
173
|
*/
|
|
183
174
|
withDefaultSemantics(defaults: Partial<SemanticProperties>): PatternBuilder;
|
|
175
|
+
/**
|
|
176
|
+
* Gate this rule on the live world (ADR-378 D5): skipped while the
|
|
177
|
+
* predicate answers false, as though the rule did not exist.
|
|
178
|
+
* @param predicate Read against the GrammarContext at match time
|
|
179
|
+
*/
|
|
180
|
+
when(predicate: GrammarGate): PatternBuilder;
|
|
184
181
|
/**
|
|
185
182
|
* Mark a slot as a number (integer)
|
|
186
183
|
* Matches digits (1, 29, 100) or words (one, twenty)
|
|
@@ -273,21 +270,15 @@ export interface GrammarBuilder {
|
|
|
273
270
|
*/
|
|
274
271
|
define(pattern: string): PatternBuilder;
|
|
275
272
|
/**
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
* @
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* .forAction('if.action.pushing')
|
|
284
|
-
* .verbs(['push', 'press', 'shove', 'move'])
|
|
285
|
-
* .pattern(':target')
|
|
286
|
-
* .where('target', scope => scope.touchable())
|
|
287
|
-
* .build();
|
|
288
|
-
* ```
|
|
273
|
+
* Register one rule from structured parts (ADR-382 D2), at this
|
|
274
|
+
* builder's tier. The Chord loader's and the generated standard
|
|
275
|
+
* grammar's entry: no text is parsed.
|
|
276
|
+
* @param spec The rule's action, parts, display text and per-slot configuration
|
|
277
|
+
* @throws PatternSyntaxError when the parts are malformed; Error when a
|
|
278
|
+
* slot configuration names a slot the parts lack, or types a greedy slot
|
|
279
|
+
* as anything but TEXT_GREEDY
|
|
289
280
|
*/
|
|
290
|
-
|
|
281
|
+
rule(spec: GrammarRuleSpec): void;
|
|
291
282
|
/**
|
|
292
283
|
* Get all defined rules
|
|
293
284
|
*/
|
|
@@ -297,104 +288,21 @@ export interface GrammarBuilder {
|
|
|
297
288
|
*/
|
|
298
289
|
clear(): void;
|
|
299
290
|
/**
|
|
300
|
-
* ADR-270 D3: remove registered rules by shape — (action id,
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
291
|
+
* ADR-270 D3: remove registered rules by shape — (action id, shape,
|
|
292
|
+
* tier), the shape test supplied by the caller over each rule (ADR-382 D6;
|
|
293
|
+
* Chord's is `samePatternShape` on `rule.parts`). Diagnostic-free:
|
|
294
|
+
* returns the count removed (0 = no rule matched); the caller owns any
|
|
295
|
+
* miss diagnostic. `tier` defaults to 'standard' — the alteration model
|
|
296
|
+
* removes platform rules, never story rules, unless explicitly asked.
|
|
305
297
|
*/
|
|
306
|
-
removeRules(action: string,
|
|
298
|
+
removeRules(action: string, shapeMatches: (rule: GrammarRule) => boolean, tier?: GrammarTier): number;
|
|
307
299
|
}
|
|
308
300
|
/**
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
* Define verb aliases for this action
|
|
315
|
-
* Each verb will generate a separate pattern
|
|
316
|
-
* @param verbs Array of verb strings (e.g., ['push', 'press', 'shove'])
|
|
317
|
-
*/
|
|
318
|
-
verbs(verbs: string[]): ActionGrammarBuilder;
|
|
319
|
-
/**
|
|
320
|
-
* Define a pattern template (without verb)
|
|
321
|
-
* Will be combined with each verb to create full patterns
|
|
322
|
-
* @param pattern Pattern template (e.g., ':target' becomes 'push :target', 'press :target', etc.)
|
|
323
|
-
*/
|
|
324
|
-
pattern(pattern: string): ActionGrammarBuilder;
|
|
325
|
-
/**
|
|
326
|
-
* Define multiple pattern templates
|
|
327
|
-
* Each pattern will be combined with each verb
|
|
328
|
-
* @param patterns Array of pattern templates
|
|
329
|
-
*
|
|
330
|
-
* @example
|
|
331
|
-
* ```typescript
|
|
332
|
-
* grammar
|
|
333
|
-
* .forAction('if.action.pushing')
|
|
334
|
-
* .verbs(['push', 'press'])
|
|
335
|
-
* .patterns([':target', ':target :direction'])
|
|
336
|
-
* .build();
|
|
337
|
-
* // Generates: push :target, press :target, push :target :direction, press :target :direction
|
|
338
|
-
* ```
|
|
339
|
-
*/
|
|
340
|
-
patterns(patterns: string[]): ActionGrammarBuilder;
|
|
341
|
-
/**
|
|
342
|
-
* ADR-271 D3: Define a complete pattern line, verb included
|
|
343
|
-
* (e.g. 'pet :animal'). Emitted as its own rule with the action's shared
|
|
344
|
-
* configuration applied — NOT crossed with verbs(). Slot-scoped
|
|
345
|
-
* configuration (.where(), slotType()) attaches only to lines that carry
|
|
346
|
-
* the slot. This is the Chord compiler's emission path, where grammar
|
|
347
|
-
* lines arrive whole rather than as verb + template.
|
|
348
|
-
* @param pattern Complete pattern line including its verb (non-empty)
|
|
349
|
-
*/
|
|
350
|
-
fullPattern(pattern: string): ActionGrammarBuilder;
|
|
351
|
-
/**
|
|
352
|
-
* Define direction patterns with aliases
|
|
353
|
-
* Creates standalone direction patterns (no verb prefix)
|
|
354
|
-
* @param directionMap Map of canonical direction to aliases
|
|
355
|
-
*
|
|
356
|
-
* @example
|
|
357
|
-
* ```typescript
|
|
358
|
-
* grammar
|
|
359
|
-
* .forAction('if.action.going')
|
|
360
|
-
* .directions({
|
|
361
|
-
* 'north': ['north', 'n'],
|
|
362
|
-
* 'south': ['south', 's'],
|
|
363
|
-
* })
|
|
364
|
-
* .build();
|
|
365
|
-
* // Generates patterns 'north', 'n', 'south', 's' each with direction semantics
|
|
366
|
-
* ```
|
|
367
|
-
*/
|
|
368
|
-
directions(directionMap: Record<string, string[]>): ActionGrammarBuilder;
|
|
369
|
-
/**
|
|
370
|
-
* Define a scope constraint for a slot (applies to all generated patterns).
|
|
371
|
-
* `.where()` scope constraints are the one parse-time gating mechanism;
|
|
372
|
-
* trait-based refusal lives in each action's validate().
|
|
373
|
-
* @param slot The slot name from the pattern
|
|
374
|
-
* @param constraint A scope-builder callback, e.g. `scope => scope.touchable()`
|
|
375
|
-
*/
|
|
376
|
-
where(slot: string, constraint: ScopeConstraintBuilder): ActionGrammarBuilder;
|
|
377
|
-
/**
|
|
378
|
-
* Set default semantic properties for all generated patterns
|
|
379
|
-
* @param defaults Default semantic properties
|
|
380
|
-
*/
|
|
381
|
-
withDefaultSemantics(defaults: Partial<SemanticProperties>): ActionGrammarBuilder;
|
|
382
|
-
/**
|
|
383
|
-
* Mark a slot as a specific type (applies to all generated patterns)
|
|
384
|
-
* @param slot The slot name
|
|
385
|
-
* @param slotType The slot type
|
|
386
|
-
*/
|
|
387
|
-
slotType(slot: string, slotType: SlotType): ActionGrammarBuilder;
|
|
388
|
-
/**
|
|
389
|
-
* Build all patterns and add them to the grammar
|
|
390
|
-
* Generates patterns from: verbs × patterns combinations
|
|
391
|
-
*/
|
|
392
|
-
build(): void;
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Grammar tier (ADR-268 D2): which layer defined the rule. Story-tier rules
|
|
396
|
-
* outrank standard-tier rules unconditionally (before specificity is
|
|
397
|
-
* consulted) — "story overrides platform". Set at the registration entry
|
|
301
|
+
* Grammar tier: which layer defined the rule. At equal literal specificity a
|
|
302
|
+
* story-tier rule outranks a standard-tier one; a more specific standard rule
|
|
303
|
+
* still wins, and a story replaces one by removing it (ADR-384 D2,
|
|
304
|
+
* `compareGrammarRank`; a reading with an item naming nothing ranks below
|
|
305
|
+
* both, ADR-386 D5). Set at the registration entry
|
|
398
306
|
* point: the standard grammar's builder registers 'standard'; the story
|
|
399
307
|
* grammar surface (getStoryGrammar()) and the Chord loader register 'story'.
|
|
400
308
|
*/
|
|
@@ -402,17 +310,29 @@ export type GrammarTier = 'standard' | 'story';
|
|
|
402
310
|
/**
|
|
403
311
|
* A compiled grammar rule
|
|
404
312
|
*/
|
|
313
|
+
/**
|
|
314
|
+
* A rule-level gate (ADR-378 D5, GH #317): read against the live world
|
|
315
|
+
* before matching. A rule whose gate answers false is skipped — neither a
|
|
316
|
+
* match nor a failure — so the input parses as though the rule did not
|
|
317
|
+
* exist. Story-tier only in practice: a Chord `define action … while
|
|
318
|
+
* <condition>` head, or a passage's command words gated to the room that
|
|
319
|
+
* declares the passage.
|
|
320
|
+
*/
|
|
321
|
+
export type GrammarGate = (context: GrammarContext) => boolean;
|
|
405
322
|
export interface GrammarRule {
|
|
406
323
|
id: string;
|
|
324
|
+
/** Display text for diagnostics and failure messages; nothing parses it (ADR-382 D2). */
|
|
407
325
|
pattern: string;
|
|
326
|
+
/** The rule's structure — the only source of its words and slots. */
|
|
327
|
+
parts: readonly PatternElement[];
|
|
408
328
|
compiledPattern?: CompiledPattern;
|
|
409
329
|
slots: Map<string, SlotConstraint>;
|
|
410
330
|
action: string;
|
|
411
331
|
/** ADR-268 D2: resolution layer — story outranks standard */
|
|
412
332
|
tier: GrammarTier;
|
|
413
|
-
|
|
333
|
+
/** ADR-378 D5: skip the rule while this answers false (absent = always on) */
|
|
334
|
+
when?: GrammarGate;
|
|
414
335
|
defaultSemantics?: Partial<SemanticProperties>;
|
|
415
|
-
experimentalConfidence?: number;
|
|
416
336
|
}
|
|
417
337
|
/**
|
|
418
338
|
* Semantic properties that can be derived from grammar
|
|
@@ -422,8 +342,16 @@ export interface SemanticProperties {
|
|
|
422
342
|
manner?: 'normal' | 'careful' | 'careless' | 'forceful' | 'stealthy' | 'quick';
|
|
423
343
|
/** Spatial relationship for placement actions */
|
|
424
344
|
spatialRelation?: 'in' | 'on' | 'under' | 'behind' | 'beside' | 'above' | 'below';
|
|
425
|
-
/**
|
|
426
|
-
|
|
345
|
+
/**
|
|
346
|
+
* The direction a movement rule carries, as the action's own vocabulary
|
|
347
|
+
* names it: a compass word (`world-model`'s `DirectionType`, `in` and
|
|
348
|
+
* `out` included), a passage key (`passage:<name>`, ADR-378 D1 — a way
|
|
349
|
+
* answered by a custom command rather than a compass word), or a ship
|
|
350
|
+
* direction under `use sailing` (`port`, `starboard`, `ahead`, ADR-375).
|
|
351
|
+
* The word is per action, so the contract does not close the set; the
|
|
352
|
+
* consumer that reads it resolves it against the ways it knows.
|
|
353
|
+
*/
|
|
354
|
+
direction?: string;
|
|
427
355
|
/** Whether the preposition was implicit */
|
|
428
356
|
implicitPreposition?: boolean;
|
|
429
357
|
/** Whether a direction was implicit */
|
|
@@ -431,19 +359,6 @@ export interface SemanticProperties {
|
|
|
431
359
|
/** Custom properties for specific actions */
|
|
432
360
|
[key: string]: any;
|
|
433
361
|
}
|
|
434
|
-
/**
|
|
435
|
-
* Mapping from text variations to semantic properties
|
|
436
|
-
*/
|
|
437
|
-
export interface SemanticMapping {
|
|
438
|
-
/** Map verb variations to properties */
|
|
439
|
-
verbs?: Record<string, Partial<SemanticProperties>>;
|
|
440
|
-
/** Map preposition variations to spatial relations */
|
|
441
|
-
prepositions?: Record<string, string>;
|
|
442
|
-
/** Map direction variations to normalized directions */
|
|
443
|
-
directions?: Record<string, string>;
|
|
444
|
-
/** Function to compute dynamic semantics based on match */
|
|
445
|
-
compute?: (match: any) => Partial<SemanticProperties>;
|
|
446
|
-
}
|
|
447
362
|
/**
|
|
448
363
|
* Slot constraint definition
|
|
449
364
|
*/
|
|
@@ -454,6 +369,8 @@ export interface SlotConstraint {
|
|
|
454
369
|
slotType?: SlotType;
|
|
455
370
|
/** For VOCABULARY slots: the category name to match against */
|
|
456
371
|
vocabularyCategory?: string;
|
|
372
|
+
/** Declared seat of an entity slot (ADR-383 D1) */
|
|
373
|
+
seat?: Seat;
|
|
457
374
|
}
|
|
458
375
|
/**
|
|
459
376
|
* Token in a pattern
|
|
@@ -467,14 +384,84 @@ export interface PatternToken {
|
|
|
467
384
|
greedy?: boolean;
|
|
468
385
|
vocabularyCategory?: string;
|
|
469
386
|
}
|
|
387
|
+
/**
|
|
388
|
+
* One element of a grammar pattern, as a rule is registered (ADR-382 D1).
|
|
389
|
+
* A rule crosses into the engine as these parts, never as text to re-split:
|
|
390
|
+
* a word, an alternation of words, or a named slot, each optionally
|
|
391
|
+
* optional. No element fixes where a slot ends: each slot admits every
|
|
392
|
+
* extent it can read and the engine searches them (ADR-386 D1, D2); a
|
|
393
|
+
* greedy slot is a text slot whose extents run to the end of the input.
|
|
394
|
+
*/
|
|
395
|
+
export type PatternElement = {
|
|
396
|
+
kind: 'word';
|
|
397
|
+
word: string;
|
|
398
|
+
optional?: boolean;
|
|
399
|
+
} | {
|
|
400
|
+
kind: 'alt';
|
|
401
|
+
words: readonly string[];
|
|
402
|
+
optional?: boolean;
|
|
403
|
+
} | {
|
|
404
|
+
kind: 'slot';
|
|
405
|
+
name: string;
|
|
406
|
+
optional?: boolean;
|
|
407
|
+
greedy?: boolean;
|
|
408
|
+
};
|
|
409
|
+
/**
|
|
410
|
+
* Where an entity slot's noun goes in the parsed command (ADR-383 D1).
|
|
411
|
+
* Every other slot type is seated by its type (instrument, topic, text,
|
|
412
|
+
* vocabulary, manner, direction).
|
|
413
|
+
*/
|
|
414
|
+
export type Seat = 'direct' | 'indirect';
|
|
415
|
+
/**
|
|
416
|
+
* Per-slot configuration on a rule spec: the slot's type, its scope
|
|
417
|
+
* constraints and, for an entity slot, its declared seat. Keyed by slot
|
|
418
|
+
* name; a name no part carries is a build error.
|
|
419
|
+
*/
|
|
420
|
+
export interface GrammarRuleSlotSpec {
|
|
421
|
+
type?: SlotType;
|
|
422
|
+
constraints?: readonly ScopeConstraintBuilder[];
|
|
423
|
+
/** For VOCABULARY slots: the category name to match against */
|
|
424
|
+
vocabularyCategory?: string;
|
|
425
|
+
/** The entity slot's seat; undeclared seats take the positional default (ADR-383 D2). */
|
|
426
|
+
seat?: Seat;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* A grammar rule, as data (ADR-382 D2) — what `GrammarBuilder.rule()` takes.
|
|
430
|
+
*/
|
|
431
|
+
export interface GrammarRuleSpec {
|
|
432
|
+
action: string;
|
|
433
|
+
parts: readonly PatternElement[];
|
|
434
|
+
/** How the rule displays in diagnostics and failure messages; never parsed. */
|
|
435
|
+
pattern: string;
|
|
436
|
+
defaults?: Partial<SemanticProperties>;
|
|
437
|
+
slots?: Readonly<Record<string, GrammarRuleSlotSpec>>;
|
|
438
|
+
when?: GrammarGate;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* One slot of a compiled pattern (ADR-382 D4): the single source of a
|
|
442
|
+
* slot's name, position, optionality, greediness and resolved type.
|
|
443
|
+
*/
|
|
444
|
+
export interface CompiledSlot {
|
|
445
|
+
name: string;
|
|
446
|
+
/** Index of the slot's token in `CompiledPattern.tokens`. */
|
|
447
|
+
tokenIndex: number;
|
|
448
|
+
optional: boolean;
|
|
449
|
+
greedy: boolean;
|
|
450
|
+
/** The configured type, `TEXT_GREEDY` for a greedy slot, else `ENTITY`. */
|
|
451
|
+
slotType: SlotType;
|
|
452
|
+
/** Set on every ENTITY slot at build (ADR-383 D1, D2); absent on every other slot type. */
|
|
453
|
+
seat?: Seat;
|
|
454
|
+
}
|
|
470
455
|
/**
|
|
471
456
|
* Compiled pattern for efficient matching
|
|
472
457
|
*/
|
|
473
458
|
export interface CompiledPattern {
|
|
474
459
|
tokens: PatternToken[];
|
|
475
|
-
|
|
460
|
+
/** Every slot, in pattern order. */
|
|
461
|
+
slots: CompiledSlot[];
|
|
462
|
+
/** The same slot records, by name. */
|
|
463
|
+
slotsByName: ReadonlyMap<string, CompiledSlot>;
|
|
476
464
|
minTokens: number;
|
|
477
|
-
maxTokens: number;
|
|
478
465
|
}
|
|
479
466
|
/**
|
|
480
467
|
* Slot match data with multi-object support
|
|
@@ -483,7 +470,10 @@ export interface SlotMatch {
|
|
|
483
470
|
tokens: number[];
|
|
484
471
|
text: string;
|
|
485
472
|
slotType?: SlotType;
|
|
486
|
-
|
|
473
|
+
articles?: string[];
|
|
474
|
+
determiners?: string[];
|
|
475
|
+
ownedByActor?: boolean;
|
|
476
|
+
scope?: string[];
|
|
487
477
|
isAll?: boolean;
|
|
488
478
|
isList?: boolean;
|
|
489
479
|
items?: SlotMatch[];
|
|
@@ -500,22 +490,38 @@ export interface SlotMatch {
|
|
|
500
490
|
*/
|
|
501
491
|
export interface PatternMatch {
|
|
502
492
|
rule: GrammarRule;
|
|
503
|
-
confidence: number;
|
|
504
493
|
slots: Map<string, SlotMatch>;
|
|
505
494
|
consumed: number;
|
|
506
495
|
/**
|
|
507
496
|
* Literal specificity (ADR-231 D2b): count of input words consumed by the
|
|
508
497
|
* pattern's literal/alternate tokens (as opposed to slots). A rule whose
|
|
509
498
|
* literals consume words outranks a rule whose unconstrained slot swallows
|
|
510
|
-
* the same words. Resolution order (ADR-
|
|
511
|
-
*
|
|
499
|
+
* the same words. Resolution order (ADR-386 D5, ADR-384 D2,
|
|
500
|
+
* `compareGrammarRank`): items naming nothing asc → literalSpecificity
|
|
501
|
+
* desc → tier (story over standard) → definition order → names desc →
|
|
502
|
+
* exact names desc.
|
|
512
503
|
*/
|
|
513
504
|
literalSpecificity?: number;
|
|
505
|
+
/**
|
|
506
|
+
* How the reading's entity items resolve through the one noun matcher
|
|
507
|
+
* (ADR-386 D4): items naming nothing, distinct entities named, items named
|
|
508
|
+
* exactly. The engine computes it for every complete reading and ranks by
|
|
509
|
+
* it; the parser compares it with the best failure's (D5).
|
|
510
|
+
*/
|
|
511
|
+
nounRank: NounRank;
|
|
514
512
|
semantics?: SemanticProperties;
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
513
|
+
/**
|
|
514
|
+
* Every literal (word or alternation) element, in pattern order, with the
|
|
515
|
+
* input tokens it consumed (ADR-383 D7) — where the verb phrase and the
|
|
516
|
+
* preposition are read from.
|
|
517
|
+
*/
|
|
518
|
+
literals: readonly MatchedElement[];
|
|
519
|
+
}
|
|
520
|
+
/** One pattern element as it matched the input (ADR-383 D7). */
|
|
521
|
+
export interface MatchedElement {
|
|
522
|
+
/** Index of the element in `rule.compiledPattern.tokens`. */
|
|
523
|
+
tokenIndex: number;
|
|
524
|
+
/** Input token indices it consumed; empty for a skipped optional or article. */
|
|
525
|
+
inputTokens: readonly number[];
|
|
520
526
|
}
|
|
521
527
|
//# sourceMappingURL=grammar-builder.d.ts.map
|