@sharpee/ide-protocol 1.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/guards.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Type guards for the IDE introspection manifest wire types.
3
+ *
4
+ * Purpose: validate untrusted manifest JSON at the decode boundary (the IDE, and
5
+ * the bridge/CLI round-trip tests) before it is treated as a {@link ProjectManifest}.
6
+ * Public interface: isProjectManifest, isEntityNode, isEntityCategory, isSourceRef.
7
+ * Owner context: @sharpee/ide-protocol (ADR-184). Pure predicates, no runtime deps.
8
+ */
9
+ import type { ProjectManifest, EntityNode, EntityCategory, SourceRef } from './types';
10
+ /** Narrow a value to a valid {@link EntityCategory}. */
11
+ export declare function isEntityCategory(value: unknown): value is EntityCategory;
12
+ /** Narrow a value to a valid {@link SourceRef}. */
13
+ export declare function isSourceRef(value: unknown): value is SourceRef;
14
+ /** Narrow a value to a valid {@link EntityNode}. `source`, when present, must be a valid SourceRef. */
15
+ export declare function isEntityNode(value: unknown): value is EntityNode;
16
+ /**
17
+ * Narrow a value to a valid {@link ProjectManifest}. Requires the schema version
18
+ * to match this package's {@link SCHEMA_VERSION} and every entity to be well-formed.
19
+ */
20
+ export declare function isProjectManifest(value: unknown): value is ProjectManifest;
21
+ //# sourceMappingURL=guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../../repos/sharpee/packages/ide-protocol/src/guards.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,cAAc,EACd,SAAS,EACV,MAAM,SAAS,CAAC;AAcjB,wDAAwD;AACxD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAED,mDAAmD;AACnD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAO9D;AAED,uGAAuG;AACvG,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAQhE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAO1E"}
package/guards.js ADDED
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /**
3
+ * Type guards for the IDE introspection manifest wire types.
4
+ *
5
+ * Purpose: validate untrusted manifest JSON at the decode boundary (the IDE, and
6
+ * the bridge/CLI round-trip tests) before it is treated as a {@link ProjectManifest}.
7
+ * Public interface: isProjectManifest, isEntityNode, isEntityCategory, isSourceRef.
8
+ * Owner context: @sharpee/ide-protocol (ADR-184). Pure predicates, no runtime deps.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.isEntityCategory = isEntityCategory;
12
+ exports.isSourceRef = isSourceRef;
13
+ exports.isEntityNode = isEntityNode;
14
+ exports.isProjectManifest = isProjectManifest;
15
+ const types_1 = require("./types");
16
+ const CATEGORIES = new Set([
17
+ 'room',
18
+ 'object',
19
+ 'npc',
20
+ 'region',
21
+ ]);
22
+ function isObject(v) {
23
+ return typeof v === 'object' && v !== null;
24
+ }
25
+ /** Narrow a value to a valid {@link EntityCategory}. */
26
+ function isEntityCategory(value) {
27
+ return typeof value === 'string' && CATEGORIES.has(value);
28
+ }
29
+ /** Narrow a value to a valid {@link SourceRef}. */
30
+ function isSourceRef(value) {
31
+ if (!isObject(value))
32
+ return false;
33
+ return (typeof value.file === 'string' &&
34
+ typeof value.line === 'number' &&
35
+ (value.resolution === 'exact' || value.resolution === 'scope'));
36
+ }
37
+ /** Narrow a value to a valid {@link EntityNode}. `source`, when present, must be a valid SourceRef. */
38
+ function isEntityNode(value) {
39
+ if (!isObject(value))
40
+ return false;
41
+ if (typeof value.id !== 'string')
42
+ return false;
43
+ if (typeof value.displayName !== 'string')
44
+ return false;
45
+ if (!isEntityCategory(value.category))
46
+ return false;
47
+ if (!isObject(value.traits))
48
+ return false;
49
+ if ('source' in value && value.source !== undefined && !isSourceRef(value.source))
50
+ return false;
51
+ return true;
52
+ }
53
+ /**
54
+ * Narrow a value to a valid {@link ProjectManifest}. Requires the schema version
55
+ * to match this package's {@link SCHEMA_VERSION} and every entity to be well-formed.
56
+ */
57
+ function isProjectManifest(value) {
58
+ if (!isObject(value))
59
+ return false;
60
+ if (value.schemaVersion !== types_1.SCHEMA_VERSION)
61
+ return false;
62
+ if (typeof value.story !== 'string')
63
+ return false;
64
+ if (value.generatedFrom !== 'cli' && value.generatedFrom !== 'bridge')
65
+ return false;
66
+ if (!Array.isArray(value.entities))
67
+ return false;
68
+ return value.entities.every(isEntityNode);
69
+ }
70
+ //# sourceMappingURL=guards.js.map
package/guards.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../repos/sharpee/packages/ide-protocol/src/guards.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAsBH,4CAEC;AAGD,kCAOC;AAGD,oCAQC;AAMD,8CAOC;AAlDD,mCAAyC;AAEzC,MAAM,UAAU,GAAgC,IAAI,GAAG,CAAiB;IACtE,MAAM;IACN,QAAQ;IACR,KAAK;IACL,QAAQ;CACT,CAAC,CAAC;AAEH,SAAS,QAAQ,CAAC,CAAU;IAC1B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC;AAC7C,CAAC;AAED,wDAAwD;AACxD,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,UAAU,CAAC,GAAG,CAAC,KAAuB,CAAC,CAAC;AAC9E,CAAC;AAED,mDAAmD;AACnD,SAAgB,WAAW,CAAC,KAAc;IACxC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACnC,OAAO,CACL,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,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KAAK,CAAC,YAAY,CAAC,CAAC;AAC5C,CAAC"}
package/index.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @sharpee/ide-protocol
3
+ *
4
+ * Shared wire types for the Sharpee IDE project-introspection manifest. The single
5
+ * source of truth for the contract between the platform's introspection emitters
6
+ * (the `--introspect` CLI and the Play-panel bridge) and the IDE that renders the
7
+ * Sharpee-aware project tree. Types only — no runtime dependencies — so both the
8
+ * Node emitter and the browser bridge import it cleanly (DEVARCH 8b).
9
+ *
10
+ * @packageDocumentation
11
+ * @see ADR-184: IDE project introspection via runtime world model
12
+ */
13
+ export type { ProjectManifest, EntityNode, EntityCategory, SourceRef, TraitSummary, } from './types.js';
14
+ export { SCHEMA_VERSION } from './types.js';
15
+ export { isProjectManifest, isEntityNode, isEntityCategory, isSourceRef, } from './guards.js';
16
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../repos/sharpee/packages/ide-protocol/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EACV,eAAe,EACf,UAAU,EACV,cAAc,EACd,SAAS,EACT,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,WAAW,GACZ,MAAM,aAAa,CAAC"}
package/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /**
3
+ * @sharpee/ide-protocol
4
+ *
5
+ * Shared wire types for the Sharpee IDE project-introspection manifest. The single
6
+ * source of truth for the contract between the platform's introspection emitters
7
+ * (the `--introspect` CLI and the Play-panel bridge) and the IDE that renders the
8
+ * Sharpee-aware project tree. Types only — no runtime dependencies — so both the
9
+ * Node emitter and the browser bridge import it cleanly (DEVARCH 8b).
10
+ *
11
+ * @packageDocumentation
12
+ * @see ADR-184: IDE project introspection via runtime world model
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.isSourceRef = exports.isEntityCategory = exports.isEntityNode = exports.isProjectManifest = exports.SCHEMA_VERSION = void 0;
16
+ var types_js_1 = require("./types.js");
17
+ Object.defineProperty(exports, "SCHEMA_VERSION", { enumerable: true, get: function () { return types_js_1.SCHEMA_VERSION; } });
18
+ var guards_js_1 = require("./guards.js");
19
+ Object.defineProperty(exports, "isProjectManifest", { enumerable: true, get: function () { return guards_js_1.isProjectManifest; } });
20
+ Object.defineProperty(exports, "isEntityNode", { enumerable: true, get: function () { return guards_js_1.isEntityNode; } });
21
+ Object.defineProperty(exports, "isEntityCategory", { enumerable: true, get: function () { return guards_js_1.isEntityCategory; } });
22
+ Object.defineProperty(exports, "isSourceRef", { enumerable: true, get: function () { return guards_js_1.isSourceRef; } });
23
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../repos/sharpee/packages/ide-protocol/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAUH,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AAEvB,yCAKqB;AAJnB,8GAAA,iBAAiB,OAAA;AACjB,yGAAA,YAAY,OAAA;AACZ,6GAAA,gBAAgB,OAAA;AAChB,wGAAA,WAAW,OAAA"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@sharpee/ide-protocol",
3
+ "version": "1.0.0",
4
+ "description": "Wire types for the Sharpee IDE project-introspection manifest (ADR-184)",
5
+ "main": "./index.js",
6
+ "types": "./index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./index.d.ts",
10
+ "require": "./index.js",
11
+ "default": "./index.js"
12
+ }
13
+ },
14
+ "keywords": [
15
+ "interactive-fiction",
16
+ "if",
17
+ "sharpee",
18
+ "ide",
19
+ "introspection",
20
+ "protocol"
21
+ ],
22
+ "author": "Sharpee Team",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/ChicagoDave/sharpee.git",
27
+ "directory": "packages/ide-protocol"
28
+ },
29
+ "homepage": "https://github.com/ChicagoDave/sharpee#readme",
30
+ "bugs": {
31
+ "url": "https://github.com/ChicagoDave/sharpee/issues"
32
+ },
33
+ "engines": {
34
+ "node": ">=18.0.0"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ }
39
+ }
package/types.d.ts ADDED
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Wire types for the Sharpee IDE project-introspection manifest.
3
+ *
4
+ * Purpose: the single, shared definition of the manifest the platform emits
5
+ * (`--introspect` on the platform-bundle CLI, and the Play-panel WKWebView
6
+ * bridge) and the IDE consumes. This is the wire contract; per DEVARCH 8b
7
+ * it lives once and is imported by every same-language consumer.
8
+ * Public interface: ProjectManifest, EntityNode, EntityCategory, SourceRef,
9
+ * TraitSummary, SCHEMA_VERSION.
10
+ * Owner context: @sharpee/ide-protocol (ADR-184). Types only — NO runtime-specific
11
+ * types (no Buffer / fs / DOM), so both the Node emitter and the browser bridge
12
+ * import it cleanly. The Swift IDE mirrors these shapes as Codable structs.
13
+ *
14
+ * @packageDocumentation
15
+ * @see ADR-184: IDE project introspection via runtime world model
16
+ */
17
+ /** Current manifest schema version. Bump on any breaking shape change. */
18
+ export declare const SCHEMA_VERSION: 1;
19
+ /**
20
+ * The Sharpee-aware project tree, produced by running the story's world
21
+ * construction and projecting the resulting entities. A flat entity list plus a
22
+ * build-status header; the IDE buckets into categories client-side from
23
+ * {@link EntityNode.category}.
24
+ */
25
+ export interface ProjectManifest {
26
+ /** Schema version; equals {@link SCHEMA_VERSION} for manifests this package emits. */
27
+ schemaVersion: typeof SCHEMA_VERSION;
28
+ /** Story id (from StoryConfig). */
29
+ story: string;
30
+ /** Which path produced this manifest. */
31
+ generatedFrom: 'cli' | 'bridge';
32
+ /** Every introspected entity, in world-enumeration order. */
33
+ entities: EntityNode[];
34
+ }
35
+ /** Top-level project-tree categories. Doors/exits surface under a room's `exits`. */
36
+ export type EntityCategory = 'room' | 'object' | 'npc' | 'region';
37
+ /** One introspected world entity. */
38
+ export interface EntityNode {
39
+ /** World entity id. */
40
+ id: string;
41
+ /** IdentityTrait name (authored text) — the tree label. */
42
+ displayName: string;
43
+ /** Derived from the runtime trait set (see ADR-184 derivation table). */
44
+ category: EntityCategory;
45
+ /** Trait-type → the IDE-relevant fields (a projection, not the full trait). */
46
+ traits: TraitSummary;
47
+ /** file:line from the tree-sitter name index; absent when unresolved. */
48
+ source?: SourceRef;
49
+ }
50
+ /** A resolved source location for an entity's creation site. */
51
+ export interface SourceRef {
52
+ /** Workspace-relative path. */
53
+ file: string;
54
+ /** 1-based line of the `createEntity('<name>', …)` site. */
55
+ line: number;
56
+ /** `'scope'` = fell back to the enclosing function (non-unique name). */
57
+ resolution: 'exact' | 'scope';
58
+ }
59
+ /**
60
+ * The fields the IDE renders/lints on, keyed by trait type. Sparse: a key is
61
+ * present only if the entity carries that trait. The index signature keeps the
62
+ * shape forward-compatible — unknown traits pass through without dropping the
63
+ * entity.
64
+ */
65
+ export interface TraitSummary {
66
+ identity?: {
67
+ description?: string;
68
+ };
69
+ /** Exit directions present — drives the "room with no exits" lint. */
70
+ room?: {
71
+ exits: string[];
72
+ };
73
+ /** Co-trait lint inputs (e.g. "lockable without openable"). */
74
+ container?: {
75
+ openable: boolean;
76
+ lockable: boolean;
77
+ };
78
+ [traitType: string]: Record<string, unknown> | undefined;
79
+ }
80
+ //# sourceMappingURL=types.d.ts.map
package/types.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../repos/sharpee/packages/ide-protocol/src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,0EAA0E;AAC1E,eAAO,MAAM,cAAc,EAAG,CAAU,CAAC;AAEzC;;;;;GAKG;AACH,MA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
1
+ "use strict";
2
+ /**
3
+ * Wire types for the Sharpee IDE project-introspection manifest.
4
+ *
5
+ * Purpose: the single, shared definition of the manifest the platform emits
6
+ * (`--introspect` on the platform-bundle CLI, and the Play-panel WKWebView
7
+ * bridge) and the IDE consumes. This is the wire contract; per DEVARCH 8b
8
+ * it lives once and is imported by every same-language consumer.
9
+ * Public interface: ProjectManifest, EntityNode, EntityCategory, SourceRef,
10
+ * TraitSummary, SCHEMA_VERSION.
11
+ * Owner context: @sharpee/ide-protocol (ADR-184). Types only — NO runtime-specific
12
+ * types (no Buffer / fs / DOM), so both the Node emitter and the browser bridge
13
+ * import it cleanly. The Swift IDE mirrors these shapes as Codable structs.
14
+ *
15
+ * @packageDocumentation
16
+ * @see ADR-184: IDE project introspection via runtime world model
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.SCHEMA_VERSION = void 0;
20
+ /** Current manifest schema version. Bump on any breaking shape change. */
21
+ exports.SCHEMA_VERSION = 1;
22
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../repos/sharpee/packages/ide-protocol/src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,0EAA0E;AAC7D,QAAA,cAAc,GAAG,CAAU,CAAC"}