@sharpee/sharpee 0.9.61-beta

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 David Cornelson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # @sharpee/sharpee
2
+
3
+ A modern TypeScript interactive fiction engine for creating text adventures and parser-based games.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@sharpee/sharpee/beta.svg)](https://www.npmjs.com/package/@sharpee/sharpee)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @sharpee/sharpee
12
+ ```
13
+
14
+ ## Features
15
+
16
+ - **Event-Driven Architecture** - Immutable events for all state changes
17
+ - **Rich World Model** - Entities with traits, behaviors, and relationships
18
+ - **Natural Language Parser** - Understands complex player commands
19
+ - **Extensible** - Add custom actions, behaviors, and game mechanics
20
+ - **Type-Safe** - Full TypeScript with strict typing
21
+
22
+ ## Quick Start
23
+
24
+ ```typescript
25
+ import {
26
+ GameEngine,
27
+ WorldModel,
28
+ EnglishParser,
29
+ EnglishLanguageProvider,
30
+ TextService
31
+ } from '@sharpee/sharpee';
32
+
33
+ // Define your story
34
+ const story = {
35
+ metadata: {
36
+ title: 'My Adventure',
37
+ author: 'Your Name',
38
+ version: '1.0.0'
39
+ },
40
+
41
+ setup(world: WorldModel) {
42
+ // Create a room
43
+ const room = world.createEntity('room', {
44
+ id: 'start-room',
45
+ name: 'Starting Room',
46
+ description: 'You are in a small room with stone walls.'
47
+ });
48
+
49
+ // Set as starting location
50
+ world.setStartingLocation(room);
51
+ }
52
+ };
53
+
54
+ // Initialize the engine
55
+ const engine = new GameEngine({
56
+ story,
57
+ parser: new EnglishParser(),
58
+ languageProvider: new EnglishLanguageProvider(),
59
+ textService: new TextService()
60
+ });
61
+
62
+ // Start the game
63
+ const startEvents = engine.start();
64
+
65
+ // Process player commands
66
+ const events = engine.processCommand('look');
67
+ ```
68
+
69
+ ## What's Included
70
+
71
+ This package re-exports the core Sharpee packages:
72
+
73
+ | Export | Description |
74
+ |--------|-------------|
75
+ | `GameEngine` | Main game runtime |
76
+ | `WorldModel`, `IFEntity` | Entity and world management |
77
+ | `EnglishParser` | Natural language command parser |
78
+ | `EnglishLanguageProvider` | English text generation |
79
+ | `TextService` | Text formatting and output |
80
+ | `QueryManager` | Player input queries (yes/no, menus) |
81
+
82
+ ## Standard Actions
83
+
84
+ The engine includes 40+ standard IF actions out of the box:
85
+
86
+ - **Movement**: go, enter, exit
87
+ - **Manipulation**: take, drop, put, insert, remove
88
+ - **Interaction**: open, close, lock, unlock, push, pull
89
+ - **Observation**: look, examine, search, read
90
+ - **Communication**: talk, give, show
91
+ - **Meta**: save, restore, quit, inventory, score
92
+
93
+ ## Documentation
94
+
95
+ - [GitHub Repository](https://github.com/ChicagoDave/sharpee)
96
+ - [Author's Guide](https://github.com/ChicagoDave/sharpee/blob/main/docs/getting-started/authors/README.md)
97
+ - [API Reference](https://github.com/ChicagoDave/sharpee/blob/main/docs/api/README.md)
98
+ - [Architecture Decisions](https://github.com/ChicagoDave/sharpee/blob/main/docs/architecture/adrs/)
99
+
100
+ ## Example Stories
101
+
102
+ See the [stories directory](https://github.com/ChicagoDave/sharpee/tree/main/stories) for complete examples:
103
+
104
+ - **Cloak of Darkness** - The classic IF benchmark
105
+ - **Dungeo** - Full implementation of Mainframe Zork (~190 rooms)
106
+
107
+ ## Requirements
108
+
109
+ - Node.js 18+
110
+ - TypeScript 5.2+ (for development)
111
+
112
+ ## License
113
+
114
+ MIT
@@ -0,0 +1,10 @@
1
+ /**
2
+ * CLI: sharpee build-browser
3
+ *
4
+ * Bundles a Sharpee story for web browser deployment.
5
+ */
6
+ /**
7
+ * Run the build-browser command
8
+ */
9
+ export declare function runBuildBrowserCommand(args: string[]): Promise<void>;
10
+ //# sourceMappingURL=build-browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-browser.d.ts","sourceRoot":"","sources":["../../src/cli/build-browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwDH;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8G1E"}
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ /**
3
+ * CLI: sharpee build-browser
4
+ *
5
+ * Bundles a Sharpee story for web browser deployment.
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.runBuildBrowserCommand = runBuildBrowserCommand;
42
+ const fs = __importStar(require("fs"));
43
+ const path = __importStar(require("path"));
44
+ const child_process_1 = require("child_process");
45
+ /**
46
+ * Read story info from package.json or index.ts
47
+ */
48
+ function getProjectInfo(projectDir) {
49
+ // Try package.json first
50
+ const packagePath = path.join(projectDir, 'package.json');
51
+ if (fs.existsSync(packagePath)) {
52
+ try {
53
+ const pkg = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));
54
+ return {
55
+ storyId: pkg.name || 'my-story',
56
+ storyTitle: pkg.description || pkg.name || 'My Story',
57
+ };
58
+ }
59
+ catch {
60
+ // Fall through
61
+ }
62
+ }
63
+ // Try reading from src/index.ts
64
+ const indexPath = path.join(projectDir, 'src', 'index.ts');
65
+ if (fs.existsSync(indexPath)) {
66
+ const content = fs.readFileSync(indexPath, 'utf-8');
67
+ const idMatch = content.match(/id:\s*['"]([^'"]+)['"]/);
68
+ const titleMatch = content.match(/title:\s*['"]([^'"]+)['"]/);
69
+ if (idMatch || titleMatch) {
70
+ return {
71
+ storyId: idMatch?.[1] || 'my-story',
72
+ storyTitle: titleMatch?.[1] || 'My Story',
73
+ };
74
+ }
75
+ }
76
+ return null;
77
+ }
78
+ /**
79
+ * Process template placeholders
80
+ */
81
+ function processTemplate(content, info) {
82
+ return content
83
+ .replace(/\{\{STORY_ID\}\}/g, info.storyId)
84
+ .replace(/\{\{STORY_TITLE\}\}/g, info.storyTitle);
85
+ }
86
+ /**
87
+ * Run the build-browser command
88
+ */
89
+ async function runBuildBrowserCommand(args) {
90
+ // Check for help
91
+ if (args.includes('--help') || args.includes('-h')) {
92
+ showHelp();
93
+ return;
94
+ }
95
+ const projectDir = process.cwd();
96
+ const minify = !args.includes('--no-minify');
97
+ const sourcemap = !args.includes('--no-sourcemap');
98
+ console.log('\n🔨 Building browser bundle\n');
99
+ // Check if this is a Sharpee project
100
+ const info = getProjectInfo(projectDir);
101
+ if (!info) {
102
+ console.error('Error: This does not appear to be a Sharpee project.');
103
+ console.error('Make sure you have a package.json or src/index.ts with story config.');
104
+ process.exit(1);
105
+ }
106
+ console.log(` Story: ${info.storyTitle} (${info.storyId})`);
107
+ // Check for browser-entry.ts
108
+ const browserEntryPath = path.join(projectDir, 'src', 'browser-entry.ts');
109
+ if (!fs.existsSync(browserEntryPath)) {
110
+ console.error('\nError: src/browser-entry.ts not found.');
111
+ console.error('Run "sharpee init-browser" first to add browser support.');
112
+ process.exit(1);
113
+ }
114
+ // Create output directory
115
+ const outDir = path.join(projectDir, 'dist', 'web');
116
+ fs.mkdirSync(outDir, { recursive: true });
117
+ // Build with esbuild
118
+ console.log(' Building...');
119
+ const esbuildArgs = [
120
+ browserEntryPath,
121
+ '--bundle',
122
+ '--platform=browser',
123
+ '--target=es2020',
124
+ '--format=iife',
125
+ `--global-name=SharpeeGame`,
126
+ `--outfile=${path.join(outDir, info.storyId + '.js')}`,
127
+ '--define:process.env.NODE_ENV=\\"production\\"',
128
+ ];
129
+ if (minify) {
130
+ esbuildArgs.push('--minify');
131
+ }
132
+ if (sourcemap) {
133
+ esbuildArgs.push('--sourcemap');
134
+ }
135
+ try {
136
+ (0, child_process_1.execSync)(`npx esbuild ${esbuildArgs.join(' ')}`, {
137
+ cwd: projectDir,
138
+ stdio: 'pipe',
139
+ });
140
+ console.log(` ✓ Built ${info.storyId}.js`);
141
+ }
142
+ catch (error) {
143
+ console.error(' ✗ Build failed');
144
+ if (error.stderr) {
145
+ console.error(error.stderr.toString());
146
+ }
147
+ process.exit(1);
148
+ }
149
+ // Copy HTML template
150
+ const browserHtmlPath = path.join(projectDir, 'browser', 'index.html');
151
+ const defaultHtmlPath = path.join(__dirname, '..', '..', 'templates', 'browser', 'index.html');
152
+ const htmlSource = fs.existsSync(browserHtmlPath) ? browserHtmlPath : defaultHtmlPath;
153
+ if (fs.existsSync(htmlSource)) {
154
+ let htmlContent = fs.readFileSync(htmlSource, 'utf-8');
155
+ htmlContent = processTemplate(htmlContent, info);
156
+ fs.writeFileSync(path.join(outDir, 'index.html'), htmlContent);
157
+ console.log(' ✓ Copied index.html');
158
+ }
159
+ else {
160
+ console.warn(' ⚠ HTML template not found');
161
+ }
162
+ // Copy CSS
163
+ const browserCssPath = path.join(projectDir, 'browser', 'styles.css');
164
+ const defaultCssPath = path.join(__dirname, '..', '..', 'templates', 'browser', 'styles.css');
165
+ const cssSource = fs.existsSync(browserCssPath) ? browserCssPath : defaultCssPath;
166
+ if (fs.existsSync(cssSource)) {
167
+ fs.copyFileSync(cssSource, path.join(outDir, 'styles.css'));
168
+ console.log(' ✓ Copied styles.css');
169
+ }
170
+ else {
171
+ console.warn(' ⚠ CSS file not found');
172
+ }
173
+ // Report bundle size
174
+ const bundlePath = path.join(outDir, info.storyId + '.js');
175
+ if (fs.existsSync(bundlePath)) {
176
+ const stats = fs.statSync(bundlePath);
177
+ const sizeKb = (stats.size / 1024).toFixed(1);
178
+ console.log(`\n Bundle size: ${sizeKb} KB`);
179
+ }
180
+ console.log('\n✅ Build complete!\n');
181
+ console.log(`Output: ${path.relative(projectDir, outDir)}/`);
182
+ console.log('');
183
+ console.log('To test locally:');
184
+ console.log(` npx serve ${path.relative(projectDir, outDir)}`);
185
+ console.log('');
186
+ }
187
+ function showHelp() {
188
+ console.log(`
189
+ sharpee build-browser - Build a web browser bundle
190
+
191
+ Usage: sharpee build-browser [options]
192
+
193
+ Options:
194
+ --no-minify Skip minification
195
+ --no-sourcemap Skip source map generation
196
+
197
+ Output:
198
+ dist/web/
199
+ index.html HTML page
200
+ <story-id>.js JavaScript bundle
201
+ styles.css Stylesheet
202
+
203
+ The bundle includes your story, the Sharpee engine, and all dependencies.
204
+ `);
205
+ }
206
+ //# sourceMappingURL=build-browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-browser.js","sourceRoot":"","sources":["../../src/cli/build-browser.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DH,wDA8GC;AAvKD,uCAAyB;AACzB,2CAA6B;AAC7B,iDAAyC;AAOzC;;GAEG;AACH,SAAS,cAAc,CAAC,UAAkB;IACxC,yBAAyB;IACzB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAC1D,IAAI,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;YAC9D,OAAO;gBACL,OAAO,EAAE,GAAG,CAAC,IAAI,IAAI,UAAU;gBAC/B,UAAU,EAAE,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,IAAI,IAAI,UAAU;aACtD,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,eAAe;QACjB,CAAC;IACH,CAAC;IAED,gCAAg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C,CAAC,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,oBAAoB,MAAM,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7D,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IAChE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,QAAQ;IACf,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;CAgBb,CAAC,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function runIfidCommand(args: string[]): void;
2
+ //# sourceMappingURL=ifid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ifid.d.ts","sourceRoot":"","sources":["../../src/cli/ifid.ts"],"names":[],"mappings":"AAKA,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAmBnD"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ // packages/sharpee/src/cli/ifid.ts
3
+ // IFID CLI commands
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.runIfidCommand = runIfidCommand;
6
+ const core_1 = require("@sharpee/core");
7
+ function runIfidCommand(args) {
8
+ const subcommand = args[0];
9
+ switch (subcommand) {
10
+ case 'generate':
11
+ handleGenerate();
12
+ break;
13
+ case 'validate':
14
+ handleValidate(args.slice(1));
15
+ break;
16
+ case undefined:
17
+ case 'help':
18
+ showHelp();
19
+ break;
20
+ default:
21
+ console.error(`Unknown ifid subcommand: ${subcommand}`);
22
+ showHelp();
23
+ process.exit(1);
24
+ }
25
+ }
26
+ function handleGenerate() {
27
+ const ifid = (0, core_1.generateIfid)();
28
+ console.log(ifid);
29
+ }
30
+ function handleValidate(args) {
31
+ const ifid = args[0];
32
+ if (!ifid) {
33
+ console.error('Usage: sharpee ifid validate <ifid>');
34
+ process.exit(1);
35
+ }
36
+ const isValid = (0, core_1.validateIfid)(ifid);
37
+ if (isValid) {
38
+ console.log(`Valid IFID: ${ifid}`);
39
+ }
40
+ else {
41
+ // Try normalizing (uppercase conversion)
42
+ const normalized = (0, core_1.normalizeIfid)(ifid);
43
+ if (normalized) {
44
+ console.log(`Valid after normalization:`);
45
+ console.log(` Original: ${ifid}`);
46
+ console.log(` Normalized: ${normalized}`);
47
+ }
48
+ else {
49
+ console.error(`Invalid IFID: ${ifid}`);
50
+ console.error('IFID requirements:');
51
+ console.error(' - Length: 8-63 characters');
52
+ console.error(' - Characters: A-Z, 0-9, and hyphens only');
53
+ console.error(' - Recommended: UUID format (uppercase)');
54
+ process.exit(1);
55
+ }
56
+ }
57
+ }
58
+ function showHelp() {
59
+ console.log(`
60
+ sharpee ifid - IFID utilities
61
+
62
+ Commands:
63
+ generate Generate a new IFID (UUID format)
64
+ validate <ifid> Validate an IFID string
65
+
66
+ Examples:
67
+ sharpee ifid generate
68
+ sharpee ifid validate A1B2C3D4-E5F6-7890-ABCD-EF1234567890
69
+ `);
70
+ }
71
+ //# sourceMappingURL=ifid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ifid.js","sourceRoot":"","sources":["../../src/cli/ifid.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,oBAAoB;;AAIpB,wCAmBC;AArBD,wCAA0E;AAE1E,SAAgB,cAAc,CAAC,IAAc;IAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAE3B,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,UAAU;YACb,cAAc,EAAE,CAAC;YACj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CAAC;YACvC,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;YACpC,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;YAC7C,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAC5D,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,QAAQ;IACf,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;CAUb,CAAC,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Sharpee CLI
4
+ *
5
+ * Command-line tools for creating and building Sharpee interactive fiction.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA;;;;GAIG"}
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * Sharpee CLI
5
+ *
6
+ * Command-line tools for creating and building Sharpee interactive fiction.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const ifid_1 = require("./ifid");
10
+ const init_1 = require("./init");
11
+ const init_browser_1 = require("./init-browser");
12
+ const build_browser_1 = require("./build-browser");
13
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
14
+ const { version: VERSION } = require('../../package.json');
15
+ async function main() {
16
+ const args = process.argv.slice(2);
17
+ const command = args[0];
18
+ try {
19
+ switch (command) {
20
+ case 'init':
21
+ await (0, init_1.runInitCommand)(args.slice(1));
22
+ break;
23
+ case 'init-browser':
24
+ await (0, init_browser_1.runInitBrowserCommand)(args.slice(1));
25
+ break;
26
+ case 'build-browser':
27
+ await (0, build_browser_1.runBuildBrowserCommand)(args.slice(1));
28
+ break;
29
+ case 'ifid':
30
+ (0, ifid_1.runIfidCommand)(args.slice(1));
31
+ break;
32
+ case 'version':
33
+ case '-v':
34
+ case '--version':
35
+ console.log(`sharpee ${VERSION}`);
36
+ break;
37
+ case 'help':
38
+ case '-h':
39
+ case '--help':
40
+ case undefined:
41
+ showHelp();
42
+ break;
43
+ default:
44
+ console.error(`Unknown command: ${command}`);
45
+ showHelp();
46
+ process.exit(1);
47
+ }
48
+ }
49
+ catch (error) {
50
+ console.error('Error:', error instanceof Error ? error.message : error);
51
+ process.exit(1);
52
+ }
53
+ }
54
+ function showHelp() {
55
+ console.log(`
56
+ sharpee - Interactive Fiction Engine CLI
57
+
58
+ Usage: sharpee <command> [options]
59
+
60
+ Commands:
61
+ init Create a new Sharpee story project
62
+ init-browser Add browser client to an existing project
63
+ build-browser Build a web browser bundle
64
+ ifid IFID utilities (generate, validate)
65
+ version Show version
66
+ help Show this help
67
+
68
+ Examples:
69
+ sharpee init my-adventure Create new project in ./my-adventure/
70
+ sharpee init-browser Add browser support to current project
71
+ sharpee build-browser Build web bundle in dist/web/
72
+
73
+ Run 'sharpee <command> --help' for command-specific help.
74
+ `);
75
+ }
76
+ main();
77
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;AACA;;;;GAIG;;AAEH,iCAAwC;AACxC,iCAAwC;AACxC,iDAAuD;AACvD,mDAAyD;AAEzD,8DAA8D;AAC9D,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAE3D,KAAK,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAExB,IAAI,CAAC;QACH,QAAQ,OAAO,EAAE,CAAC;YAChB,KAAK,MAAM;gBACT,MAAM,IAAA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harpee init-browser
3
+ *
4
+ * Adds browser client files to an existing Sharpee story project.
5
+ */
6
+ /**
7
+ * Run the init-browser command
8
+ */
9
+ export declare function runInitBrowserCommand(args: string[]): Promise<void>;
10
+ //# sourceMappingURL=init-browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-browser.d.ts","sourceRoot":"","sources":["../../src/cli/init-browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA2DH;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgGzE"}