brainy/README.demo.md
David Snelling 7878f200fc **docs: restructure CLI usage details and update scripts for clarity**
- **CLI Documentation Updates**:
  - Updated `README.md` to reflect the separation of CLI functionality into a new package: `@soulcraft/brainy-cli`.
  - Replaced inline CLI imports with instructions for installing and using `@soulcraft/brainy-cli`.
  - Clarified notes on keeping the main package lightweight by decoupling CLI functionality.

- **Script and Command Adjustments**:
  - Modified build instructions in `README.demo.md` to use `npm run build && npm run build:browser`.
  - Updated demo scripts in `package.json` to point to `/demo/index.html` instead of `/index.html`.
  - Revised style-check script in `CONTRIBUTING.md` to use `npm run check:style`.

- **Issues and Contribution Guidelines**:
  - Improved issue reporting section in `DEVELOPERS.md` with clearer guidelines and examples for bug and feature requests.

**Purpose**: These changes enhance documentation accuracy, streamline developer guidance, and ensure commands/scripts are up-to-date with current usage patterns.
2025-07-17 07:53:41 -07:00

1.8 KiB

Running the Brainy Demo

The Brainy interactive demo showcases the library's features in a web browser. Follow these steps to run it:

Prerequisites

  • Make sure you have Node.js installed (version 24.4.0 or higher)
  • Ensure the project is built (run both npm run build and npm run build:browser)

Running the Demo

Run the following command from the project root:

npm run demo

This will start an HTTP server and automatically open the demo in your default browser.

Option 2: Manual setup

  1. Start an HTTP server in the project root:
npx http-server
  1. Open your browser and navigate to: http://localhost:8080/demo/index.html

Troubleshooting

If you see the error "Could not load Brainy library. Please ensure the project is built and served over HTTP", check the following:

  1. Make sure you've built the project with npm run build && npm run build:browser
  2. Ensure you're accessing the demo through HTTP (not by opening the file directly)
  3. Check your browser's console for additional error messages

If issues persist, try clearing your browser cache or using a private/incognito window.

Build Process

The Brainy library uses a two-step build process:

  1. npm run build - Compiles TypeScript files to JavaScript (used for Node.js environments)
  2. npm run build:browser - Creates a browser-compatible bundle using Rollup

You can run both steps together with:

npm run build && npm run build:browser

Or simply use the demo script which does this for you:

npm run demo

The browser bundle is created from src/unified.ts, which provides environment detection and adapts to browser, Node.js, or serverless environments. This unified approach ensures that the library works correctly across all environments.