sncommit 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.
@@ -0,0 +1,66 @@
1
+ import { readFileSync, writeFileSync, existsSync } from "fs";
2
+ import { homedir } from "os";
3
+ import path from "path";
4
+ import { Config } from "../types";
5
+
6
+ const CONFIG_FILE = path.join(homedir(), ".better-commit.json");
7
+
8
+ const DEFAULT_CONFIG: Config = {
9
+ model: "llama-3.1-8b-instant",
10
+ maxHistoryCommits: 50,
11
+ commitStyle: "conventional",
12
+ language: "en",
13
+ customPrompt: "",
14
+ };
15
+
16
+ export class ConfigManager {
17
+ private config: Config;
18
+
19
+ constructor() {
20
+ this.config = this.loadConfig();
21
+ }
22
+
23
+ private loadConfig(): Config {
24
+ try {
25
+ if (existsSync(CONFIG_FILE)) {
26
+ const configData = readFileSync(CONFIG_FILE, "utf-8");
27
+ return { ...DEFAULT_CONFIG, ...JSON.parse(configData) };
28
+ }
29
+ } catch {
30
+ // Silently fail - use defaults
31
+ }
32
+ return { ...DEFAULT_CONFIG };
33
+ }
34
+
35
+ public getConfig(): Config {
36
+ return { ...this.config };
37
+ }
38
+
39
+ public updateConfig(updates: Partial<Config>): void {
40
+ this.config = { ...this.config, ...updates };
41
+ this.saveConfig();
42
+ }
43
+
44
+ private saveConfig(): void {
45
+ try {
46
+ writeFileSync(CONFIG_FILE, JSON.stringify(this.config, null, 2));
47
+ } catch (error) {
48
+ throw new Error(`Failed to save config: ${error}`);
49
+ }
50
+ }
51
+
52
+ public getConfigPath(): string {
53
+ return CONFIG_FILE;
54
+ }
55
+
56
+ public hasConfig(): boolean {
57
+ return existsSync(CONFIG_FILE);
58
+ }
59
+
60
+ public resetConfig(): void {
61
+ this.config = { ...DEFAULT_CONFIG };
62
+ this.saveConfig();
63
+ }
64
+ }
65
+
66
+ export const configManager = new ConfigManager();
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "esModuleInterop": true,
7
+ "allowSyntheticDefaultImports": true,
8
+ "strict": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "declaration": true,
12
+ "outDir": "./dist",
13
+ "rootDir": "./src",
14
+ "jsx": "react-jsx",
15
+ "types": ["node", "bun-types"]
16
+ },
17
+ "include": ["src/**/*"],
18
+ "exclude": ["node_modules", "dist"]
19
+ }