@colbymchenry/codegraph 0.5.7 → 0.6.2

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.
Files changed (52) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +682 -681
  3. package/dist/bin/codegraph.js +14 -14
  4. package/dist/bin/codegraph.js.map +1 -1
  5. package/dist/bin/uninstall.d.ts +15 -0
  6. package/dist/bin/uninstall.d.ts.map +1 -0
  7. package/dist/bin/uninstall.js +174 -0
  8. package/dist/bin/uninstall.js.map +1 -0
  9. package/dist/db/migrations.js +11 -11
  10. package/dist/db/queries.js +86 -86
  11. package/dist/db/schema.sql +163 -163
  12. package/dist/directory.js +16 -16
  13. package/dist/extraction/grammars.d.ts.map +1 -1
  14. package/dist/extraction/grammars.js +50 -4
  15. package/dist/extraction/grammars.js.map +1 -1
  16. package/dist/extraction/tree-sitter.d.ts +64 -0
  17. package/dist/extraction/tree-sitter.d.ts.map +1 -1
  18. package/dist/extraction/tree-sitter.js +586 -1
  19. package/dist/extraction/tree-sitter.js.map +1 -1
  20. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  21. package/dist/installer/banner.d.ts +1 -1
  22. package/dist/installer/banner.d.ts.map +1 -1
  23. package/dist/installer/banner.js +12 -10
  24. package/dist/installer/banner.js.map +1 -1
  25. package/dist/installer/claude-md-template.js +32 -32
  26. package/dist/installer/config-writer.d.ts +0 -1
  27. package/dist/installer/config-writer.d.ts.map +1 -1
  28. package/dist/installer/config-writer.js +8 -26
  29. package/dist/installer/config-writer.js.map +1 -1
  30. package/dist/installer/index.d.ts.map +1 -1
  31. package/dist/installer/index.js +11 -26
  32. package/dist/installer/index.js.map +1 -1
  33. package/dist/resolution/import-resolver.d.ts +4 -0
  34. package/dist/resolution/import-resolver.d.ts.map +1 -1
  35. package/dist/resolution/import-resolver.js +9 -0
  36. package/dist/resolution/import-resolver.js.map +1 -1
  37. package/dist/resolution/index.d.ts +1 -1
  38. package/dist/resolution/index.d.ts.map +1 -1
  39. package/dist/resolution/index.js +39 -4
  40. package/dist/resolution/index.js.map +1 -1
  41. package/dist/sync/git-hooks.d.ts +66 -0
  42. package/dist/sync/git-hooks.d.ts.map +1 -0
  43. package/dist/sync/git-hooks.js +281 -0
  44. package/dist/sync/git-hooks.js.map +1 -0
  45. package/dist/types.d.ts +1 -1
  46. package/dist/types.d.ts.map +1 -1
  47. package/dist/types.js +11 -0
  48. package/dist/types.js.map +1 -1
  49. package/dist/vectors/search.js +33 -33
  50. package/package.json +60 -59
  51. package/scripts/patch-tree-sitter-dart.js +112 -112
  52. package/scripts/postinstall.js +68 -68
