1818📊 ** Embedding Statistics** - Real-time metrics for provider and cache performance
1919🎯 ** Smart Search Routing** - Automatic fallback from cloud to local on failures
2020
21- ## Installation
21+ ## Installation from Local Repository
2222
23- ### Option 1: Build from Source
23+ ### Option 1: Install Directly from Directory (Recommended)
2424
2525``` bash
26- # Install NAPI-RS CLI
27- npm install -g @napi-rs/cli
26+ # Build the addon once
27+ cd /path/to/codegraph-rust/crates/codegraph-napi
28+ npm install
29+ npm run build
30+
31+ # Install in your project
32+ cd /path/to/your-project
33+ npm install /path/to/codegraph-rust/crates/codegraph-napi
34+ ```
35+
36+ ### Option 2: Pack and Install
2837
29- # Build the addon
30- cd crates/codegraph-napi
38+ ``` bash
39+ # Build and pack the addon
40+ cd /path/to/codegraph-rust/crates/codegraph-napi
3141npm install
3242npm run build
43+ npm pack # Or: bun run pack
3344
34- # The compiled addon will be in ./codegraph.*.node
45+ # This creates: codegraph-napi-1.0.0.tgz
46+
47+ # Install the tarball in your project
48+ cd /path/to/your-project
49+ npm install /path/to/codegraph-rust/crates/codegraph-napi/codegraph-napi-1.0.0.tgz
3550```
3651
37- ### Option 2: Pre-built Binaries (Coming Soon)
52+ The tarball includes:
53+ - ✅ Compiled ` .node ` binary for your platform
54+ - ✅ TypeScript definitions (` index.d.ts ` )
55+ - ✅ ` package.json ` with all metadata
56+
57+ ** Quick Example:**
58+
59+ ``` bash
60+ # One-time: Build and pack
61+ cd ~ /codegraph-rust/crates/codegraph-napi
62+ npm install && npm run build && npm pack
63+
64+ # Share the tarball or install locally
65+ cd ~ /my-awesome-app
66+ npm install ~ /codegraph-rust/crates/codegraph-napi/codegraph-napi-1.0.0.tgz
67+
68+ # Start using immediately
69+ cat > search.ts << 'EOF '
70+ import { semanticSearch } from 'codegraph-napi';
71+
72+ const results = await semanticSearch('authentication');
73+ console.log(results);
74+ EOF
75+
76+ npx tsx search.ts
77+ ```
78+
79+ ### Option 3: Add to package.json
80+
81+ ``` json
82+ {
83+ "dependencies" : {
84+ "codegraph-napi" : " file:../codegraph-rust/crates/codegraph-napi"
85+ }
86+ }
87+ ```
88+
89+ Then run ` npm install ` or ` bun install ` .
90+
91+ ### Option 4: Pre-built Binaries (Coming Soon)
3892
3993``` bash
4094npm install codegraph
@@ -82,10 +136,12 @@ export CODEGRAPH_CLOUD_ENABLED=true
82136
83137## Quick Start
84138
139+ > ** Note** : All examples work with both ` npm ` and ` bun ` . Simply replace ` npm ` with ` bun ` in any command.
140+
85141### Semantic Search (New!)
86142
87143``` typescript
88- import { semanticSearch , getCloudConfig } from ' codegraph' ;
144+ import { semanticSearch , getCloudConfig } from ' codegraph-napi ' ;
89145
90146// Check cloud availability
91147const cloudConfig = await getCloudConfig ();
@@ -115,7 +171,7 @@ import {
115171 listVersions ,
116172 createBranch ,
117173 mergeBranches ,
118- } from ' codegraph' ;
174+ } from ' codegraph-napi ' ;
119175
120176// Create a version - direct function call!
121177const version = await createVersion ({
@@ -144,7 +200,7 @@ await createBranch({
144200### Initialization
145201
146202``` typescript
147- import { initialize , getAddonVersion } from ' codegraph' ;
203+ import { initialize , getAddonVersion } from ' codegraph-napi ' ;
148204
149205// Optional - initializes automatically on first call
150206await initialize ();
@@ -385,7 +441,7 @@ console.timeEnd('cli');
385441
386442``` typescript
387443import express from ' express' ;
388- import { createVersion , listVersions } from ' codegraph' ;
444+ import { createVersion , listVersions } from ' codegraph-napi ' ;
389445
390446const app = express ();
391447app .use (express .json ());
@@ -412,7 +468,7 @@ app.listen(3000);
412468``` typescript
413469#! / usr / bin / env node
414470import { Command } from ' commander' ;
415- import { createVersion , listVersions } from ' codegraph' ;
471+ import { createVersion , listVersions } from ' codegraph-napi ' ;
416472
417473const program = new Command ();
418474
@@ -444,7 +500,7 @@ program.parse();
444500
445501``` typescript
446502import { Queue , Worker } from ' bullmq' ;
447- import { createVersion , mergeBranches } from ' codegraph' ;
503+ import { createVersion , mergeBranches } from ' codegraph-napi ' ;
448504
449505const worker = new Worker (' codegraph-tasks' , async job => {
450506 switch (job .name ) {
@@ -465,7 +521,7 @@ const worker = new Worker('codegraph-tasks', async job => {
465521### Example 1: Semantic Code Search with Fallback
466522
467523``` typescript
468- import { semanticSearch , getCloudConfig } from ' codegraph' ;
524+ import { semanticSearch , getCloudConfig } from ' codegraph-napi ' ;
469525
470526async function searchCode(query : string ) {
471527 // Check cloud availability first
@@ -500,7 +556,7 @@ await searchCode('JWT token validation');
500556
501557``` typescript
502558import { watch } from ' fs' ;
503- import { reloadConfig , getCloudConfig , getConfigPath } from ' codegraph' ;
559+ import { reloadConfig , getCloudConfig , getConfigPath } from ' codegraph-napi ' ;
504560
505561async function watchConfiguration() {
506562 const configPath = await getConfigPath ();
@@ -533,7 +589,7 @@ watchConfiguration().catch(console.error);
533589### Example 3: Embedding Provider Monitoring
534590
535591``` typescript
536- import { getEmbeddingStats , semanticSearch } from ' codegraph' ;
592+ import { getEmbeddingStats , semanticSearch } from ' codegraph-napi ' ;
537593
538594async function monitorEmbeddings() {
539595 // Get initial stats
@@ -569,7 +625,7 @@ monitorEmbeddings().catch(console.error);
569625### Example 4: Progressive Search (Local → Cloud)
570626
571627``` typescript
572- import { semanticSearch , isCloudAvailable } from ' codegraph' ;
628+ import { semanticSearch , isCloudAvailable } from ' codegraph-napi ' ;
573629
574630async function progressiveSearch(query : string ) {
575631 // Try local search first (fast)
@@ -611,7 +667,7 @@ import {
611667 semanticSearch ,
612668 getCloudConfig ,
613669 reloadConfig
614- } from ' codegraph' ;
670+ } from ' codegraph-napi ' ;
615671
616672class SearchService {
617673 private cloudEnabled = false ;
@@ -711,7 +767,7 @@ CMD ["node", "server.js"]
711767
712768``` typescript
713769// lambda/handler.ts
714- import { createVersion , listVersions } from ' codegraph' ;
770+ import { createVersion , listVersions } from ' codegraph-napi ' ;
715771
716772export const handler = async (event ) => {
717773 if (event .action === ' create' ) {
@@ -832,7 +888,7 @@ mkdir -p ~/.codegraph
832888// Set environment variable before importing
833889process .env .CODEGRAPH_STORAGE = ' /custom/path' ;
834890
835- import { initialize } from ' codegraph' ;
891+ import { initialize } from ' codegraph-napi ' ;
836892await initialize ();
837893```
838894
0 commit comments