@colbymchenry/codegraph 0.2.9 → 0.4.8

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.

Potentially problematic release.


This version of @colbymchenry/codegraph might be problematic. Click here for more details.

Files changed (113) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +647 -641
  3. package/dist/bin/codegraph.d.ts +7 -2
  4. package/dist/bin/codegraph.d.ts.map +1 -1
  5. package/dist/bin/codegraph.js +360 -140
  6. package/dist/bin/codegraph.js.map +1 -1
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +8 -1
  9. package/dist/config.js.map +1 -1
  10. package/dist/context/index.d.ts +17 -4
  11. package/dist/context/index.d.ts.map +1 -1
  12. package/dist/context/index.js +182 -15
  13. package/dist/context/index.js.map +1 -1
  14. package/dist/db/index.d.ts.map +1 -1
  15. package/dist/db/index.js +16 -0
  16. package/dist/db/index.js.map +1 -1
  17. package/dist/db/migrations.d.ts +1 -1
  18. package/dist/db/migrations.d.ts.map +1 -1
  19. package/dist/db/migrations.js +11 -12
  20. package/dist/db/migrations.js.map +1 -1
  21. package/dist/db/queries.d.ts +19 -0
  22. package/dist/db/queries.d.ts.map +1 -1
  23. package/dist/db/queries.js +221 -107
  24. package/dist/db/queries.js.map +1 -1
  25. package/dist/db/schema.sql +154 -149
  26. package/dist/directory.d.ts +13 -1
  27. package/dist/directory.d.ts.map +1 -1
  28. package/dist/directory.js +62 -19
  29. package/dist/directory.js.map +1 -1
  30. package/dist/errors.d.ts +1 -1
  31. package/dist/errors.d.ts.map +1 -1
  32. package/dist/errors.js +7 -1
  33. package/dist/errors.js.map +1 -1
  34. package/dist/extraction/grammars.d.ts +9 -4
  35. package/dist/extraction/grammars.d.ts.map +1 -1
  36. package/dist/extraction/grammars.js +133 -65
  37. package/dist/extraction/grammars.js.map +1 -1
  38. package/dist/extraction/index.d.ts.map +1 -1
  39. package/dist/extraction/index.js +119 -7
  40. package/dist/extraction/index.js.map +1 -1
  41. package/dist/extraction/tree-sitter.d.ts +62 -0
  42. package/dist/extraction/tree-sitter.d.ts.map +1 -1
  43. package/dist/extraction/tree-sitter.js +937 -34
  44. package/dist/extraction/tree-sitter.js.map +1 -1
  45. package/dist/graph/traversal.d.ts.map +1 -1
  46. package/dist/graph/traversal.js +6 -2
  47. package/dist/graph/traversal.js.map +1 -1
  48. package/dist/index.d.ts +6 -38
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +85 -74
  51. package/dist/index.js.map +1 -1
  52. package/dist/installer/banner.js +7 -7
  53. package/dist/installer/claude-md-template.js +32 -32
  54. package/dist/installer/config-writer.d.ts +9 -0
  55. package/dist/installer/config-writer.d.ts.map +1 -1
  56. package/dist/installer/config-writer.js +78 -0
  57. package/dist/installer/config-writer.js.map +1 -1
  58. package/dist/installer/index.d.ts.map +1 -1
  59. package/dist/installer/index.js +28 -16
  60. package/dist/installer/index.js.map +1 -1
  61. package/dist/mcp/index.d.ts +14 -3
  62. package/dist/mcp/index.d.ts.map +1 -1
  63. package/dist/mcp/index.js +109 -29
  64. package/dist/mcp/index.js.map +1 -1
  65. package/dist/mcp/tools.d.ts +62 -1
  66. package/dist/mcp/tools.d.ts.map +1 -1
  67. package/dist/mcp/tools.js +414 -43
  68. package/dist/mcp/tools.js.map +1 -1
  69. package/dist/mcp/transport.d.ts.map +1 -1
  70. package/dist/mcp/transport.js +2 -0
  71. package/dist/mcp/transport.js.map +1 -1
  72. package/dist/resolution/frameworks/index.d.ts +1 -0
  73. package/dist/resolution/frameworks/index.d.ts.map +1 -1
  74. package/dist/resolution/frameworks/index.js +5 -1
  75. package/dist/resolution/frameworks/index.js.map +1 -1
  76. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  77. package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  78. package/dist/resolution/frameworks/svelte.js +268 -0
  79. package/dist/resolution/frameworks/svelte.js.map +1 -0
  80. package/dist/resolution/index.d.ts +11 -2
  81. package/dist/resolution/index.d.ts.map +1 -1
  82. package/dist/resolution/index.js +94 -13
  83. package/dist/resolution/index.js.map +1 -1
  84. package/dist/sentry.d.ts +22 -0
  85. package/dist/sentry.d.ts.map +1 -0
  86. package/dist/sentry.js +159 -0
  87. package/dist/sentry.js.map +1 -0
  88. package/dist/sync/index.d.ts +4 -2
  89. package/dist/sync/index.d.ts.map +1 -1
  90. package/dist/sync/index.js +3 -5
  91. package/dist/sync/index.js.map +1 -1
  92. package/dist/types.d.ts +5 -1
  93. package/dist/types.d.ts.map +1 -1
  94. package/dist/types.js +11 -0
  95. package/dist/types.js.map +1 -1
  96. package/dist/utils.d.ts +45 -2
  97. package/dist/utils.d.ts.map +1 -1
  98. package/dist/utils.js +114 -3
  99. package/dist/utils.js.map +1 -1
  100. package/dist/vectors/embedder.d.ts +1 -1
  101. package/dist/vectors/embedder.d.ts.map +1 -1
  102. package/dist/vectors/embedder.js +5 -2
  103. package/dist/vectors/embedder.js.map +1 -1
  104. package/dist/vectors/search.d.ts.map +1 -1
  105. package/dist/vectors/search.js +33 -32
  106. package/dist/vectors/search.js.map +1 -1
  107. package/package.json +72 -65
  108. package/scripts/patch-tree-sitter-dart.js +112 -0
  109. package/scripts/postinstall.js +71 -0
  110. package/dist/sync/git-hooks.d.ts +0 -66
  111. package/dist/sync/git-hooks.d.ts.map +0 -1
  112. package/dist/sync/git-hooks.js +0 -281
  113. package/dist/sync/git-hooks.js.map +0 -1
