commitect 1.0.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/.github/workflows/publish.yml +39 -0
- package/LICENSE +21 -0
- package/README.md +176 -0
- package/dist/commands/analyze.d.ts +2 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js +40 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/clear-cache.d.ts +2 -0
- package/dist/commands/clear-cache.d.ts.map +1 -0
- package/dist/commands/clear-cache.js +23 -0
- package/dist/commands/clear-cache.js.map +1 -0
- package/dist/commands/commit.d.ts +2 -0
- package/dist/commands/commit.d.ts.map +1 -0
- package/dist/commands/commit.js +42 -0
- package/dist/commands/commit.js.map +1 -0
- package/dist/commands/copy.d.ts +2 -0
- package/dist/commands/copy.d.ts.map +1 -0
- package/dist/commands/copy.js +42 -0
- package/dist/commands/copy.js.map +1 -0
- package/dist/commands/help.d.ts +2 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +129 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/history.d.ts +2 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +58 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/services/llm.d.ts +6 -0
- package/dist/services/llm.d.ts.map +1 -0
- package/dist/services/llm.js +94 -0
- package/dist/services/llm.js.map +1 -0
- package/dist/utils/cache.d.ts +61 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +141 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/git.d.ts +5 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +69 -0
- package/dist/utils/git.js.map +1 -0
- package/package.json +38 -0
- package/src/commands/analyze.ts +44 -0
- package/src/commands/clear-cache.ts +23 -0
- package/src/commands/commit.ts +48 -0
- package/src/commands/copy.ts +48 -0
- package/src/commands/help.ts +143 -0
- package/src/commands/history.ts +62 -0
- package/src/index.ts +53 -0
- package/src/services/llm.ts +123 -0
- package/src/utils/cache.ts +170 -0
- package/src/utils/git.ts +74 -0
- package/tsconfig.json +20 -0
package/src/utils/git.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
|
|
3
|
+
const IGNORED_PATHS = [
|
|
4
|
+
'node_modules/',
|
|
5
|
+
'bin/',
|
|
6
|
+
'obj/',
|
|
7
|
+
'dist/',
|
|
8
|
+
'build/',
|
|
9
|
+
'.git/'
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export function isGitRepository(): boolean {
|
|
13
|
+
try {
|
|
14
|
+
execSync('git rev-parse --git-dir', { stdio: 'pipe' });
|
|
15
|
+
return true;
|
|
16
|
+
} catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getGitDiff(): string {
|
|
22
|
+
try {
|
|
23
|
+
// Get both staged and unstaged changes
|
|
24
|
+
const diff = execSync('git diff HEAD', {
|
|
25
|
+
encoding: 'utf-8',
|
|
26
|
+
maxBuffer: 10 * 1024 * 1024 // 10MB buffer
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return filterIgnoredPaths(diff);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
throw new Error('Failed to read git diff');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function hasChanges(): boolean {
|
|
36
|
+
try {
|
|
37
|
+
const status = execSync('git status --porcelain', {
|
|
38
|
+
encoding: 'utf-8'
|
|
39
|
+
});
|
|
40
|
+
return status.trim().length > 0;
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function executeCommit(message: string): void {
|
|
47
|
+
try {
|
|
48
|
+
execSync(`git commit -m "${message.replace(/"/g, '\\"')}"`, {
|
|
49
|
+
stdio: 'inherit'
|
|
50
|
+
});
|
|
51
|
+
} catch (error) {
|
|
52
|
+
throw new Error('Git commit failed');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function filterIgnoredPaths(diff: string): string {
|
|
57
|
+
const lines = diff.split('\n');
|
|
58
|
+
const filteredLines: string[] = [];
|
|
59
|
+
let skipFile = false;
|
|
60
|
+
|
|
61
|
+
for (const line of lines) {
|
|
62
|
+
// Check if this is a file header
|
|
63
|
+
if (line.startsWith('diff --git')) {
|
|
64
|
+
const path = line.split(' b/')[1];
|
|
65
|
+
skipFile = IGNORED_PATHS.some(ignored => path?.startsWith(ignored));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!skipFile) {
|
|
69
|
+
filteredLines.push(line);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return filteredLines.join('\n');
|
|
74
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ES2020",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"moduleResolution": "node"
|
|
17
|
+
},
|
|
18
|
+
"include": ["src/**/*"],
|
|
19
|
+
"exclude": ["node_modules", "dist"]
|
|
20
|
+
}
|