@soulcraft/brainy 0.9.15 → 0.9.17

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/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![Node.js](https://img.shields.io/badge/node-%3E%3D24.0.0-brightgreen.svg)](https://nodejs.org/)
7
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.1.6-blue.svg)](https://www.typescriptlang.org/)
8
8
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
9
- [![npm](https://img.shields.io/badge/npm-v0.9.15-blue.svg)](https://www.npmjs.com/package/@soulcraft/brainy)
9
+ [![npm](https://img.shields.io/badge/npm-v0.9.17-blue.svg)](https://www.npmjs.com/package/@soulcraft/brainy)
10
10
 
11
11
  [//]: # ([![Cartographer](https://img.shields.io/badge/Cartographer-Official%20Standard-brightgreen)](https://github.com/sodal-project/cartographer))
12
12
 
@@ -110,8 +110,13 @@ import { BrainyData } from '@soulcraft/brainy'
110
110
 
111
111
  // Minified version for production
112
112
  import { BrainyData } from '@soulcraft/brainy/min'
113
+
114
+ // CLI functionality (only imported when needed)
115
+ import '@soulcraft/brainy/cli'
113
116
  ```
114
117
 
118
+ > **Note**: The CLI functionality (4MB) is not included in the standard import, reducing the bundle size for browser and Node.js applications. The CLI is only built and loaded when explicitly imported or when using the command-line interface.
119
+
115
120
  ### Browser Usage
116
121
 
117
122
  ```html
@@ -285,23 +290,30 @@ Brainy uses a modern build system that optimizes for both Node.js and browser en
285
290
  2. **Environment-Specific Builds**
286
291
  - **Node.js Build**: Optimized for server environments with full functionality
287
292
  - **Browser Build**: Optimized for browser environments with reduced bundle size
293
+ - **CLI Build**: Separate build for command-line interface functionality
288
294
  - Conditional exports in package.json for automatic environment detection
289
295
 
290
- 3. **Environment Detection**
296
+ 3. **Modular Architecture**
297
+ - Core functionality and CLI are built separately
298
+ - CLI (4MB) is only included when explicitly imported or used from command line
299
+ - Reduced bundle size for browser and Node.js applications
300
+
301
+ 4. **Environment Detection**
291
302
  - Automatically detects whether it's running in a browser or Node.js
292
303
  - Loads appropriate dependencies and functionality based on the environment
293
304
  - Provides consistent API across all environments
294
305
 
295
- 4. **TypeScript**
306
+ 5. **TypeScript**
296
307
  - Written in TypeScript for type safety and better developer experience
297
308
  - Generates type definitions for TypeScript users
298
309
  - Compiled to ES2020 for modern JavaScript environments
299
310
 
300
- 5. **Build Scripts**
301
- - `npm run build`: Builds the Node.js version
311
+ 6. **Build Scripts**
312
+ - `npm run build`: Builds the core library without CLI
302
313
  - `npm run build:browser`: Builds the browser-optimized version
303
- - `npm run build:cli`: Builds the CLI version
304
- - `npm run demo`: Builds both Node.js and browser versions and starts a demo server
314
+ - `npm run build:cli`: Builds the CLI version (only needed for CLI usage)
315
+ - `npm run prepare:cli`: Builds the CLI for command-line usage
316
+ - `npm run demo`: Builds both core library and browser versions and starts a demo server
305
317
  - GitHub Actions workflow: Automatically deploys the demo directory to GitHub Pages when pushing to the main branch
306
318
 
307
319
  ### Running the Pipeline
@@ -412,11 +424,13 @@ Connections between nouns (edges in the graph):
412
424
 
413
425
  ## Command Line Interface
414
426
 
415
- Brainy includes a powerful CLI for managing your data:
427
+ Brainy includes a powerful CLI for managing your data. The CLI is available as a separate package `@soulcraft/brainy-cli` to reduce the bundle size of the main package.
428
+
429
+ ### Installing and Using the CLI
416
430
 
417
431
  ```bash
418
- # Install globally
419
- npm install -g @soulcraft/brainy --legacy-peer-deps
432
+ # Install the CLI globally
433
+ npm install -g @soulcraft/brainy-cli
420
434
 
421
435
  # Initialize a database
422
436
  brainy init
@@ -436,6 +450,24 @@ brainy visualize
436
450
  brainy visualize --root <id> --depth 3
437
451
  ```
438
452
 
453
+ ### Publishing the CLI Package
454
+
455
+ If you need to publish the CLI package to npm, please refer to the [CLI Publishing Guide](docs/publishing-cli.md) for detailed instructions.
456
+
457
+ ### Using the CLI in Your Code
458
+
459
+ If you need to use the CLI functionality in your code, you can import it explicitly:
460
+
461
+ ```typescript
462
+ // Import the CLI functionality
463
+ import '@soulcraft/brainy/cli'
464
+
465
+ // Now you can use the CLI programmatically
466
+ // ...
467
+ ```
468
+
469
+ This will only build and load the CLI when you explicitly import it, keeping your bundle size small when you don't need the CLI.
470
+
439
471
  ### Development Usage
440
472
 
441
473
  ```bash
package/dist/cli.js CHANGED
@@ -13426,7 +13426,7 @@ var omelette = /*@__PURE__*/getDefaultExportFromCjs(omeletteExports);
13426
13426
  * This file is auto-generated during the build process.
13427
13427
  * Do not modify this file directly.
13428
13428
  */
13429
- const VERSION = '0.9.13';
13429
+ const VERSION = '0.9.17';
13430
13430
 
13431
13431
  /**
13432
13432
  * Brainy CLI
@@ -2,5 +2,5 @@
2
2
  * This file is auto-generated during the build process.
3
3
  * Do not modify this file directly.
4
4
  */
5
- export declare const VERSION = "0.9.15";
5
+ export declare const VERSION = "0.9.17";
6
6
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "0.9.15",
3
+ "version": "0.9.17",
4
4
  "description": "A vector graph database using HNSW indexing with Origin Private File System storage",
5
5
  "main": "dist/unified.js",
6
6
  "module": "dist/unified.js",
@@ -22,6 +22,9 @@
22
22
  "./types/augmentations": {
23
23
  "import": "./dist/types/augmentations.js",
24
24
  "types": "./dist/types/augmentations.d.ts"
25
+ },
26
+ "./cli": {
27
+ "import": "./dist/cli.js"
25
28
  }
26
29
  },
27
30
  "engines": {
@@ -34,7 +37,6 @@
34
37
  "build:cli": "BUILD_TYPE=cli rollup -c rollup.config.js",
35
38
  "start": "node dist/unified.js",
36
39
  "demo": "npm run build && npm run build:browser && npx http-server -o /index.html",
37
- "cli": "npm run build:cli && node ./cli-wrapper.js",
38
40
  "version": "node scripts/generate-version.js",
39
41
  "version:patch": "npm version patch",
40
42
  "version:minor": "npm version minor",
@@ -44,7 +46,9 @@
44
46
  "format": "prettier --write \"src/**/*.{ts,js}\"",
45
47
  "check-format": "prettier --check \"src/**/*.{ts,js}\"",
46
48
  "check-style": "node scripts/check-code-style.js",
49
+ "prepare": "npm run build",
47
50
  "deploy": "npm run build && npm publish",
51
+ "deploy:both": "node scripts/publish-cli.js",
48
52
  "deploy:cloud:aws": "cd cloud-wrapper && npm run build && npm run deploy:aws",
49
53
  "deploy:cloud:gcp": "cd cloud-wrapper && npm run build && npm run deploy:gcp",
50
54
  "deploy:cloud:cloudflare": "cd cloud-wrapper && npm run build && npm run deploy:cloudflare",
@@ -52,9 +56,6 @@
52
56
  "postinstall": "echo 'Note: If you encounter dependency conflicts with TensorFlow.js packages, please use: npm install --legacy-peer-deps'",
53
57
  "dry-run": "npm pack --dry-run"
54
58
  },
55
- "bin": {
56
- "brainy": "cli-wrapper.js"
57
- },
58
59
  "keywords": [
59
60
  "vector-database",
60
61
  "hnsw",
@@ -84,7 +85,6 @@
84
85
  "dist/types/",
85
86
  "LICENSE",
86
87
  "README.md",
87
- "cli-wrapper.js",
88
88
  "brainy.png"
89
89
  ],
90
90
  "devDependencies": {
package/cli-wrapper.js DELETED
@@ -1,56 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * CLI Wrapper Script
5
- *
6
- * This script serves as a wrapper for the Brainy CLI, ensuring that command-line arguments
7
- * are properly passed to the CLI when invoked through npm scripts.
8
- */
9
-
10
- import { spawn } from 'child_process'
11
- import { fileURLToPath } from 'url'
12
- import { dirname, join } from 'path'
13
- import fs from 'fs'
14
-
15
- // Get the directory of the current module
16
- const __filename = fileURLToPath(import.meta.url)
17
- const __dirname = dirname(__filename)
18
-
19
- // Path to the actual CLI script
20
- const cliPath = join(__dirname, 'dist', 'cli.js')
21
-
22
- // Check if the CLI script exists
23
- if (!fs.existsSync(cliPath)) {
24
- console.error(`Error: CLI script not found at ${cliPath}`)
25
- console.error('Make sure you have built the project with "npm run build"')
26
- process.exit(1)
27
- }
28
-
29
- // Special handling for version flags
30
- if (process.argv.includes('--version') || process.argv.includes('-V')) {
31
- // Read version directly from package.json to ensure it's always correct
32
- try {
33
- const packageJsonPath = join(__dirname, 'package.json')
34
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
35
- console.log(packageJson.version)
36
- process.exit(0)
37
- } catch (error) {
38
- console.error('Error loading version information:', error.message)
39
- process.exit(1)
40
- }
41
- }
42
-
43
- // Forward all arguments to the CLI script
44
- const args = process.argv.slice(2)
45
-
46
- // Check if npm is passing --force flag
47
- // When npm runs with --force, it sets the npm_config_force environment variable
48
- if (process.env.npm_config_force === 'true' && args.includes('clear') && !args.includes('--force') && !args.includes('-f')) {
49
- args.push('--force')
50
- }
51
-
52
- const cli = spawn('node', [cliPath, ...args], { stdio: 'inherit' })
53
-
54
- cli.on('close', (code) => {
55
- process.exit(code)
56
- })