@mduenas/codegraph 0.4.0
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/LICENSE +21 -0
- package/README.md +641 -0
- package/dist/bin/codegraph.d.ts +20 -0
- package/dist/bin/codegraph.d.ts.map +1 -0
- package/dist/bin/codegraph.js +704 -0
- package/dist/bin/codegraph.js.map +1 -0
- package/dist/config.d.ts +51 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +291 -0
- package/dist/config.js.map +1 -0
- package/dist/context/formatter.d.ts +30 -0
- package/dist/context/formatter.d.ts.map +1 -0
- package/dist/context/formatter.js +244 -0
- package/dist/context/formatter.js.map +1 -0
- package/dist/context/index.d.ts +86 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +402 -0
- package/dist/context/index.js.map +1 -0
- package/dist/db/index.d.ts +64 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +170 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrations.d.ts +44 -0
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +105 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/queries.d.ts +148 -0
- package/dist/db/queries.d.ts.map +1 -0
- package/dist/db/queries.js +669 -0
- package/dist/db/queries.js.map +1 -0
- package/dist/directory.d.ts +45 -0
- package/dist/directory.d.ts.map +1 -0
- package/dist/directory.js +191 -0
- package/dist/directory.js.map +1 -0
- package/dist/errors.d.ts +136 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +219 -0
- package/dist/errors.js.map +1 -0
- package/dist/extraction/grammars.d.ts +36 -0
- package/dist/extraction/grammars.d.ts.map +1 -0
- package/dist/extraction/grammars.js +181 -0
- package/dist/extraction/grammars.js.map +1 -0
- package/dist/extraction/index.d.ts +91 -0
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/index.js +493 -0
- package/dist/extraction/index.js.map +1 -0
- package/dist/extraction/tree-sitter.d.ts +176 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -0
- package/dist/extraction/tree-sitter.js +1798 -0
- package/dist/extraction/tree-sitter.js.map +1 -0
- package/dist/graph/index.d.ts +8 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +13 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/queries.d.ts +106 -0
- package/dist/graph/queries.d.ts.map +1 -0
- package/dist/graph/queries.js +355 -0
- package/dist/graph/queries.js.map +1 -0
- package/dist/graph/traversal.d.ts +127 -0
- package/dist/graph/traversal.d.ts.map +1 -0
- package/dist/graph/traversal.js +465 -0
- package/dist/graph/traversal.js.map +1 -0
- package/dist/index.d.ts +496 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +818 -0
- package/dist/index.js.map +1 -0
- package/dist/installer/banner.d.ts +40 -0
- package/dist/installer/banner.d.ts.map +1 -0
- package/dist/installer/banner.js +162 -0
- package/dist/installer/banner.js.map +1 -0
- package/dist/installer/claude-md-template.d.ts +10 -0
- package/dist/installer/claude-md-template.d.ts.map +1 -0
- package/dist/installer/claude-md-template.js +46 -0
- package/dist/installer/claude-md-template.js.map +1 -0
- package/dist/installer/config-writer.d.ts +36 -0
- package/dist/installer/config-writer.d.ts.map +1 -0
- package/dist/installer/config-writer.js +282 -0
- package/dist/installer/config-writer.js.map +1 -0
- package/dist/installer/index.d.ts +13 -0
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +155 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/installer/prompts.d.ts +18 -0
- package/dist/installer/prompts.d.ts.map +1 -0
- package/dist/installer/prompts.js +113 -0
- package/dist/installer/prompts.js.map +1 -0
- package/dist/mcp/index.d.ts +64 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +207 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/tools.d.ts +93 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +442 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/transport.d.ts +89 -0
- package/dist/mcp/transport.d.ts.map +1 -0
- package/dist/mcp/transport.js +170 -0
- package/dist/mcp/transport.js.map +1 -0
- package/dist/resolution/frameworks/csharp.d.ts +8 -0
- package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
- package/dist/resolution/frameworks/csharp.js +274 -0
- package/dist/resolution/frameworks/csharp.js.map +1 -0
- package/dist/resolution/frameworks/express.d.ts +8 -0
- package/dist/resolution/frameworks/express.d.ts.map +1 -0
- package/dist/resolution/frameworks/express.js +208 -0
- package/dist/resolution/frameworks/express.js.map +1 -0
- package/dist/resolution/frameworks/go.d.ts +8 -0
- package/dist/resolution/frameworks/go.d.ts.map +1 -0
- package/dist/resolution/frameworks/go.js +225 -0
- package/dist/resolution/frameworks/go.js.map +1 -0
- package/dist/resolution/frameworks/index.d.ts +33 -0
- package/dist/resolution/frameworks/index.d.ts.map +1 -0
- package/dist/resolution/frameworks/index.js +113 -0
- package/dist/resolution/frameworks/index.js.map +1 -0
- package/dist/resolution/frameworks/java.d.ts +8 -0
- package/dist/resolution/frameworks/java.d.ts.map +1 -0
- package/dist/resolution/frameworks/java.js +239 -0
- package/dist/resolution/frameworks/java.js.map +1 -0
- package/dist/resolution/frameworks/laravel.d.ts +13 -0
- package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
- package/dist/resolution/frameworks/laravel.js +198 -0
- package/dist/resolution/frameworks/laravel.js.map +1 -0
- package/dist/resolution/frameworks/python.d.ts +10 -0
- package/dist/resolution/frameworks/python.d.ts.map +1 -0
- package/dist/resolution/frameworks/python.js +331 -0
- package/dist/resolution/frameworks/python.js.map +1 -0
- package/dist/resolution/frameworks/react.d.ts +8 -0
- package/dist/resolution/frameworks/react.d.ts.map +1 -0
- package/dist/resolution/frameworks/react.js +294 -0
- package/dist/resolution/frameworks/react.js.map +1 -0
- package/dist/resolution/frameworks/ruby.d.ts +8 -0
- package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
- package/dist/resolution/frameworks/ruby.js +262 -0
- package/dist/resolution/frameworks/ruby.js.map +1 -0
- package/dist/resolution/frameworks/rust.d.ts +8 -0
- package/dist/resolution/frameworks/rust.d.ts.map +1 -0
- package/dist/resolution/frameworks/rust.js +222 -0
- package/dist/resolution/frameworks/rust.js.map +1 -0
- package/dist/resolution/frameworks/swift.d.ts +10 -0
- package/dist/resolution/frameworks/swift.d.ts.map +1 -0
- package/dist/resolution/frameworks/swift.js +486 -0
- package/dist/resolution/frameworks/swift.js.map +1 -0
- package/dist/resolution/import-resolver.d.ts +20 -0
- package/dist/resolution/import-resolver.d.ts.map +1 -0
- package/dist/resolution/import-resolver.js +445 -0
- package/dist/resolution/import-resolver.js.map +1 -0
- package/dist/resolution/index.d.ts +72 -0
- package/dist/resolution/index.d.ts.map +1 -0
- package/dist/resolution/index.js +301 -0
- package/dist/resolution/index.js.map +1 -0
- package/dist/resolution/name-matcher.d.ts +27 -0
- package/dist/resolution/name-matcher.d.ts.map +1 -0
- package/dist/resolution/name-matcher.js +210 -0
- package/dist/resolution/name-matcher.js.map +1 -0
- package/dist/resolution/types.d.ts +108 -0
- package/dist/resolution/types.d.ts.map +1 -0
- package/dist/resolution/types.js +8 -0
- package/dist/resolution/types.js.map +1 -0
- package/dist/sync/git-hooks.d.ts +66 -0
- package/dist/sync/git-hooks.d.ts.map +1 -0
- package/dist/sync/git-hooks.js +281 -0
- package/dist/sync/git-hooks.js.map +1 -0
- package/dist/sync/index.d.ts +13 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +18 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/types.d.ts +410 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +165 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +116 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +295 -0
- package/dist/utils.js.map +1 -0
- package/dist/vectors/embedder.d.ts +140 -0
- package/dist/vectors/embedder.d.ts.map +1 -0
- package/dist/vectors/embedder.js +336 -0
- package/dist/vectors/embedder.js.map +1 -0
- package/dist/vectors/index.d.ts +9 -0
- package/dist/vectors/index.d.ts.map +1 -0
- package/dist/vectors/index.js +20 -0
- package/dist/vectors/index.js.map +1 -0
- package/dist/vectors/manager.d.ts +119 -0
- package/dist/vectors/manager.d.ts.map +1 -0
- package/dist/vectors/manager.js +274 -0
- package/dist/vectors/manager.js.map +1 -0
- package/dist/vectors/search.d.ts +134 -0
- package/dist/vectors/search.d.ts.map +1 -0
- package/dist/vectors/search.js +409 -0
- package/dist/vectors/search.js.map +1 -0
- package/package.json +67 -0
- package/scripts/postinstall.js +68 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/resolution/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,281 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-hooks.js","sourceRoot":"","sources":["../../src/sync/git-hooks.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqRH,sDAEC;AArRD,uCAAyB;AACzB,2CAA6B;AAE7B;;GAEG;AACH,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAEvC;;GAEG;AACH,MAAM,gBAAgB,GAAG,4BAA4B,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG;EACzB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;CAsBjB,CAAC;AAsBF;;GAEG;AACH,MAAa,eAAe;IAClB,MAAM,CAAS;IACf,QAAQ,CAAS;IAEzB,YAAY,WAAmB;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9E,CAAC;IAED;;OAEG;IACH,eAAe;QACb,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAE5D,IAAI,CAAC,EAAE,CAAC,UAAU,CAA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ACJ,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,2BAA2B;SACrC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IACpD,CAAC;CACF;AAzMD,0CAyMC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CAAC,WAAmB;IACvD,OAAO,IAAI,eAAe,CAAC,WAAW,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync Module
|
|
3
|
+
*
|
|
4
|
+
* Provides synchronization functionality for keeping the code graph
|
|
5
|
+
* up-to-date with file system changes.
|
|
6
|
+
*
|
|
7
|
+
* Components:
|
|
8
|
+
* - Git hooks for automatic post-commit syncing
|
|
9
|
+
* - Content hashing for change detection (in extraction module)
|
|
10
|
+
* - Incremental reindexing (in extraction module)
|
|
11
|
+
*/
|
|
12
|
+
export { GitHooksManager, createGitHooksManager, HookInstallResult, HookRemoveResult, } from './git-hooks';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Sync Module
|
|
4
|
+
*
|
|
5
|
+
* Provides synchronization functionality for keeping the code graph
|
|
6
|
+
* up-to-date with file system changes.
|
|
7
|
+
*
|
|
8
|
+
* Components:
|
|
9
|
+
* - Git hooks for automatic post-commit syncing
|
|
10
|
+
* - Content hashing for change detection (in extraction module)
|
|
11
|
+
* - Incremental reindexing (in extraction module)
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.createGitHooksManager = exports.GitHooksManager = void 0;
|
|
15
|
+
var git_hooks_1 = require("./git-hooks");
|
|
16
|
+
Object.defineProperty(exports, "GitHooksManager", { enumerable: true, get: function () { return git_hooks_1.GitHooksManager; } });
|
|
17
|
+
Object.defineProperty(exports, "createGitHooksManager", { enumerable: true, get: function () { return git_hooks_1.createGitHooksManager; } });
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,yCAKqB;AAJnB,4GAAA,eAAe,OAAA;AACf,kHAAA,qBAAqB,OAAA"}
|