@cdoing/opentuicli 0.1.21 → 0.1.26

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.
@@ -1,107 +0,0 @@
1
- /**
2
- * Settings Store — Zustand + persist (file-backed)
3
- *
4
- * Persists user preferences to ~/.cdoing/tui-settings.json so they
5
- * survive across sessions: theme, mode, provider, model, sidebar, etc.
6
- */
7
-
8
- import * as fs from "fs";
9
- import * as path from "path";
10
- import * as os from "os";
11
- import { create } from "zustand";
12
- import { persist, createJSONStorage, type StateStorage } from "zustand/middleware";
13
-
14
- // ── File-backed storage adapter ─────────────────────────
15
-
16
- const SETTINGS_PATH = path.join(os.homedir(), ".cdoing", "tui-settings.json");
17
-
18
- const fileStorage: StateStorage = {
19
- getItem: (name: string): string | null => {
20
- try {
21
- if (!fs.existsSync(SETTINGS_PATH)) return null;
22
- const data = JSON.parse(fs.readFileSync(SETTINGS_PATH, "utf-8"));
23
- return JSON.stringify(data[name] ?? null);
24
- } catch {
25
- return null;
26
- }
27
- },
28
- setItem: (name: string, value: string): void => {
29
- try {
30
- const dir = path.dirname(SETTINGS_PATH);
31
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
32
- let data: Record<string, unknown> = {};
33
- try {
34
- if (fs.existsSync(SETTINGS_PATH)) {
35
- data = JSON.parse(fs.readFileSync(SETTINGS_PATH, "utf-8"));
36
- }
37
- } catch {}
38
- data[name] = JSON.parse(value);
39
- fs.writeFileSync(SETTINGS_PATH, JSON.stringify(data, null, 2), "utf-8");
40
- } catch {}
41
- },
42
- removeItem: (name: string): void => {
43
- try {
44
- if (!fs.existsSync(SETTINGS_PATH)) return;
45
- const data = JSON.parse(fs.readFileSync(SETTINGS_PATH, "utf-8"));
46
- delete data[name];
47
- fs.writeFileSync(SETTINGS_PATH, JSON.stringify(data, null, 2), "utf-8");
48
- } catch {}
49
- },
50
- };
51
-
52
- // ── Settings State ──────────────────────────────────────
53
-
54
- export interface SettingsState {
55
- // Appearance
56
- themeId: string;
57
- mode: "dark" | "light";
58
- syncTerminalBg: boolean;
59
- sidebarMode: "auto" | "show" | "hide";
60
-
61
- // Provider / model
62
- provider: string;
63
- model: string;
64
-
65
- // Actions
66
- setThemeId: (id: string) => void;
67
- setMode: (mode: "dark" | "light") => void;
68
- setSyncTerminalBg: (sync: boolean) => void;
69
- setSidebarMode: (mode: "auto" | "show" | "hide") => void;
70
- setProvider: (provider: string) => void;
71
- setModel: (model: string) => void;
72
- }
73
-
74
- export const useSettingsStore = create<SettingsState>()(
75
- persist(
76
- (set) => ({
77
- // Defaults
78
- themeId: "vercel",
79
- mode: "dark",
80
- syncTerminalBg: true,
81
- sidebarMode: "auto",
82
- provider: "anthropic",
83
- model: "",
84
-
85
- // Actions
86
- setThemeId: (themeId) => set({ themeId }),
87
- setMode: (mode) => set({ mode }),
88
- setSyncTerminalBg: (syncTerminalBg) => set({ syncTerminalBg }),
89
- setSidebarMode: (sidebarMode) => set({ sidebarMode }),
90
- setProvider: (provider) => set({ provider }),
91
- setModel: (model) => set({ model }),
92
- }),
93
- {
94
- name: "tui-settings",
95
- storage: createJSONStorage(() => fileStorage),
96
- // Only persist these keys (not actions)
97
- partialize: (state) => ({
98
- themeId: state.themeId,
99
- mode: state.mode,
100
- syncTerminalBg: state.syncTerminalBg,
101
- sidebarMode: state.sidebarMode,
102
- provider: state.provider,
103
- model: state.model,
104
- }),
105
- },
106
- ),
107
- );
package/tsconfig.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "outDir": "dist",
7
- "rootDir": "src",
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "declaration": true,
12
- "declarationMap": true,
13
- "sourceMap": true,
14
- "resolveJsonModule": true,
15
- "jsx": "react-jsx",
16
- "jsxImportSource": "@opentui/react",
17
- "lib": ["ESNext", "DOM", "DOM.Iterable"],
18
- "types": [],
19
- "noEmit": true
20
- },
21
- "include": ["src/**/*"],
22
- "exclude": ["node_modules", "dist"]
23
- }