@@ -1,112 +1,112 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Patches tree-sitter-dart to use NAPI bindings compatible with tree-sitter 0.22+
4
- *
5
- * tree-sitter-dart v1.0.0 ships with NAN-style bindings that are incompatible
6
- * with tree-sitter 0.22+ which expects NAPI-style bindings with type-tagged
7
- * externals. This script rewrites the binding files and rebuilds.
8
- */
9
- const { writeFileSync, existsSync } = require('fs');
10
- const { join } = require('path');
11
- const { execSync } = require('child_process');
12
-
13
- const DART_DIR = join(__dirname, '..', 'node_modules', 'tree-sitter-dart');
14
-
15
- if (!existsSync(DART_DIR)) {
16
- // tree-sitter-dart not installed, skip
17
- process.exit(0);
18
- }
19
-
20
- // Check if already patched (look for NAPI-style binding)
21
- const bindingPath = join(DART_DIR, 'bindings', 'node', 'binding.cc');
22
- const { readFileSync } = require('fs');
23
- try {
24
- const existing = readFileSync(bindingPath, 'utf8');
25
- if (existing.includes('napi.h')) {
26
- // Already patched, check if build exists
27
- const buildPath = join(DART_DIR, 'build', 'Release', 'tree_sitter_dart_binding.node');
28
- if (existsSync(buildPath)) {
29
- console.log('tree-sitter-dart: already patched and built.');
30
- process.exit(0);
31
- }
32
- // Patched but not built, fall through to rebuild
33
- }
34
- } catch {
35
- // Can't read, continue with patch
36
- }
37
-
38
- console.log('Patching tree-sitter-dart for NAPI compatibility...');
39
-
40
- // Write NAPI-compatible binding.cc
41
- const bindingCC = `#include <napi.h>
42
-
43
- typedef struct TSLanguage TSLanguage;
44
-
45
- extern "C" TSLanguage *tree_sitter_dart();
46
-
47
- // "tree-sitter", "language" hashed with BLAKE2
48
- const napi_type_tag LANGUAGE_TYPE_TAG = {
49
- 0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
50
- };
51
-
52
- Napi::Object Init(Napi::Env env, Napi::Object exports) {
53
- exports["name"] = Napi::String::New(env, "dart");
54
- auto language = Napi::External<TSLanguage>::New(env, tree_sitter_dart());
55
- language.TypeTag(&LANGUAGE_TYPE_TAG);
56
- exports["language"] = language;
57
- return exports;
58
- }
59
-
60
- NODE_API_MODULE(tree_sitter_dart_binding, Init)
61
- `;
62
- writeFileSync(bindingPath, bindingCC);
63
-
64
- // Write NAPI-compatible binding.gyp
65
- const bindingGyp = `{
66
- "targets": [
67
- {
68
- "target_name": "tree_sitter_dart_binding",
69
- "dependencies": [
70
- "<!(node -p \\"require('node-addon-api').targets\\"):node_addon_api_except"
71
- ],
72
- "include_dirs": [
73
- "src"
74
- ],
75
- "sources": [
76
- "src/parser.c",
77
- "bindings/node/binding.cc",
78
- "src/scanner.c"
79
- ],
80
- "conditions": [
81
- ["OS!='win'", {
82
- "cflags_c": [
83
- "-std=c99"
84
- ]
85
- }, {
86
- "cflags_c": [
87
- "/std:c11",
88
- "/utf-8"
89
- ]
90
- }]
91
- ]
92
- }
93
- ]
94
- }
95
- `;
96
- writeFileSync(join(DART_DIR, 'binding.gyp'), bindingGyp);
97
-
98
- // Rebuild native module
99
- try {
100
- execSync('npx node-gyp rebuild', {
101
- cwd: DART_DIR,
102
- stdio: 'pipe',
103
- timeout: 120000,
104
- });
105
- console.log('tree-sitter-dart: patched and rebuilt successfully.');
106
- } catch (error) {
107
- console.error('Warning: Failed to rebuild tree-sitter-dart native module.');
108
- console.error('Dart language support may not work.');
109
- if (process.env.DEBUG) {
110
- console.error(error.stderr?.toString());
111
- }
112
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Patches tree-sitter-dart to use NAPI bindings compatible with tree-sitter 0.22+
4
+ *
5
+ * tree-sitter-dart v1.0.0 ships with NAN-style bindings that are incompatible
6
+ * with tree-sitter 0.22+ which expects NAPI-style bindings with type-tagged
7
+ * externals. This script rewrites the binding files and rebuilds.
8
+ */
9
+ const { writeFileSync, existsSync } = require('fs');
10
+ const { join } = require('path');
11
+ const { execSync } = require('child_process');
12
+
13
+ const DART_DIR = join(__dirname, '..', 'node_modules', 'tree-sitter-dart');
14
+
15
+ if (!existsSync(DART_DIR)) {
16
+ // tree-sitter-dart not installed, skip
17
+ process.exit(0);
18
+ }
19
+
20
+ // Check if already patched (look for NAPI-style binding)
21
+ const bindingPath = join(DART_DIR, 'bindings', 'node', 'binding.cc');
22
+ const { readFileSync } = require('fs');
23
+ try {
24
+ const existing = readFileSync(bindingPath, 'utf8');
25
+ if (existing.includes('napi.h')) {
26
+ // Already patched, check if build exists
27
+ const buildPath = join(DART_DIR, 'build', 'Release', 'tree_sitter_dart_binding.node');
28
+ if (existsSync(buildPath)) {
29
+ console.log('tree-sitter-dart: already patched and built.');
30
+ process.exit(0);
31
+ }
32
+ // Patched but not built, fall through to rebuild
33
+ }
34
+ } catch {
35
+ // Can't read, continue with patch
36
+ }
37
+
38
+ console.log('Patching tree-sitter-dart for NAPI compatibility...');
39
+
40
+ // Write NAPI-compatible binding.cc
41
+ const bindingCC = `#include <napi.h>
42
+
43
+ typedef struct TSLanguage TSLanguage;
44
+
45
+ extern "C" TSLanguage *tree_sitter_dart();
46
+
47
+ // "tree-sitter", "language" hashed with BLAKE2
48
+ const napi_type_tag LANGUAGE_TYPE_TAG = {
49
+ 0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
50
+ };
51
+
52
+ Napi::Object Init(Napi::Env env, Napi::Object exports) {
53
+ exports["name"] = Napi::String::New(env, "dart");
54
+ auto language = Napi::External<TSLanguage>::New(env, tree_sitter_dart());
55
+ language.TypeTag(&LANGUAGE_TYPE_TAG);
56
+ exports["language"] = language;
57
+ return exports;
58
+ }
59
+
60
+ NODE_API_MODULE(tree_sitter_dart_binding, Init)
61
+ `;
62
+ writeFileSync(bindingPath, bindingCC);
63
+
64
+ // Write NAPI-compatible binding.gyp
65
+ const bindingGyp = `{
66
+ "targets": [
67
+ {
68
+ "target_name": "tree_sitter_dart_binding",
69
+ "dependencies": [
70
+ "<!(node -p \\"require('node-addon-api').targets\\"):node_addon_api_except"
71
+ ],
72
+ "include_dirs": [
73
+ "src"
74
+ ],
75
+ "sources": [
76
+ "src/parser.c",
77
+ "bindings/node/binding.cc",
78
+ "src/scanner.c"
79
+ ],
80
+ "conditions": [
81
+ ["OS!='win'", {
82
+ "cflags_c": [
83
+ "-std=c99"
84
+ ]
85
+ }, {
86
+ "cflags_c": [
87
+ "/std:c11",
88
+ "/utf-8"
89
+ ]
90
+ }]
91
+ ]
92
+ }
93
+ ]
94
+ }
95
+ `;
96
+ writeFileSync(join(DART_DIR, 'binding.gyp'), bindingGyp);
97
+
98
+ // Rebuild native module
99
+ try {
100
+ execSync('npx node-gyp rebuild', {
101
+ cwd: DART_DIR,
102
+ stdio: 'pipe',
103
+ timeout: 120000,
104
+ });
105
+ console.log('tree-sitter-dart: patched and rebuilt successfully.');
106
+ } catch (error) {
107
+ console.error('Warning: Failed to rebuild tree-sitter-dart native module.');
108
+ console.error('Dart language support may not work.');
109
+ if (process.env.DEBUG) {
110
+ console.error(error.stderr?.toString());
111
+ }
112
+ }
@@ -1,68 +1,68 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Postinstall script - downloads the embedding model to ~/.codegraph/models
4
- * This runs after `npm install` or `npx @colbymchenry/codegraph`
5
- */
6
- const { existsSync, mkdirSync } = require('fs');
7
- const { join } = require('path');
8
- const { homedir } = require('os');
9
-
10
- const CODEGRAPH_DIR = join(homedir(), '.codegraph');
11
- const MODELS_DIR = join(CODEGRAPH_DIR, 'models');
12
- const MODEL_ID = 'nomic-ai/nomic-embed-text-v1.5';
13
-
14
- async function downloadModel() {
15
- // Ensure directories exist
16
- if (!existsSync(CODEGRAPH_DIR)) {
17
- mkdirSync(CODEGRAPH_DIR, { recursive: true });
18
- }
19
- if (!existsSync(MODELS_DIR)) {
20
- mkdirSync(MODELS_DIR, { recursive: true });
21
- }
22
-
23
- // Check if model is already cached
24
- const modelCachePath = join(MODELS_DIR, MODEL_ID.replace('/', '/'));
25
- if (existsSync(modelCachePath)) {
26
- console.log('Embedding model already downloaded.');
27
- return;
28
- }
29
-
30
- console.log('Downloading embedding model (~130MB)...');
31
- console.log('This is a one-time download for semantic code search.\n');
32
-
33
- try {
34
- // Dynamic import for @xenova/transformers (ESM-only package)
35
- const { pipeline, env } = await import('@xenova/transformers');
36
-
37
- // Configure cache directory
38
- env.cacheDir = MODELS_DIR;
39
-
40
- // Download with progress
41
- await pipeline('feature-extraction', MODEL_ID, {
42
- progress_callback: (progress) => {
43
- if (progress.status === 'progress' && progress.file && progress.progress !== undefined) {
44
- const fileName = progress.file.split('/').pop();
45
- const percent = Math.round(progress.progress);
46
- process.stdout.write(`\rDownloading ${fileName}... ${percent}% `);
47
- } else if (progress.status === 'done') {
48
- process.stdout.write('\n');
49
- }
50
- },
51
- });
52
-
53
- console.log('\nEmbedding model ready!');
54
- } catch (error) {
55
- // Don't fail the install if model download fails
56
- // User can still use codegraph without semantic search
57
- console.log('\nNote: Could not download embedding model.');
58
- console.log('Semantic search will download it on first use.');
59
- if (process.env.DEBUG) {
60
- console.error(error);
61
- }
62
- }
63
- }
64
-
65
- downloadModel().catch(() => {
66
- // Silent exit - don't break npm install
67
- process.exit(0);
68
- });
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Postinstall script - downloads the embedding model to ~/.codegraph/models
4
+ * This runs after `npm install` or `npx @colbymchenry/codegraph`
5
+ */
6
+ const { existsSync, mkdirSync } = require('fs');
7
+ const { join } = require('path');
8
+ const { homedir } = require('os');
9
+
10
+ const CODEGRAPH_DIR = join(homedir(), '.codegraph');
11
+ const MODELS_DIR = join(CODEGRAPH_DIR, 'models');
12
+ const MODEL_ID = 'nomic-ai/nomic-embed-text-v1.5';
13
+
14
+ async function downloadModel() {
15
+ // Ensure directories exist
16
+ if (!existsSync(CODEGRAPH_DIR)) {
17
+ mkdirSync(CODEGRAPH_DIR, { recursive: true });
18
+ }
19
+ if (!existsSync(MODELS_DIR)) {
20
+ mkdirSync(MODELS_DIR, { recursive: true });
21
+ }
22
+
23
+ // Check if model is already cached
24
+ const modelCachePath = join(MODELS_DIR, MODEL_ID.replace('/', '/'));
25
+ if (existsSync(modelCachePath)) {
26
+ console.log('Embedding model already downloaded.');
27
+ return;
28
+ }
29
+
30
+ console.log('Downloading embedding model (~130MB)...');
31
+ console.log('This is a one-time download for semantic code search.\n');
32
+
33
+ try {
34
+ // Dynamic import for @xenova/transformers (ESM-only package)
35
+ const { pipeline, env } = await import('@xenova/transformers');
36
+
37
+ // Configure cache directory
38
+ env.cacheDir = MODELS_DIR;
39
+
40
+ // Download with progress
41
+ await pipeline('feature-extraction', MODEL_ID, {
42
+ progress_callback: (progress) => {
43
+ if (progress.status === 'progress' && progress.file && progress.progress !== undefined) {
44
+ const fileName = progress.file.split('/').pop();
45
+ const percent = Math.round(progress.progress);
46
+ process.stdout.write(`\rDownloading ${fileName}... ${percent}% `);
47
+ } else if (progress.status === 'done') {
48
+ process.stdout.write('\n');
49
+ }
50
+ },
51
+ });
52
+
53
+ console.log('\nEmbedding model ready!');
54
+ } catch (error) {
55
+ // Don't fail the install if model download fails
56
+ // User can still use codegraph without semantic search
57
+ console.log('\nNote: Could not download embedding model.');
58
+ console.log('Semantic search will download it on first use.');
59
+ if (process.env.DEBUG) {
60
+ console.error(error);
61
+ }
62
+ }
63
+ }
64
+
65
+ downloadModel().catch(() => {
66
+ // Silent exit - don't break npm install
67
+ process.exit(0);
68
+ });