@soulcraft/brainy 0.9.16 → 0.9.19
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 +59 -15
- package/dist/cli.js +1 -1
- package/dist/utils/version.d.ts +1 -1
- package/package.json +3 -11
- package/cli-wrapper.js +0 -56
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://nodejs.org/)
|
|
7
7
|
[](https://www.typescriptlang.org/)
|
|
8
8
|
[](CONTRIBUTING.md)
|
|
9
|
-
[](https://www.npmjs.com/package/@soulcraft/brainy)
|
|
10
10
|
|
|
11
11
|
[//]: # ([](https://github.com/sodal-project/cartographer))
|
|
12
12
|
|
|
@@ -110,8 +110,15 @@ 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
|
|
119
|
+
> Node.js applications. The CLI is only built and loaded when explicitly imported or when using the command-line
|
|
120
|
+
> interface.
|
|
121
|
+
|
|
115
122
|
### Browser Usage
|
|
116
123
|
|
|
117
124
|
```html
|
|
@@ -285,23 +292,30 @@ Brainy uses a modern build system that optimizes for both Node.js and browser en
|
|
|
285
292
|
2. **Environment-Specific Builds**
|
|
286
293
|
- **Node.js Build**: Optimized for server environments with full functionality
|
|
287
294
|
- **Browser Build**: Optimized for browser environments with reduced bundle size
|
|
295
|
+
- **CLI Build**: Separate build for command-line interface functionality
|
|
288
296
|
- Conditional exports in package.json for automatic environment detection
|
|
289
297
|
|
|
290
|
-
3. **
|
|
298
|
+
3. **Modular Architecture**
|
|
299
|
+
- Core functionality and CLI are built separately
|
|
300
|
+
- CLI (4MB) is only included when explicitly imported or used from command line
|
|
301
|
+
- Reduced bundle size for browser and Node.js applications
|
|
302
|
+
|
|
303
|
+
4. **Environment Detection**
|
|
291
304
|
- Automatically detects whether it's running in a browser or Node.js
|
|
292
305
|
- Loads appropriate dependencies and functionality based on the environment
|
|
293
306
|
- Provides consistent API across all environments
|
|
294
307
|
|
|
295
|
-
|
|
308
|
+
5. **TypeScript**
|
|
296
309
|
- Written in TypeScript for type safety and better developer experience
|
|
297
310
|
- Generates type definitions for TypeScript users
|
|
298
311
|
- Compiled to ES2020 for modern JavaScript environments
|
|
299
312
|
|
|
300
|
-
|
|
301
|
-
- `npm run build`: Builds the
|
|
313
|
+
6. **Build Scripts**
|
|
314
|
+
- `npm run build`: Builds the core library without CLI
|
|
302
315
|
- `npm run build:browser`: Builds the browser-optimized version
|
|
303
|
-
- `npm run build:cli`: Builds the CLI version
|
|
304
|
-
- `npm run
|
|
316
|
+
- `npm run build:cli`: Builds the CLI version (only needed for CLI usage)
|
|
317
|
+
- `npm run prepare:cli`: Builds the CLI for command-line usage
|
|
318
|
+
- `npm run demo`: Builds both core library and browser versions and starts a demo server
|
|
305
319
|
- GitHub Actions workflow: Automatically deploys the demo directory to GitHub Pages when pushing to the main branch
|
|
306
320
|
|
|
307
321
|
### Running the Pipeline
|
|
@@ -412,11 +426,14 @@ Connections between nouns (edges in the graph):
|
|
|
412
426
|
|
|
413
427
|
## Command Line Interface
|
|
414
428
|
|
|
415
|
-
Brainy includes a powerful CLI for managing your data
|
|
429
|
+
Brainy includes a powerful CLI for managing your data. The CLI is available as a separate package
|
|
430
|
+
`@soulcraft/brainy-cli` to reduce the bundle size of the main package.
|
|
431
|
+
|
|
432
|
+
### Installing and Using the CLI
|
|
416
433
|
|
|
417
434
|
```bash
|
|
418
|
-
# Install globally
|
|
419
|
-
npm install -g @soulcraft/brainy
|
|
435
|
+
# Install the CLI globally
|
|
436
|
+
npm install -g @soulcraft/brainy-cli
|
|
420
437
|
|
|
421
438
|
# Initialize a database
|
|
422
439
|
brainy init
|
|
@@ -436,6 +453,26 @@ brainy visualize
|
|
|
436
453
|
brainy visualize --root <id> --depth 3
|
|
437
454
|
```
|
|
438
455
|
|
|
456
|
+
### Publishing the CLI Package
|
|
457
|
+
|
|
458
|
+
If you need to publish the CLI package to npm, please refer to the [CLI Publishing Guide](docs/publishing-cli.md) for
|
|
459
|
+
detailed instructions.
|
|
460
|
+
|
|
461
|
+
### Using the CLI in Your Code
|
|
462
|
+
|
|
463
|
+
If you need to use the CLI functionality in your code, you can import it explicitly:
|
|
464
|
+
|
|
465
|
+
```typescript
|
|
466
|
+
// Import the CLI functionality
|
|
467
|
+
import '@soulcraft/brainy/cli'
|
|
468
|
+
|
|
469
|
+
// Now you can use the CLI programmatically
|
|
470
|
+
// ...
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
This will only build and load the CLI when you explicitly import it, keeping your bundle size small when you don't need
|
|
474
|
+
the CLI.
|
|
475
|
+
|
|
439
476
|
### Development Usage
|
|
440
477
|
|
|
441
478
|
```bash
|
|
@@ -1270,17 +1307,24 @@ comprehensive [Scaling Strategy](scalingStrategy.md) document.
|
|
|
1270
1307
|
|
|
1271
1308
|
Brainy takes advantage of several optimizations available in Node.js 24:
|
|
1272
1309
|
|
|
1273
|
-
1. **Improved Worker Threads Performance**: The multithreading system has been completely rewritten to leverage Node.js
|
|
1310
|
+
1. **Improved Worker Threads Performance**: The multithreading system has been completely rewritten to leverage Node.js
|
|
1311
|
+
24's enhanced Worker Threads API, resulting in better performance for compute-intensive operations like embedding
|
|
1312
|
+
generation and vector similarity calculations.
|
|
1274
1313
|
|
|
1275
|
-
2. **Worker Pool Management**: A sophisticated worker pool system reuses worker threads to minimize the overhead of
|
|
1314
|
+
2. **Worker Pool Management**: A sophisticated worker pool system reuses worker threads to minimize the overhead of
|
|
1315
|
+
creating and destroying threads, leading to more efficient resource utilization.
|
|
1276
1316
|
|
|
1277
|
-
3. **Dynamic Module Imports**: Uses the new `node:` protocol prefix for importing core modules, which provides better
|
|
1317
|
+
3. **Dynamic Module Imports**: Uses the new `node:` protocol prefix for importing core modules, which provides better
|
|
1318
|
+
performance and more reliable module resolution.
|
|
1278
1319
|
|
|
1279
|
-
4. **ES Modules Optimizations**: Takes advantage of Node.js 24's improved ESM implementation for faster module loading
|
|
1320
|
+
4. **ES Modules Optimizations**: Takes advantage of Node.js 24's improved ESM implementation for faster module loading
|
|
1321
|
+
and execution.
|
|
1280
1322
|
|
|
1281
|
-
5. **Enhanced Error Handling**: Implements more robust error handling patterns available in Node.js 24 for better
|
|
1323
|
+
5. **Enhanced Error Handling**: Implements more robust error handling patterns available in Node.js 24 for better
|
|
1324
|
+
stability and debugging.
|
|
1282
1325
|
|
|
1283
1326
|
These optimizations are particularly beneficial for:
|
|
1327
|
+
|
|
1284
1328
|
- Large-scale vector operations
|
|
1285
1329
|
- Batch processing of embeddings
|
|
1286
1330
|
- Real-time data processing pipelines
|
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.
|
|
13429
|
+
const VERSION = '0.9.17';
|
|
13430
13430
|
|
|
13431
13431
|
/**
|
|
13432
13432
|
* Brainy CLI
|
package/dist/utils/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.19",
|
|
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",
|
|
@@ -31,10 +31,8 @@
|
|
|
31
31
|
"prebuild": "node scripts/generate-version.js",
|
|
32
32
|
"build": "BUILD_TYPE=unified rollup -c rollup.config.js",
|
|
33
33
|
"build:browser": "BUILD_TYPE=browser rollup -c rollup.config.js",
|
|
34
|
-
"build:cli": "BUILD_TYPE=cli rollup -c rollup.config.js",
|
|
35
34
|
"start": "node dist/unified.js",
|
|
36
35
|
"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
36
|
"version": "node scripts/generate-version.js",
|
|
39
37
|
"version:patch": "npm version patch",
|
|
40
38
|
"version:minor": "npm version minor",
|
|
@@ -44,8 +42,9 @@
|
|
|
44
42
|
"format": "prettier --write \"src/**/*.{ts,js}\"",
|
|
45
43
|
"check-format": "prettier --check \"src/**/*.{ts,js}\"",
|
|
46
44
|
"check-style": "node scripts/check-code-style.js",
|
|
47
|
-
"prepare": "npm run build
|
|
45
|
+
"prepare": "npm run build",
|
|
48
46
|
"deploy": "npm run build && npm publish",
|
|
47
|
+
"deploy:both": "node scripts/publish-cli.js",
|
|
49
48
|
"deploy:cloud:aws": "cd cloud-wrapper && npm run build && npm run deploy:aws",
|
|
50
49
|
"deploy:cloud:gcp": "cd cloud-wrapper && npm run build && npm run deploy:gcp",
|
|
51
50
|
"deploy:cloud:cloudflare": "cd cloud-wrapper && npm run build && npm run deploy:cloudflare",
|
|
@@ -53,9 +52,6 @@
|
|
|
53
52
|
"postinstall": "echo 'Note: If you encounter dependency conflicts with TensorFlow.js packages, please use: npm install --legacy-peer-deps'",
|
|
54
53
|
"dry-run": "npm pack --dry-run"
|
|
55
54
|
},
|
|
56
|
-
"bin": {
|
|
57
|
-
"brainy": "cli-wrapper.js"
|
|
58
|
-
},
|
|
59
55
|
"keywords": [
|
|
60
56
|
"vector-database",
|
|
61
57
|
"hnsw",
|
|
@@ -85,7 +81,6 @@
|
|
|
85
81
|
"dist/types/",
|
|
86
82
|
"LICENSE",
|
|
87
83
|
"README.md",
|
|
88
|
-
"cli-wrapper.js",
|
|
89
84
|
"brainy.png"
|
|
90
85
|
],
|
|
91
86
|
"devDependencies": {
|
|
@@ -95,7 +90,6 @@
|
|
|
95
90
|
"@rollup/plugin-replace": "^5.0.5",
|
|
96
91
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
97
92
|
"@types/node": "^20.4.5",
|
|
98
|
-
"@types/omelette": "^0.4.5",
|
|
99
93
|
"@types/uuid": "^10.0.0",
|
|
100
94
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
101
95
|
"@typescript-eslint/parser": "^6.0.0",
|
|
@@ -114,8 +108,6 @@
|
|
|
114
108
|
"@tensorflow/tfjs-converter": "^4.22.0",
|
|
115
109
|
"@tensorflow/tfjs-core": "^4.22.0",
|
|
116
110
|
"buffer": "^6.0.3",
|
|
117
|
-
"commander": "^14.0.0",
|
|
118
|
-
"omelette": "^0.4.17",
|
|
119
111
|
"uuid": "^9.0.0"
|
|
120
112
|
},
|
|
121
113
|
"prettier": {
|
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
|
-
})
|