@@ -0,0 +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
+ }
@@ -0,0 +1,71 @@
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
+ // @sengac/tree-sitter-dart ships with NAPI prebuilds for all platforms
66
+ // No patching needed (replaced old tree-sitter-dart v1.0.0 which used NAN bindings)
67
+
68
+ downloadModel().catch(() => {
69
+ // Silent exit - don't break npm install
70
+ process.exit(0);
71
+ });
@@ -1,66 +0,0 @@
1
- /**
2
- * Git Hooks Management
3
- *
4
- * Installs and manages git hooks for automatic incremental indexing.
5
- */
6
- /**
7
- * Result of hook installation
8
- */
9
- export interface HookInstallResult {
10
- success: boolean;
11
- hookPath: string;
12
- message: string;
13
- previousHookBackedUp?: boolean;
14
- backupPath?: string;
15
- }
16
- /**
17
- * Result of hook removal
18
- */
19
- export interface HookRemoveResult {
20
- success: boolean;
21
- message: string;
22
- restoredFromBackup?: boolean;
23
- }
24
- /**
25
- * Git hooks manager
26
- */
27
- export declare class GitHooksManager {
28
- private gitDir;
29
- private hooksDir;
30
- constructor(projectRoot: string);
31
- /**
32
- * Check if the project is a git repository
33
- */
34
- isGitRepository(): boolean;
35
- /**
36
- * Check if the post-commit hook is installed by CodeGraph
37
- */
38
- isHookInstalled(): boolean;
39
- /**
40
- * Install the post-commit hook
41
- *
42
- * If a hook already exists:
43
- * - If it's a CodeGraph hook, update it
44
- * - If it's a user hook, back it up and install ours
45
- */
46
- installHook(): HookInstallResult;
47
- /**
48
- * Remove the CodeGraph post-commit hook
49
- *
50
- * If a backup exists, restore it.
51
- */
52
- removeHook(): HookRemoveResult;
53
- /**
54
- * Get the path to the hooks directory
55
- */
56
- getHooksDir(): string;
57
- /**
58
- * Get the path to the post-commit hook
59
- */
60
- getHookPath(): string;
61
- }
62
- /**
63
- * Create a git hooks manager for a project
64
- */
65
- export declare function createGitHooksManager(projectRoot: string): GitHooksManager;
66
- //# sourceMappingURL=git-hooks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git-hooks.d.ts","sourceRoot":"","sources":["../../src/sync/git-hooks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgDH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAS;gBAEb,WAAW,EAAE,MAAM;IAK/B;;OAEG;IACH,eAAe,IAAI,OAAO;IAI1B;;OAEG;IACH,eAAe,IAAI,OAAO;IAe1B;;;;;;OAMG;IACH,WAAW,IAAI,iBAAiB;IAgFhC;;;;OAIG;IACH,UAAU,IAAI,gBAAgB;IA8D9B;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;OAEG;IACH,WAAW,IAAI,MAAM;CAGtB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,eAAe,CAE1E"}
@@ -1,281 +0,0 @@
1
- "use strict";
2
- /**
3
- * Git Hooks Management
4
- *
5
- * Installs and manages git hooks for automatic incremental indexing.
6
- */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || (function () {
24
- var ownKeys = function(o) {
25
- ownKeys = Object.getOwnPropertyNames || function (o) {
26
- var ar = [];
27
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
- return ar;
29
- };
30
- return ownKeys(o);
31
- };
32
- return function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- })();
40
- Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.GitHooksManager = void 0;
42
- exports.createGitHooksManager = createGitHooksManager;
43
- const fs = __importStar(require("fs"));
44
- const path = __importStar(require("path"));
45
- /**
46
- * Name of the post-commit hook file
47
- */
48
- const POST_COMMIT_HOOK = 'post-commit';
49
- /**
50
- * Marker comment to identify CodeGraph-managed hooks
51
- */
52
- const CODEGRAPH_MARKER = '# CodeGraph auto-sync hook';
53
- /**
54
- * The post-commit hook script content
55
- *
56
- * This script:
57
- * 1. Checks if codegraph CLI is available
58
- * 2. Falls back to npx if not
59
- * 3. Runs sync in the background to avoid blocking commits
60
- */
61
- const POST_COMMIT_SCRIPT = `#!/bin/sh
62
- ${CODEGRAPH_MARKER}
63
- # This hook was installed by CodeGraph to enable automatic incremental indexing.
64
- # It runs after each commit to keep the code graph in sync.
65
- # To remove this hook, run: codegraph hooks --remove
66
- # Or delete this file manually.
67
-
68
- # Run sync in background to avoid blocking the commit
69
- (
70
- # Check if we're in a CodeGraph project
71
- if [ ! -d ".codegraph" ]; then
72
- exit 0
73
- fi
74
-
75
- # Try to run codegraph sync
76
- if command -v codegraph >/dev/null 2>&1; then
77
- codegraph sync --quiet 2>/dev/null &
78
- elif command -v npx >/dev/null 2>&1; then
79
- npx codegraph sync --quiet 2>/dev/null &
80
- fi
81
- ) &
82
-
83
- exit 0
84
- `;
85
- /**
86
- * Git hooks manager
87
- */
88
- class GitHooksManager {
89
- gitDir;
90
- hooksDir;
91
- constructor(projectRoot) {
92
- this.gitDir = path.join(projectRoot, '.git');
93
- this.hooksDir = path.join(this.gitDir, 'hooks');
94
- }
95
- /**
96
- * Check if the project is a git repository
97
- */
98
- isGitRepository() {
99
- return fs.existsSync(this.gitDir) && fs.statSync(this.gitDir).isDirectory();
100
- }
101
- /**
102
- * Check if the post-commit hook is installed by CodeGraph
103
- */
104
- isHookInstalled() {
105
- const hookPath = path.join(this.hooksDir, POST_COMMIT_HOOK);
106
- if (!fs.existsSync(hookPath)) {
107
- return false;
108
- }
109
- try {
110
- const content = fs.readFileSync(hookPath, 'utf-8');
111
- return content.includes(CODEGRAPH_MARKER);
112
- }
113
- catch {
114
- return false;
115
- }
116
- }
117
- /**
118
- * Install the post-commit hook
119
- *
120
- * If a hook already exists:
121
- * - If it's a CodeGraph hook, update it
122
- * - If it's a user hook, back it up and install ours
123
- */
124
- installHook() {
125
- const hookPath = path.join(this.hooksDir, POST_COMMIT_HOOK);
126
- // Check if this is a git repository
127
- if (!this.isGitRepository()) {
128
- return {
129
- success: false,
130
- hookPath,
131
- message: 'Not a git repository. Initialize git first with: git init',
132
- };
133
- }
134
- // Ensure hooks directory exists
135
- if (!fs.existsSync(this.hooksDir)) {
136
- try {
137
- fs.mkdirSync(this.hooksDir, { recursive: true });
138
- }
139
- catch (error) {
140
- return {
141
- success: false,
142
- hookPath,
143
- message: `Failed to create hooks directory: ${error}`,
144
- };
145
- }
146
- }
147
- // Check for existing hook
148
- let previousHookBackedUp = false;
149
- let backupPath;
150
- if (fs.existsSync(hookPath)) {
151
- try {
152
- const existingContent = fs.readFileSync(hookPath, 'utf-8');
153
- // If it's already our hook, just update it
154
- if (existingContent.includes(CODEGRAPH_MARKER)) {
155
- fs.writeFileSync(hookPath, POST_COMMIT_SCRIPT, { mode: 0o755 });
156
- return {
157
- success: true,
158
- hookPath,
159
- message: 'Post-commit hook updated.',
160
- };
161
- }
162
- // It's a user hook - back it up
163
- backupPath = `${hookPath}.codegraph-backup`;
164
- fs.copyFileSync(hookPath, backupPath);
165
- previousHookBackedUp = true;
166
- }
167
- catch (error) {
168
- return {
169
- success: false,
170
- hookPath,
171
- message: `Failed to backup existing hook: ${error}`,
172
- };
173
- }
174
- }
175
- // Write the hook
176
- try {
177
- fs.writeFileSync(hookPath, POST_COMMIT_SCRIPT, { mode: 0o755 });
178
- }
179
- catch (error) {
180
- return {
181
- success: false,
182
- hookPath,
183
- message: `Failed to write hook: ${error}`,
184
- };
185
- }
186
- const message = previousHookBackedUp
187
- ? `Post-commit hook installed. Previous hook backed up to: ${backupPath}`
188
- : 'Post-commit hook installed.';
189
- return {
190
- success: true,
191
- hookPath,
192
- message,
193
- previousHookBackedUp,
194
- backupPath,
195
- };
196
- }
197
- /**
198
- * Remove the CodeGraph post-commit hook
199
- *
200
- * If a backup exists, restore it.
201
- */
202
- removeHook() {
203
- const hookPath = path.join(this.hooksDir, POST_COMMIT_HOOK);
204
- const backupPath = `${hookPath}.codegraph-backup`;
205
- // Check if hook exists
206
- if (!fs.existsSync(hookPath)) {
207
- return {
208
- success: true,
209
- message: 'No post-commit hook found.',
210
- };
211
- }
212
- // Check if it's our hook
213
- try {
214
- const content = fs.readFileSync(hookPath, 'utf-8');
215
- if (!content.includes(CODEGRAPH_MARKER)) {
216
- return {
217
- success: false,
218
- message: 'Post-commit hook was not installed by CodeGraph. Not removing.',
219
- };
220
- }
221
- }
222
- catch (error) {
223
- return {
224
- success: false,
225
- message: `Failed to read hook: ${error}`,
226
- };
227
- }
228
- // Remove the hook
229
- try {
230
- fs.unlinkSync(hookPath);
231
- }
232
- catch (error) {
233
- return {
234
- success: false,
235
- message: `Failed to remove hook: ${error}`,
236
- };
237
- }
238
- // Restore backup if it exists
239
- if (fs.existsSync(backupPath)) {
240
- try {
241
- fs.renameSync(backupPath, hookPath);
242
- return {
243
- success: true,
244
- message: 'Post-commit hook removed. Previous hook restored from backup.',
245
- restoredFromBackup: true,
246
- };
247
- }
248
- catch (error) {
249
- return {
250
- success: true,
251
- message: `Post-commit hook removed. Warning: failed to restore backup: ${error}`,
252
- restoredFromBackup: false,
253
- };
254
- }
255
- }
256
- return {
257
- success: true,
258
- message: 'Post-commit hook removed.',
259
- };
260
- }
261
- /**
262
- * Get the path to the hooks directory
263
- */
264
- getHooksDir() {
265
- return this.hooksDir;
266
- }
267
- /**
268
- * Get the path to the post-commit hook
269
- */
270
- getHookPath() {
271
- return path.join(this.hooksDir, POST_COMMIT_HOOK);
272
- }
273
- }
274
- exports.GitHooksManager = GitHooksManager;
275
- /**
276
- * Create a git hooks manager for a project
277
- */
278
- function createGitHooksManager(projectRoot) {
279
- return new GitHooksManager(projectRoot);
280
- }
281
- //# sourceMappingURL=git-hooks.js.map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