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.
Files changed (55) hide show
  1. package/.github/workflows/publish.yml +39 -0
  2. package/LICENSE +21 -0
  3. package/README.md +176 -0
  4. package/dist/commands/analyze.d.ts +2 -0
  5. package/dist/commands/analyze.d.ts.map +1 -0
  6. package/dist/commands/analyze.js +40 -0
  7. package/dist/commands/analyze.js.map +1 -0
  8. package/dist/commands/clear-cache.d.ts +2 -0
  9. package/dist/commands/clear-cache.d.ts.map +1 -0
  10. package/dist/commands/clear-cache.js +23 -0
  11. package/dist/commands/clear-cache.js.map +1 -0
  12. package/dist/commands/commit.d.ts +2 -0
  13. package/dist/commands/commit.d.ts.map +1 -0
  14. package/dist/commands/commit.js +42 -0
  15. package/dist/commands/commit.js.map +1 -0
  16. package/dist/commands/copy.d.ts +2 -0
  17. package/dist/commands/copy.d.ts.map +1 -0
  18. package/dist/commands/copy.js +42 -0
  19. package/dist/commands/copy.js.map +1 -0
  20. package/dist/commands/help.d.ts +2 -0
  21. package/dist/commands/help.d.ts.map +1 -0
  22. package/dist/commands/help.js +129 -0
  23. package/dist/commands/help.js.map +1 -0
  24. package/dist/commands/history.d.ts +2 -0
  25. package/dist/commands/history.d.ts.map +1 -0
  26. package/dist/commands/history.js +58 -0
  27. package/dist/commands/history.js.map +1 -0
  28. package/dist/index.d.ts +3 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +44 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/services/llm.d.ts +6 -0
  33. package/dist/services/llm.d.ts.map +1 -0
  34. package/dist/services/llm.js +94 -0
  35. package/dist/services/llm.js.map +1 -0
  36. package/dist/utils/cache.d.ts +61 -0
  37. package/dist/utils/cache.d.ts.map +1 -0
  38. package/dist/utils/cache.js +141 -0
  39. package/dist/utils/cache.js.map +1 -0
  40. package/dist/utils/git.d.ts +5 -0
  41. package/dist/utils/git.d.ts.map +1 -0
  42. package/dist/utils/git.js +69 -0
  43. package/dist/utils/git.js.map +1 -0
  44. package/package.json +38 -0
  45. package/src/commands/analyze.ts +44 -0
  46. package/src/commands/clear-cache.ts +23 -0
  47. package/src/commands/commit.ts +48 -0
  48. package/src/commands/copy.ts +48 -0
  49. package/src/commands/help.ts +143 -0
  50. package/src/commands/history.ts +62 -0
  51. package/src/index.ts +53 -0
  52. package/src/services/llm.ts +123 -0
  53. package/src/utils/cache.ts +170 -0
  54. package/src/utils/git.ts +74 -0
  55. package/tsconfig.json +20 -0
@@ -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
+ }