@liendev/core 0.19.5
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 +336 -0
- package/dist/config/loader.d.ts +12 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +46 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/merge.d.ts +20 -0
- package/dist/config/merge.d.ts.map +1 -0
- package/dist/config/merge.js +71 -0
- package/dist/config/merge.js.map +1 -0
- package/dist/config/migration-manager.d.ts +46 -0
- package/dist/config/migration-manager.d.ts.map +1 -0
- package/dist/config/migration-manager.js +119 -0
- package/dist/config/migration-manager.js.map +1 -0
- package/dist/config/migration.d.ts +20 -0
- package/dist/config/migration.d.ts.map +1 -0
- package/dist/config/migration.js +155 -0
- package/dist/config/migration.js.map +1 -0
- package/dist/config/schema.d.ts +101 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +58 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/service.d.ts +122 -0
- package/dist/config/service.d.ts.map +1 -0
- package/dist/config/service.js +477 -0
- package/dist/config/service.js.map +1 -0
- package/dist/constants.d.ts +20 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +43 -0
- package/dist/constants.js.map +1 -0
- package/dist/embeddings/cache.d.ts +45 -0
- package/dist/embeddings/cache.d.ts.map +1 -0
- package/dist/embeddings/cache.js +109 -0
- package/dist/embeddings/cache.js.map +1 -0
- package/dist/embeddings/local.d.ts +10 -0
- package/dist/embeddings/local.d.ts.map +1 -0
- package/dist/embeddings/local.js +63 -0
- package/dist/embeddings/local.js.map +1 -0
- package/dist/embeddings/types.d.ts +9 -0
- package/dist/embeddings/types.d.ts.map +1 -0
- package/dist/embeddings/types.js +5 -0
- package/dist/embeddings/types.js.map +1 -0
- package/dist/errors/codes.d.ts +18 -0
- package/dist/errors/codes.d.ts.map +1 -0
- package/dist/errors/codes.js +25 -0
- package/dist/errors/codes.js.map +1 -0
- package/dist/errors/index.d.ts +85 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +134 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/frameworks/detector-service.d.ts +59 -0
- package/dist/frameworks/detector-service.d.ts.map +1 -0
- package/dist/frameworks/detector-service.js +219 -0
- package/dist/frameworks/detector-service.js.map +1 -0
- package/dist/frameworks/laravel/config.d.ts +6 -0
- package/dist/frameworks/laravel/config.d.ts.map +1 -0
- package/dist/frameworks/laravel/config.js +68 -0
- package/dist/frameworks/laravel/config.js.map +1 -0
- package/dist/frameworks/laravel/detector.d.ts +6 -0
- package/dist/frameworks/laravel/detector.d.ts.map +1 -0
- package/dist/frameworks/laravel/detector.js +96 -0
- package/dist/frameworks/laravel/detector.js.map +1 -0
- package/dist/frameworks/nodejs/config.d.ts +6 -0
- package/dist/frameworks/nodejs/config.d.ts.map +1 -0
- package/dist/frameworks/nodejs/config.js +57 -0
- package/dist/frameworks/nodejs/config.js.map +1 -0
- package/dist/frameworks/nodejs/detector.d.ts +6 -0
- package/dist/frameworks/nodejs/detector.d.ts.map +1 -0
- package/dist/frameworks/nodejs/detector.js +77 -0
- package/dist/frameworks/nodejs/detector.js.map +1 -0
- package/dist/frameworks/php/config.d.ts +6 -0
- package/dist/frameworks/php/config.d.ts.map +1 -0
- package/dist/frameworks/php/config.js +53 -0
- package/dist/frameworks/php/config.js.map +1 -0
- package/dist/frameworks/php/detector.d.ts +7 -0
- package/dist/frameworks/php/detector.d.ts.map +1 -0
- package/dist/frameworks/php/detector.js +101 -0
- package/dist/frameworks/php/detector.js.map +1 -0
- package/dist/frameworks/registry.d.ts +20 -0
- package/dist/frameworks/registry.d.ts.map +1 -0
- package/dist/frameworks/registry.js +38 -0
- package/dist/frameworks/registry.js.map +1 -0
- package/dist/frameworks/shopify/config.d.ts +6 -0
- package/dist/frameworks/shopify/config.d.ts.map +1 -0
- package/dist/frameworks/shopify/config.js +50 -0
- package/dist/frameworks/shopify/config.js.map +1 -0
- package/dist/frameworks/shopify/detector.d.ts +6 -0
- package/dist/frameworks/shopify/detector.d.ts.map +1 -0
- package/dist/frameworks/shopify/detector.js +103 -0
- package/dist/frameworks/shopify/detector.js.map +1 -0
- package/dist/frameworks/types.d.ts +51 -0
- package/dist/frameworks/types.d.ts.map +1 -0
- package/dist/frameworks/types.js +21 -0
- package/dist/frameworks/types.js.map +1 -0
- package/dist/git/tracker.d.ts +56 -0
- package/dist/git/tracker.d.ts.map +1 -0
- package/dist/git/tracker.js +189 -0
- package/dist/git/tracker.js.map +1 -0
- package/dist/git/utils.d.ts +60 -0
- package/dist/git/utils.d.ts.map +1 -0
- package/dist/git/utils.js +152 -0
- package/dist/git/utils.js.map +1 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer/ast/chunker.d.ts +28 -0
- package/dist/indexer/ast/chunker.d.ts.map +1 -0
- package/dist/indexer/ast/chunker.js +268 -0
- package/dist/indexer/ast/chunker.js.map +1 -0
- package/dist/indexer/ast/complexity/cognitive.d.ts +16 -0
- package/dist/indexer/ast/complexity/cognitive.d.ts.map +1 -0
- package/dist/indexer/ast/complexity/cognitive.js +106 -0
- package/dist/indexer/ast/complexity/cognitive.js.map +1 -0
- package/dist/indexer/ast/complexity/cyclomatic.d.ts +12 -0
- package/dist/indexer/ast/complexity/cyclomatic.d.ts.map +1 -0
- package/dist/indexer/ast/complexity/cyclomatic.js +61 -0
- package/dist/indexer/ast/complexity/cyclomatic.js.map +1 -0
- package/dist/indexer/ast/complexity/halstead.d.ts +55 -0
- package/dist/indexer/ast/complexity/halstead.d.ts.map +1 -0
- package/dist/indexer/ast/complexity/halstead.js +290 -0
- package/dist/indexer/ast/complexity/halstead.js.map +1 -0
- package/dist/indexer/ast/complexity/index.d.ts +13 -0
- package/dist/indexer/ast/complexity/index.d.ts.map +1 -0
- package/dist/indexer/ast/complexity/index.js +12 -0
- package/dist/indexer/ast/complexity/index.js.map +1 -0
- package/dist/indexer/ast/parser.d.ts +27 -0
- package/dist/indexer/ast/parser.d.ts.map +1 -0
- package/dist/indexer/ast/parser.js +103 -0
- package/dist/indexer/ast/parser.js.map +1 -0
- package/dist/indexer/ast/symbols.d.ts +17 -0
- package/dist/indexer/ast/symbols.d.ts.map +1 -0
- package/dist/indexer/ast/symbols.js +265 -0
- package/dist/indexer/ast/symbols.js.map +1 -0
- package/dist/indexer/ast/traversers/index.d.ts +19 -0
- package/dist/indexer/ast/traversers/index.d.ts.map +1 -0
- package/dist/indexer/ast/traversers/index.js +42 -0
- package/dist/indexer/ast/traversers/index.js.map +1 -0
- package/dist/indexer/ast/traversers/php.d.ts +21 -0
- package/dist/indexer/ast/traversers/php.d.ts.map +1 -0
- package/dist/indexer/ast/traversers/php.js +67 -0
- package/dist/indexer/ast/traversers/php.js.map +1 -0
- package/dist/indexer/ast/traversers/python.d.ts +28 -0
- package/dist/indexer/ast/traversers/python.d.ts.map +1 -0
- package/dist/indexer/ast/traversers/python.js +67 -0
- package/dist/indexer/ast/traversers/python.js.map +1 -0
- package/dist/indexer/ast/traversers/types.d.ts +98 -0
- package/dist/indexer/ast/traversers/types.d.ts.map +1 -0
- package/dist/indexer/ast/traversers/types.js +2 -0
- package/dist/indexer/ast/traversers/types.js.map +1 -0
- package/dist/indexer/ast/traversers/typescript.d.ts +29 -0
- package/dist/indexer/ast/traversers/typescript.d.ts.map +1 -0
- package/dist/indexer/ast/traversers/typescript.js +88 -0
- package/dist/indexer/ast/traversers/typescript.js.map +1 -0
- package/dist/indexer/ast/types.d.ts +59 -0
- package/dist/indexer/ast/types.d.ts.map +1 -0
- package/dist/indexer/ast/types.js +2 -0
- package/dist/indexer/ast/types.js.map +1 -0
- package/dist/indexer/change-detector.d.ts +17 -0
- package/dist/indexer/change-detector.d.ts.map +1 -0
- package/dist/indexer/change-detector.js +207 -0
- package/dist/indexer/change-detector.js.map +1 -0
- package/dist/indexer/chunk-batch-processor.d.ts +103 -0
- package/dist/indexer/chunk-batch-processor.d.ts.map +1 -0
- package/dist/indexer/chunk-batch-processor.js +179 -0
- package/dist/indexer/chunk-batch-processor.js.map +1 -0
- package/dist/indexer/chunker.d.ts +10 -0
- package/dist/indexer/chunker.d.ts.map +1 -0
- package/dist/indexer/chunker.js +96 -0
- package/dist/indexer/chunker.js.map +1 -0
- package/dist/indexer/dependency-analyzer.d.ts +60 -0
- package/dist/indexer/dependency-analyzer.d.ts.map +1 -0
- package/dist/indexer/dependency-analyzer.js +261 -0
- package/dist/indexer/dependency-analyzer.js.map +1 -0
- package/dist/indexer/incremental.d.ts +47 -0
- package/dist/indexer/incremental.d.ts.map +1 -0
- package/dist/indexer/incremental.js +284 -0
- package/dist/indexer/incremental.js.map +1 -0
- package/dist/indexer/index.d.ts +80 -0
- package/dist/indexer/index.d.ts.map +1 -0
- package/dist/indexer/index.js +364 -0
- package/dist/indexer/index.js.map +1 -0
- package/dist/indexer/json-template-chunker.d.ts +9 -0
- package/dist/indexer/json-template-chunker.d.ts.map +1 -0
- package/dist/indexer/json-template-chunker.js +83 -0
- package/dist/indexer/json-template-chunker.js.map +1 -0
- package/dist/indexer/liquid-chunker.d.ts +13 -0
- package/dist/indexer/liquid-chunker.d.ts.map +1 -0
- package/dist/indexer/liquid-chunker.js +272 -0
- package/dist/indexer/liquid-chunker.js.map +1 -0
- package/dist/indexer/manifest.d.ts +122 -0
- package/dist/indexer/manifest.d.ts.map +1 -0
- package/dist/indexer/manifest.js +262 -0
- package/dist/indexer/manifest.js.map +1 -0
- package/dist/indexer/progress-tracker.d.ts +35 -0
- package/dist/indexer/progress-tracker.d.ts.map +1 -0
- package/dist/indexer/progress-tracker.js +33 -0
- package/dist/indexer/progress-tracker.js.map +1 -0
- package/dist/indexer/scanner.d.ts +16 -0
- package/dist/indexer/scanner.d.ts.map +1 -0
- package/dist/indexer/scanner.js +159 -0
- package/dist/indexer/scanner.js.map +1 -0
- package/dist/indexer/symbol-extractor.d.ts +18 -0
- package/dist/indexer/symbol-extractor.d.ts.map +1 -0
- package/dist/indexer/symbol-extractor.js +351 -0
- package/dist/indexer/symbol-extractor.js.map +1 -0
- package/dist/indexer/types.d.ts +34 -0
- package/dist/indexer/types.d.ts.map +1 -0
- package/dist/indexer/types.js +2 -0
- package/dist/indexer/types.js.map +1 -0
- package/dist/insights/complexity-analyzer.d.ts +82 -0
- package/dist/insights/complexity-analyzer.d.ts.map +1 -0
- package/dist/insights/complexity-analyzer.js +356 -0
- package/dist/insights/complexity-analyzer.js.map +1 -0
- package/dist/insights/formatters/index.d.ts +11 -0
- package/dist/insights/formatters/index.d.ts.map +1 -0
- package/dist/insights/formatters/index.js +20 -0
- package/dist/insights/formatters/index.js.map +1 -0
- package/dist/insights/formatters/json.d.ts +7 -0
- package/dist/insights/formatters/json.d.ts.map +1 -0
- package/dist/insights/formatters/json.js +14 -0
- package/dist/insights/formatters/json.js.map +1 -0
- package/dist/insights/formatters/sarif.d.ts +6 -0
- package/dist/insights/formatters/sarif.d.ts.map +1 -0
- package/dist/insights/formatters/sarif.js +113 -0
- package/dist/insights/formatters/sarif.js.map +1 -0
- package/dist/insights/formatters/text.d.ts +6 -0
- package/dist/insights/formatters/text.d.ts.map +1 -0
- package/dist/insights/formatters/text.js +154 -0
- package/dist/insights/formatters/text.js.map +1 -0
- package/dist/insights/types.d.ts +73 -0
- package/dist/insights/types.d.ts.map +1 -0
- package/dist/insights/types.js +9 -0
- package/dist/insights/types.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/path-matching.d.ts +69 -0
- package/dist/utils/path-matching.d.ts.map +1 -0
- package/dist/utils/path-matching.js +123 -0
- package/dist/utils/path-matching.js.map +1 -0
- package/dist/utils/result.d.ts +65 -0
- package/dist/utils/result.d.ts.map +1 -0
- package/dist/utils/result.js +67 -0
- package/dist/utils/result.js.map +1 -0
- package/dist/utils/version.d.ts +22 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +28 -0
- package/dist/utils/version.js.map +1 -0
- package/dist/vectordb/batch-insert.d.ts +14 -0
- package/dist/vectordb/batch-insert.d.ts.map +1 -0
- package/dist/vectordb/batch-insert.js +185 -0
- package/dist/vectordb/batch-insert.js.map +1 -0
- package/dist/vectordb/boosting/composer.d.ts +51 -0
- package/dist/vectordb/boosting/composer.d.ts.map +1 -0
- package/dist/vectordb/boosting/composer.js +65 -0
- package/dist/vectordb/boosting/composer.js.map +1 -0
- package/dist/vectordb/boosting/index.d.ts +22 -0
- package/dist/vectordb/boosting/index.d.ts.map +1 -0
- package/dist/vectordb/boosting/index.js +22 -0
- package/dist/vectordb/boosting/index.js.map +1 -0
- package/dist/vectordb/boosting/strategies.d.ts +40 -0
- package/dist/vectordb/boosting/strategies.d.ts.map +1 -0
- package/dist/vectordb/boosting/strategies.js +174 -0
- package/dist/vectordb/boosting/strategies.js.map +1 -0
- package/dist/vectordb/boosting/types.d.ts +20 -0
- package/dist/vectordb/boosting/types.d.ts.map +1 -0
- package/dist/vectordb/boosting/types.js +2 -0
- package/dist/vectordb/boosting/types.js.map +1 -0
- package/dist/vectordb/intent-classifier.d.ts +99 -0
- package/dist/vectordb/intent-classifier.d.ts.map +1 -0
- package/dist/vectordb/intent-classifier.js +193 -0
- package/dist/vectordb/intent-classifier.js.map +1 -0
- package/dist/vectordb/lancedb.d.ts +45 -0
- package/dist/vectordb/lancedb.d.ts.map +1 -0
- package/dist/vectordb/lancedb.js +203 -0
- package/dist/vectordb/lancedb.js.map +1 -0
- package/dist/vectordb/maintenance.d.ts +18 -0
- package/dist/vectordb/maintenance.d.ts.map +1 -0
- package/dist/vectordb/maintenance.js +87 -0
- package/dist/vectordb/maintenance.js.map +1 -0
- package/dist/vectordb/query.d.ts +34 -0
- package/dist/vectordb/query.d.ts.map +1 -0
- package/dist/vectordb/query.js +303 -0
- package/dist/vectordb/query.js.map +1 -0
- package/dist/vectordb/relevance.d.ts +15 -0
- package/dist/vectordb/relevance.d.ts.map +1 -0
- package/dist/vectordb/relevance.js +19 -0
- package/dist/vectordb/relevance.js.map +1 -0
- package/dist/vectordb/types.d.ts +29 -0
- package/dist/vectordb/types.d.ts.map +1 -0
- package/dist/vectordb/types.js +2 -0
- package/dist/vectordb/types.js.map +1 -0
- package/dist/vectordb/version.d.ts +16 -0
- package/dist/vectordb/version.d.ts.map +1 -0
- package/dist/vectordb/version.js +40 -0
- package/dist/vectordb/version.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { isGitRepo, getCurrentBranch, getCurrentCommit, getChangedFiles, getChangedFilesBetweenCommits, } from './utils.js';
|
|
4
|
+
/**
|
|
5
|
+
* Tracks git state (branch and commit) and detects changes.
|
|
6
|
+
* Persists state to disk to survive server restarts.
|
|
7
|
+
*/
|
|
8
|
+
export class GitStateTracker {
|
|
9
|
+
stateFile;
|
|
10
|
+
rootDir;
|
|
11
|
+
currentState = null;
|
|
12
|
+
constructor(rootDir, indexPath) {
|
|
13
|
+
this.rootDir = rootDir;
|
|
14
|
+
this.stateFile = path.join(indexPath, '.git-state.json');
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Loads the last known git state from disk.
|
|
18
|
+
* Returns null if no state file exists (first run).
|
|
19
|
+
*/
|
|
20
|
+
async loadState() {
|
|
21
|
+
try {
|
|
22
|
+
const content = await fs.readFile(this.stateFile, 'utf-8');
|
|
23
|
+
return JSON.parse(content);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// File doesn't exist or is invalid - this is fine for first run
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Saves the current git state to disk.
|
|
32
|
+
*/
|
|
33
|
+
async saveState(state) {
|
|
34
|
+
try {
|
|
35
|
+
const content = JSON.stringify(state, null, 2);
|
|
36
|
+
await fs.writeFile(this.stateFile, content, 'utf-8');
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
// Log but don't throw - state persistence is best-effort
|
|
40
|
+
console.error(`[Lien] Warning: Failed to save git state: ${error}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Gets the current git state from the repository.
|
|
45
|
+
*
|
|
46
|
+
* @returns Current git state
|
|
47
|
+
* @throws Error if git commands fail
|
|
48
|
+
*/
|
|
49
|
+
async getCurrentGitState() {
|
|
50
|
+
const branch = await getCurrentBranch(this.rootDir);
|
|
51
|
+
const commit = await getCurrentCommit(this.rootDir);
|
|
52
|
+
return {
|
|
53
|
+
branch,
|
|
54
|
+
commit,
|
|
55
|
+
timestamp: Date.now(),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Initializes the tracker by loading saved state and checking current state.
|
|
60
|
+
* Should be called once when MCP server starts.
|
|
61
|
+
*
|
|
62
|
+
* @returns Array of changed files if state changed, null if no changes or first run
|
|
63
|
+
*/
|
|
64
|
+
async initialize() {
|
|
65
|
+
// Check if this is a git repo
|
|
66
|
+
const isRepo = await isGitRepo(this.rootDir);
|
|
67
|
+
if (!isRepo) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
// Get current state
|
|
72
|
+
this.currentState = await this.getCurrentGitState();
|
|
73
|
+
// Load previous state
|
|
74
|
+
const previousState = await this.loadState();
|
|
75
|
+
if (!previousState) {
|
|
76
|
+
// First run - save current state
|
|
77
|
+
await this.saveState(this.currentState);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
// Check if state changed
|
|
81
|
+
const branchChanged = previousState.branch !== this.currentState.branch;
|
|
82
|
+
const commitChanged = previousState.commit !== this.currentState.commit;
|
|
83
|
+
if (!branchChanged && !commitChanged) {
|
|
84
|
+
// No changes
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
// State changed - get list of changed files
|
|
88
|
+
let changedFiles = [];
|
|
89
|
+
if (branchChanged) {
|
|
90
|
+
// Branch changed - compare current branch with previous branch
|
|
91
|
+
try {
|
|
92
|
+
changedFiles = await getChangedFiles(this.rootDir, previousState.branch, this.currentState.branch);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
// If branches diverged too much or don't exist, fall back to commit diff
|
|
96
|
+
console.error(`[Lien] Branch diff failed, using commit diff: ${error}`);
|
|
97
|
+
changedFiles = await getChangedFilesBetweenCommits(this.rootDir, previousState.commit, this.currentState.commit);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (commitChanged) {
|
|
101
|
+
// Same branch, different commit
|
|
102
|
+
changedFiles = await getChangedFilesBetweenCommits(this.rootDir, previousState.commit, this.currentState.commit);
|
|
103
|
+
}
|
|
104
|
+
// Save new state
|
|
105
|
+
await this.saveState(this.currentState);
|
|
106
|
+
return changedFiles;
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
console.error(`[Lien] Failed to initialize git tracker: ${error}`);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Checks for git state changes since last check.
|
|
115
|
+
* This is called periodically by the MCP server.
|
|
116
|
+
*
|
|
117
|
+
* @returns Array of changed files if state changed, null if no changes
|
|
118
|
+
*/
|
|
119
|
+
async detectChanges() {
|
|
120
|
+
// Check if this is a git repo
|
|
121
|
+
const isRepo = await isGitRepo(this.rootDir);
|
|
122
|
+
if (!isRepo) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
// Get current state
|
|
127
|
+
const newState = await this.getCurrentGitState();
|
|
128
|
+
// If we don't have a previous state, just save current and return
|
|
129
|
+
if (!this.currentState) {
|
|
130
|
+
this.currentState = newState;
|
|
131
|
+
await this.saveState(newState);
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
// Check if state changed
|
|
135
|
+
const branchChanged = this.currentState.branch !== newState.branch;
|
|
136
|
+
const commitChanged = this.currentState.commit !== newState.commit;
|
|
137
|
+
if (!branchChanged && !commitChanged) {
|
|
138
|
+
// No changes
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
// State changed - get list of changed files
|
|
142
|
+
let changedFiles = [];
|
|
143
|
+
if (branchChanged) {
|
|
144
|
+
// Branch changed
|
|
145
|
+
try {
|
|
146
|
+
changedFiles = await getChangedFiles(this.rootDir, this.currentState.branch, newState.branch);
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
// Fall back to commit diff
|
|
150
|
+
console.error(`[Lien] Branch diff failed, using commit diff: ${error}`);
|
|
151
|
+
changedFiles = await getChangedFilesBetweenCommits(this.rootDir, this.currentState.commit, newState.commit);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else if (commitChanged) {
|
|
155
|
+
// Same branch, different commit
|
|
156
|
+
changedFiles = await getChangedFilesBetweenCommits(this.rootDir, this.currentState.commit, newState.commit);
|
|
157
|
+
}
|
|
158
|
+
// Update current state
|
|
159
|
+
this.currentState = newState;
|
|
160
|
+
await this.saveState(newState);
|
|
161
|
+
return changedFiles;
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
console.error(`[Lien] Failed to detect git changes: ${error}`);
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Gets the current git state.
|
|
170
|
+
* Useful for status display.
|
|
171
|
+
*/
|
|
172
|
+
getState() {
|
|
173
|
+
return this.currentState;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Manually updates the saved state.
|
|
177
|
+
* Useful after manual reindexing to sync state.
|
|
178
|
+
*/
|
|
179
|
+
async updateState() {
|
|
180
|
+
try {
|
|
181
|
+
this.currentState = await this.getCurrentGitState();
|
|
182
|
+
await this.saveState(this.currentState);
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
console.error(`[Lien] Failed to update git state: ${error}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracker.js","sourceRoot":"","sources":["../../src/git/tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,6BAA6B,GAC9B,MAAM,YAAY,CAAC;AAQpB;;;GAGG;AACH,MAAM,OAAO,eAAe;IAClB,SAAS,CAAS;IAClB,OAAO,CAAS;IAChB,YAAY,GAAoB,IAAI,CAAC;IAE7C,YAAY,OAAe,EAAE,SAAiB;QAC5C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,SAAS;QACrB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC3D,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,gEAAgE;YAChE,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,SAAS,CAAC,KAAe;QACrC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAC/C,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,O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CAChB,CAAC;YACJ,CAAC;YAED,uBAAuB;YACvB,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;YAC7B,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAE/B,OAAO,YAAY,CAAC;QACtB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,wCAAwC,KAAK,EAAE,CAAC,CAAC;YAC/D,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW;QACf,IAAI,CAAC;YACH,IAAI,CAAC,YAAY,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACpD,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a directory is a git repository.
|
|
3
|
+
*
|
|
4
|
+
* @param rootDir - Directory to check
|
|
5
|
+
* @returns true if directory is a git repo, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export declare function isGitRepo(rootDir: string): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Gets the current git branch name.
|
|
10
|
+
*
|
|
11
|
+
* @param rootDir - Root directory of the git repository
|
|
12
|
+
* @returns Branch name (e.g., "main", "feature-branch")
|
|
13
|
+
* @throws Error if not a git repo or git command fails
|
|
14
|
+
*/
|
|
15
|
+
export declare function getCurrentBranch(rootDir: string): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Gets the current git commit SHA (HEAD).
|
|
18
|
+
*
|
|
19
|
+
* @param rootDir - Root directory of the git repository
|
|
20
|
+
* @returns Commit SHA (full 40-character hash)
|
|
21
|
+
* @throws Error if not a git repo or git command fails
|
|
22
|
+
*/
|
|
23
|
+
export declare function getCurrentCommit(rootDir: string): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the list of files that changed between two git references.
|
|
26
|
+
*
|
|
27
|
+
* @param rootDir - Root directory of the git repository
|
|
28
|
+
* @param fromRef - Starting reference (branch name, commit SHA, or tag)
|
|
29
|
+
* @param toRef - Ending reference (branch name, commit SHA, or tag)
|
|
30
|
+
* @returns Array of file paths (relative to repo root) that changed
|
|
31
|
+
* @throws Error if git command fails
|
|
32
|
+
*/
|
|
33
|
+
export declare function getChangedFiles(rootDir: string, fromRef: string, toRef: string): Promise<string[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the list of files that changed in a specific commit.
|
|
36
|
+
*
|
|
37
|
+
* @param rootDir - Root directory of the git repository
|
|
38
|
+
* @param commitSha - Commit SHA to check
|
|
39
|
+
* @returns Array of file paths (absolute) that changed in this commit
|
|
40
|
+
* @throws Error if git command fails
|
|
41
|
+
*/
|
|
42
|
+
export declare function getChangedFilesInCommit(rootDir: string, commitSha: string): Promise<string[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the list of files that changed between two commits.
|
|
45
|
+
* More efficient than getChangedFiles for commit-to-commit comparisons.
|
|
46
|
+
*
|
|
47
|
+
* @param rootDir - Root directory of the git repository
|
|
48
|
+
* @param fromCommit - Starting commit SHA
|
|
49
|
+
* @param toCommit - Ending commit SHA
|
|
50
|
+
* @returns Array of file paths (absolute) that changed between commits
|
|
51
|
+
* @throws Error if git command fails
|
|
52
|
+
*/
|
|
53
|
+
export declare function getChangedFilesBetweenCommits(rootDir: string, fromCommit: string, toCommit: string): Promise<string[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Checks if git is installed and available.
|
|
56
|
+
*
|
|
57
|
+
* @returns true if git is available, false otherwise
|
|
58
|
+
*/
|
|
59
|
+
export declare function isGitAvailable(): Promise<boolean>;
|
|
60
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/git/utils.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQjE;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAUvE;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAUvE;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,EAAE,CAAC,CAoBnB;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,EAAE,CAAC,CAoBnB;AAED;;;;;;;;;GASG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,EAAE,CAAC,CAoBnB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAOvD"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { exec } from 'child_process';
|
|
2
|
+
import { promisify } from 'util';
|
|
3
|
+
import fs from 'fs/promises';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
const execAsync = promisify(exec);
|
|
6
|
+
/**
|
|
7
|
+
* Checks if a directory is a git repository.
|
|
8
|
+
*
|
|
9
|
+
* @param rootDir - Directory to check
|
|
10
|
+
* @returns true if directory is a git repo, false otherwise
|
|
11
|
+
*/
|
|
12
|
+
export async function isGitRepo(rootDir) {
|
|
13
|
+
try {
|
|
14
|
+
const gitDir = path.join(rootDir, '.git');
|
|
15
|
+
await fs.access(gitDir);
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Gets the current git branch name.
|
|
24
|
+
*
|
|
25
|
+
* @param rootDir - Root directory of the git repository
|
|
26
|
+
* @returns Branch name (e.g., "main", "feature-branch")
|
|
27
|
+
* @throws Error if not a git repo or git command fails
|
|
28
|
+
*/
|
|
29
|
+
export async function getCurrentBranch(rootDir) {
|
|
30
|
+
try {
|
|
31
|
+
const { stdout } = await execAsync('git rev-parse --abbrev-ref HEAD', {
|
|
32
|
+
cwd: rootDir,
|
|
33
|
+
timeout: 5000, // 5 second timeout
|
|
34
|
+
});
|
|
35
|
+
return stdout.trim();
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw new Error(`Failed to get current branch: ${error}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Gets the current git commit SHA (HEAD).
|
|
43
|
+
*
|
|
44
|
+
* @param rootDir - Root directory of the git repository
|
|
45
|
+
* @returns Commit SHA (full 40-character hash)
|
|
46
|
+
* @throws Error if not a git repo or git command fails
|
|
47
|
+
*/
|
|
48
|
+
export async function getCurrentCommit(rootDir) {
|
|
49
|
+
try {
|
|
50
|
+
const { stdout } = await execAsync('git rev-parse HEAD', {
|
|
51
|
+
cwd: rootDir,
|
|
52
|
+
timeout: 5000,
|
|
53
|
+
});
|
|
54
|
+
return stdout.trim();
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new Error(`Failed to get current commit: ${error}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets the list of files that changed between two git references.
|
|
62
|
+
*
|
|
63
|
+
* @param rootDir - Root directory of the git repository
|
|
64
|
+
* @param fromRef - Starting reference (branch name, commit SHA, or tag)
|
|
65
|
+
* @param toRef - Ending reference (branch name, commit SHA, or tag)
|
|
66
|
+
* @returns Array of file paths (relative to repo root) that changed
|
|
67
|
+
* @throws Error if git command fails
|
|
68
|
+
*/
|
|
69
|
+
export async function getChangedFiles(rootDir, fromRef, toRef) {
|
|
70
|
+
try {
|
|
71
|
+
const { stdout } = await execAsync(`git diff --name-only ${fromRef}...${toRef}`, {
|
|
72
|
+
cwd: rootDir,
|
|
73
|
+
timeout: 10000, // 10 second timeout for diffs
|
|
74
|
+
});
|
|
75
|
+
const files = stdout
|
|
76
|
+
.trim()
|
|
77
|
+
.split('\n')
|
|
78
|
+
.filter(Boolean)
|
|
79
|
+
.map(file => path.join(rootDir, file)); // Convert to absolute paths
|
|
80
|
+
return files;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
throw new Error(`Failed to get changed files: ${error}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Gets the list of files that changed in a specific commit.
|
|
88
|
+
*
|
|
89
|
+
* @param rootDir - Root directory of the git repository
|
|
90
|
+
* @param commitSha - Commit SHA to check
|
|
91
|
+
* @returns Array of file paths (absolute) that changed in this commit
|
|
92
|
+
* @throws Error if git command fails
|
|
93
|
+
*/
|
|
94
|
+
export async function getChangedFilesInCommit(rootDir, commitSha) {
|
|
95
|
+
try {
|
|
96
|
+
const { stdout } = await execAsync(`git diff-tree --no-commit-id --name-only -r ${commitSha}`, {
|
|
97
|
+
cwd: rootDir,
|
|
98
|
+
timeout: 10000,
|
|
99
|
+
});
|
|
100
|
+
const files = stdout
|
|
101
|
+
.trim()
|
|
102
|
+
.split('\n')
|
|
103
|
+
.filter(Boolean)
|
|
104
|
+
.map(file => path.join(rootDir, file)); // Convert to absolute paths
|
|
105
|
+
return files;
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
throw new Error(`Failed to get changed files in commit: ${error}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Gets the list of files that changed between two commits.
|
|
113
|
+
* More efficient than getChangedFiles for commit-to-commit comparisons.
|
|
114
|
+
*
|
|
115
|
+
* @param rootDir - Root directory of the git repository
|
|
116
|
+
* @param fromCommit - Starting commit SHA
|
|
117
|
+
* @param toCommit - Ending commit SHA
|
|
118
|
+
* @returns Array of file paths (absolute) that changed between commits
|
|
119
|
+
* @throws Error if git command fails
|
|
120
|
+
*/
|
|
121
|
+
export async function getChangedFilesBetweenCommits(rootDir, fromCommit, toCommit) {
|
|
122
|
+
try {
|
|
123
|
+
const { stdout } = await execAsync(`git diff --name-only ${fromCommit} ${toCommit}`, {
|
|
124
|
+
cwd: rootDir,
|
|
125
|
+
timeout: 10000,
|
|
126
|
+
});
|
|
127
|
+
const files = stdout
|
|
128
|
+
.trim()
|
|
129
|
+
.split('\n')
|
|
130
|
+
.filter(Boolean)
|
|
131
|
+
.map(file => path.join(rootDir, file)); // Convert to absolute paths
|
|
132
|
+
return files;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
throw new Error(`Failed to get changed files between commits: ${error}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Checks if git is installed and available.
|
|
140
|
+
*
|
|
141
|
+
* @returns true if git is available, false otherwise
|
|
142
|
+
*/
|
|
143
|
+
export async function isGitAvailable() {
|
|
144
|
+
try {
|
|
145
|
+
await execAsync('git --version', { timeout: 3000 });
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/git/utils.ts"],"names":[],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CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,0CAA0C,KAAK,EAAE,CAAC,CAAC;IACrE,CAAC;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,OAAe,EACf,UAAkB,EAClB,QAAgB;IAEhB,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAChC,wBAAwB,UAAU,IAAI,QAAQ,EAAE,EAChD;YACE,GAAG,EAAE,OAAO;YACZ,OAAO,EAAE,KAAK;SACf,CACF,CAAC;QAEF,MAAM,KAAK,GAAG,MAAM;aACjB,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;aACX,MAAM,CAAC,OAAO,CAAC;aACf,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,4BAA4B;QAEtE,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,gDAAgD,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,IAAI,CAAC;QACH,MAAM,SAAS,CAAC,eAAe,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @liendev/core - Lien's indexing and analysis engine
|
|
3
|
+
*
|
|
4
|
+
* This is the public API for:
|
|
5
|
+
* - @liendev/cli (CLI commands)
|
|
6
|
+
* - @liendev/action (GitHub Action)
|
|
7
|
+
* - @liendev/cloud (Cloud workers)
|
|
8
|
+
* - Third-party integrations
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import {
|
|
13
|
+
* indexCodebase,
|
|
14
|
+
* VectorDB,
|
|
15
|
+
* ComplexityAnalyzer,
|
|
16
|
+
* loadConfig,
|
|
17
|
+
* } from '@liendev/core';
|
|
18
|
+
*
|
|
19
|
+
* // Index a codebase
|
|
20
|
+
* const result = await indexCodebase({ rootDir: '/path/to/project' });
|
|
21
|
+
*
|
|
22
|
+
* // Run complexity analysis
|
|
23
|
+
* const db = await VectorDB.load('/path/to/project');
|
|
24
|
+
* const config = await loadConfig('/path/to/project');
|
|
25
|
+
* const analyzer = new ComplexityAnalyzer(db, config);
|
|
26
|
+
* const report = await analyzer.analyze();
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export { indexCodebase } from './indexer/index.js';
|
|
30
|
+
export type { IndexingOptions, IndexingProgress, IndexingResult } from './indexer/index.js';
|
|
31
|
+
export { ManifestManager } from './indexer/manifest.js';
|
|
32
|
+
export type { IndexManifest, FileEntry } from './indexer/manifest.js';
|
|
33
|
+
export { chunkFile } from './indexer/chunker.js';
|
|
34
|
+
export { scanCodebase, scanCodebaseWithFrameworks, detectLanguage } from './indexer/scanner.js';
|
|
35
|
+
export { indexSingleFile, indexMultipleFiles, normalizeToRelativePath } from './indexer/incremental.js';
|
|
36
|
+
export { extractSymbols } from './indexer/symbol-extractor.js';
|
|
37
|
+
export { LocalEmbeddings } from './embeddings/local.js';
|
|
38
|
+
export { CachedEmbeddings } from './embeddings/cache.js';
|
|
39
|
+
export type { EmbeddingService } from './embeddings/types.js';
|
|
40
|
+
export { EMBEDDING_DIMENSION, EMBEDDING_DIMENSIONS } from './embeddings/types.js';
|
|
41
|
+
export { VectorDB } from './vectordb/lancedb.js';
|
|
42
|
+
export type { VectorDBInterface, SearchResult } from './vectordb/types.js';
|
|
43
|
+
export { calculateRelevance } from './vectordb/relevance.js';
|
|
44
|
+
export type { RelevanceCategory } from './vectordb/relevance.js';
|
|
45
|
+
export { readVersionFile, writeVersionFile } from './vectordb/version.js';
|
|
46
|
+
export { ComplexityAnalyzer } from './insights/complexity-analyzer.js';
|
|
47
|
+
export { formatReport, formatTextReport, formatJsonReport, formatSarifReport } from './insights/formatters/index.js';
|
|
48
|
+
export type { OutputFormat } from './insights/formatters/index.js';
|
|
49
|
+
import { ConfigService, configService as _configService } from './config/service.js';
|
|
50
|
+
import { defaultConfig as _defaultConfig, isLegacyConfig, isModernConfig } from './config/schema.js';
|
|
51
|
+
import type { LienConfig, LegacyLienConfig, FrameworkConfig, FrameworkInstance } from './config/schema.js';
|
|
52
|
+
export { ConfigService, _configService as configService };
|
|
53
|
+
export type { ValidationResult, MigrationResult } from './config/service.js';
|
|
54
|
+
export { MigrationManager } from './config/migration-manager.js';
|
|
55
|
+
export { migrateConfig, migrateConfigFile } from './config/migration.js';
|
|
56
|
+
export { _defaultConfig as defaultConfig, isLegacyConfig, isModernConfig };
|
|
57
|
+
export type { LienConfig, LegacyLienConfig, FrameworkConfig, FrameworkInstance };
|
|
58
|
+
export declare const loadConfig: (rootDir?: string) => Promise<LienConfig>;
|
|
59
|
+
export declare const saveConfig: (rootDir: string, config: LienConfig) => Promise<void>;
|
|
60
|
+
export declare const createDefaultConfig: () => LienConfig;
|
|
61
|
+
export { isGitRepo, isGitAvailable, getCurrentBranch, getCurrentCommit, getChangedFiles, getChangedFilesBetweenCommits, } from './git/utils.js';
|
|
62
|
+
export { GitStateTracker } from './git/tracker.js';
|
|
63
|
+
export type { GitState } from './git/tracker.js';
|
|
64
|
+
export { groupByConfidence, selectByPriority, resolveFrameworkConflicts, runAllDetectors, detectAllFrameworks, getDetectionSummary, } from './frameworks/detector-service.js';
|
|
65
|
+
export type { DetectionWithPriority, GroupedDetections } from './frameworks/detector-service.js';
|
|
66
|
+
export { frameworkDetectors, registerFramework, getFrameworkDetector } from './frameworks/registry.js';
|
|
67
|
+
export type { FrameworkDetector, DetectionResult, DetectionOptions } from './frameworks/types.js';
|
|
68
|
+
export { laravelDetector } from './frameworks/laravel/detector.js';
|
|
69
|
+
export { nodejsDetector } from './frameworks/nodejs/detector.js';
|
|
70
|
+
export { phpDetector } from './frameworks/php/detector.js';
|
|
71
|
+
export { shopifyDetector } from './frameworks/shopify/detector.js';
|
|
72
|
+
export { LienError, LienErrorCode, ConfigError, IndexingError, EmbeddingError, DatabaseError, wrapError, isLienError, getErrorMessage, getErrorStack, } from './errors/index.js';
|
|
73
|
+
export type { ChunkMetadata, CodeChunk, ScanOptions, RiskLevel, ComplexityMetricType, HalsteadDetails, ComplexityViolation, FileComplexityData, ComplexityReport, } from './types/index.js';
|
|
74
|
+
export { RISK_ORDER } from './types/index.js';
|
|
75
|
+
export { DEFAULT_CHUNK_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CONCURRENCY, DEFAULT_EMBEDDING_BATCH_SIZE, EMBEDDING_MICRO_BATCH_SIZE, VECTOR_DB_MAX_BATCH_SIZE, VECTOR_DB_MIN_BATCH_SIZE, DEFAULT_EMBEDDING_MODEL, DEFAULT_PORT, VERSION_CHECK_INTERVAL_MS, DEFAULT_GIT_POLL_INTERVAL_MS, DEFAULT_DEBOUNCE_MS, INDEX_FORMAT_VERSION, } from './constants.js';
|
|
76
|
+
export { Result, Ok, Err, isOk, isErr, unwrap, unwrapOr } from './utils/result.js';
|
|
77
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,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e,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAMnE,OAAO,EACL,SAAS,EACT,aAAa,EACb,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAAa,EACb,SAAS,EACT,WAAW,EACX,eAAe,EACf,aAAa,GACd,MAAM,mBAAmB,CAAC;AAM3B,YAAY,EAEV,aAAa,EACb,SAAS,EACT,WAAW,EAGX,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAM9C,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,4BAA4B,EAC5B,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,YAAY,EACZ,yBAAyB,EACzB,4BAA4B,EAC5B,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @liendev/core - Lien's indexing and analysis engine
|
|
3
|
+
*
|
|
4
|
+
* This is the public API for:
|
|
5
|
+
* - @liendev/cli (CLI commands)
|
|
6
|
+
* - @liendev/action (GitHub Action)
|
|
7
|
+
* - @liendev/cloud (Cloud workers)
|
|
8
|
+
* - Third-party integrations
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import {
|
|
13
|
+
* indexCodebase,
|
|
14
|
+
* VectorDB,
|
|
15
|
+
* ComplexityAnalyzer,
|
|
16
|
+
* loadConfig,
|
|
17
|
+
* } from '@liendev/core';
|
|
18
|
+
*
|
|
19
|
+
* // Index a codebase
|
|
20
|
+
* const result = await indexCodebase({ rootDir: '/path/to/project' });
|
|
21
|
+
*
|
|
22
|
+
* // Run complexity analysis
|
|
23
|
+
* const db = await VectorDB.load('/path/to/project');
|
|
24
|
+
* const config = await loadConfig('/path/to/project');
|
|
25
|
+
* const analyzer = new ComplexityAnalyzer(db, config);
|
|
26
|
+
* const report = await analyzer.analyze();
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
// =============================================================================
|
|
30
|
+
// INDEXING
|
|
31
|
+
// =============================================================================
|
|
32
|
+
export { indexCodebase } from './indexer/index.js';
|
|
33
|
+
export { ManifestManager } from './indexer/manifest.js';
|
|
34
|
+
export { chunkFile } from './indexer/chunker.js';
|
|
35
|
+
export { scanCodebase, scanCodebaseWithFrameworks, detectLanguage } from './indexer/scanner.js';
|
|
36
|
+
export { indexSingleFile, indexMultipleFiles, normalizeToRelativePath } from './indexer/incremental.js';
|
|
37
|
+
export { extractSymbols } from './indexer/symbol-extractor.js';
|
|
38
|
+
// =============================================================================
|
|
39
|
+
// EMBEDDINGS
|
|
40
|
+
// =============================================================================
|
|
41
|
+
export { LocalEmbeddings } from './embeddings/local.js';
|
|
42
|
+
export { CachedEmbeddings } from './embeddings/cache.js';
|
|
43
|
+
export { EMBEDDING_DIMENSION, EMBEDDING_DIMENSIONS } from './embeddings/types.js';
|
|
44
|
+
// =============================================================================
|
|
45
|
+
// VECTOR DATABASE
|
|
46
|
+
// =============================================================================
|
|
47
|
+
export { VectorDB } from './vectordb/lancedb.js';
|
|
48
|
+
export { calculateRelevance } from './vectordb/relevance.js';
|
|
49
|
+
export { readVersionFile, writeVersionFile } from './vectordb/version.js';
|
|
50
|
+
// =============================================================================
|
|
51
|
+
// COMPLEXITY ANALYSIS
|
|
52
|
+
// =============================================================================
|
|
53
|
+
export { ComplexityAnalyzer } from './insights/complexity-analyzer.js';
|
|
54
|
+
export { formatReport, formatTextReport, formatJsonReport, formatSarifReport } from './insights/formatters/index.js';
|
|
55
|
+
// =============================================================================
|
|
56
|
+
// CONFIGURATION
|
|
57
|
+
// =============================================================================
|
|
58
|
+
import { ConfigService, configService as _configService } from './config/service.js';
|
|
59
|
+
import { defaultConfig as _defaultConfig, isLegacyConfig, isModernConfig } from './config/schema.js';
|
|
60
|
+
export { ConfigService, _configService as configService };
|
|
61
|
+
export { MigrationManager } from './config/migration-manager.js';
|
|
62
|
+
export { migrateConfig, migrateConfigFile } from './config/migration.js';
|
|
63
|
+
export { _defaultConfig as defaultConfig, isLegacyConfig, isModernConfig };
|
|
64
|
+
// Convenience re-exports
|
|
65
|
+
export const loadConfig = (rootDir) => _configService.load(rootDir);
|
|
66
|
+
export const saveConfig = (rootDir, config) => _configService.save(rootDir, config);
|
|
67
|
+
export const createDefaultConfig = () => _defaultConfig;
|
|
68
|
+
// =============================================================================
|
|
69
|
+
// GIT UTILITIES
|
|
70
|
+
// =============================================================================
|
|
71
|
+
export { isGitRepo, isGitAvailable, getCurrentBranch, getCurrentCommit, getChangedFiles, getChangedFilesBetweenCommits, } from './git/utils.js';
|
|
72
|
+
export { GitStateTracker } from './git/tracker.js';
|
|
73
|
+
// =============================================================================
|
|
74
|
+
// FRAMEWORK DETECTION
|
|
75
|
+
// =============================================================================
|
|
76
|
+
export { groupByConfidence, selectByPriority, resolveFrameworkConflicts, runAllDetectors, detectAllFrameworks, getDetectionSummary, } from './frameworks/detector-service.js';
|
|
77
|
+
export { frameworkDetectors, registerFramework, getFrameworkDetector } from './frameworks/registry.js';
|
|
78
|
+
export { laravelDetector } from './frameworks/laravel/detector.js';
|
|
79
|
+
export { nodejsDetector } from './frameworks/nodejs/detector.js';
|
|
80
|
+
export { phpDetector } from './frameworks/php/detector.js';
|
|
81
|
+
export { shopifyDetector } from './frameworks/shopify/detector.js';
|
|
82
|
+
// =============================================================================
|
|
83
|
+
// ERRORS
|
|
84
|
+
// =============================================================================
|
|
85
|
+
export { LienError, LienErrorCode, ConfigError, IndexingError, EmbeddingError, DatabaseError, wrapError, isLienError, getErrorMessage, getErrorStack, } from './errors/index.js';
|
|
86
|
+
export { RISK_ORDER } from './types/index.js';
|
|
87
|
+
// =============================================================================
|
|
88
|
+
// CONSTANTS
|
|
89
|
+
// =============================================================================
|
|
90
|
+
export { DEFAULT_CHUNK_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CONCURRENCY, DEFAULT_EMBEDDING_BATCH_SIZE, EMBEDDING_MICRO_BATCH_SIZE, VECTOR_DB_MAX_BATCH_SIZE, VECTOR_DB_MIN_BATCH_SIZE, DEFAULT_EMBEDDING_MODEL, DEFAULT_PORT, VERSION_CHECK_INTERVAL_MS, DEFAULT_GIT_POLL_INTERVAL_MS, DEFAULT_DEBOUNCE_MS, INDEX_FORMAT_VERSION, } from './constants.js';
|
|
91
|
+
// =============================================================================
|
|
92
|
+
// UTILITIES
|
|
93
|
+
// =============================================================================
|
|
94
|
+
export { Ok, Err, isOk, isErr, unwrap, unwrapOr } from './utils/result.js';
|
|
95
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,gFAAgF;AAChF,WAAW;AACX,gFAAgF;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,M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qB,EACrB,mBAAmB,EACnB,4BAA4B,EAC5B,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,YAAY,EACZ,yBAAyB,EACzB,4BAA4B,EAC5B,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAExB,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,OAAO,EAAU,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ASTChunk } from './types.js';
|
|
2
|
+
export interface ASTChunkOptions {
|
|
3
|
+
maxChunkSize?: number;
|
|
4
|
+
minChunkSize?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Chunk a file using AST-based semantic boundaries
|
|
8
|
+
*
|
|
9
|
+
* Uses Tree-sitter to parse code into an AST and extract semantic chunks
|
|
10
|
+
* (functions, classes, methods) that respect code structure.
|
|
11
|
+
*
|
|
12
|
+
* **Known Limitations:**
|
|
13
|
+
* - Tree-sitter may fail with "Invalid argument" error on very large files (1000+ lines)
|
|
14
|
+
* - When this occurs, Lien automatically falls back to line-based chunking
|
|
15
|
+
* - Configure fallback behavior via `chunking.astFallback` ('line-based' or 'error')
|
|
16
|
+
*
|
|
17
|
+
* @param filepath - Path to the file
|
|
18
|
+
* @param content - File content
|
|
19
|
+
* @param options - Chunking options
|
|
20
|
+
* @returns Array of AST-aware chunks
|
|
21
|
+
* @throws Error if AST parsing fails and astFallback is 'error'
|
|
22
|
+
*/
|
|
23
|
+
export declare function chunkByAST(filepath: string, content: string, options?: ASTChunkOptions): ASTChunk[];
|
|
24
|
+
/**
|
|
25
|
+
* Check if AST chunking should be used for a file
|
|
26
|
+
*/
|
|
27
|
+
export declare function shouldUseAST(filepath: string): boolean;
|
|
28
|
+
//# sourceMappingURL=chunker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunker.d.ts","sourceRoot":"","sources":["../../../src/indexer/ast/chunker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAM3C,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,eAAoB,GAC5B,QAAQ,EAAE,CA2EZ;AAmQD;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEtD"}
|