vigthoria-cli 1.6.1 → 1.6.4

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 (46) hide show
  1. package/README.md +52 -1
  2. package/dist/commands/chat.d.ts +31 -45
  3. package/dist/commands/chat.d.ts.map +1 -1
  4. package/dist/commands/chat.js +374 -855
  5. package/dist/commands/chat.js.map +1 -1
  6. package/dist/commands/repo.d.ts +10 -0
  7. package/dist/commands/repo.d.ts.map +1 -1
  8. package/dist/commands/repo.js +215 -97
  9. package/dist/commands/repo.js.map +1 -1
  10. package/dist/index.js +32 -4
  11. package/dist/index.js.map +1 -1
  12. package/dist/utils/api.d.ts +8 -0
  13. package/dist/utils/api.d.ts.map +1 -1
  14. package/dist/utils/api.js +183 -42
  15. package/dist/utils/api.js.map +1 -1
  16. package/dist/utils/config.d.ts.map +1 -1
  17. package/dist/utils/config.js +2 -1
  18. package/dist/utils/config.js.map +1 -1
  19. package/dist/utils/tools.d.ts +3 -0
  20. package/dist/utils/tools.d.ts.map +1 -1
  21. package/dist/utils/tools.js +252 -14
  22. package/dist/utils/tools.js.map +1 -1
  23. package/package.json +13 -2
  24. package/install.ps1 +0 -290
  25. package/install.sh +0 -307
  26. package/src/commands/auth.ts +0 -226
  27. package/src/commands/chat.ts +0 -1101
  28. package/src/commands/config.ts +0 -306
  29. package/src/commands/deploy.ts +0 -609
  30. package/src/commands/edit.ts +0 -310
  31. package/src/commands/explain.ts +0 -115
  32. package/src/commands/generate.ts +0 -222
  33. package/src/commands/hub.ts +0 -382
  34. package/src/commands/repo.ts +0 -742
  35. package/src/commands/review.ts +0 -186
  36. package/src/index.ts +0 -601
  37. package/src/types/marked-terminal.d.ts +0 -31
  38. package/src/utils/api.ts +0 -526
  39. package/src/utils/config.ts +0 -241
  40. package/src/utils/files.ts +0 -273
  41. package/src/utils/logger.ts +0 -130
  42. package/src/utils/session.ts +0 -179
  43. package/src/utils/tools.ts +0 -1964
  44. package/test-parse.js +0 -105
  45. package/test-parse2.js +0 -35
  46. package/tsconfig.json +0 -20
@@ -1,179 +0,0 @@
1
- /**
2
- * Session Manager - Persist and resume conversations
3
- * Similar to Vigthoria's session persistence
4
- */
5
-
6
- import * as fs from 'fs';
7
- import * as path from 'path';
8
- import * as os from 'os';
9
- import { ChatMessage } from './api.js';
10
-
11
- export interface Session {
12
- id: string;
13
- name: string;
14
- project: string;
15
- model: string;
16
- messages: ChatMessage[];
17
- createdAt: string;
18
- updatedAt: string;
19
- agentMode: boolean;
20
- }
21
-
22
- export class SessionManager {
23
- private sessionsDir: string;
24
-
25
- constructor() {
26
- this.sessionsDir = path.join(os.homedir(), '.vigthoria', 'sessions');
27
- this.ensureDir();
28
- }
29
-
30
- private ensureDir(): void {
31
- try {
32
- if (!fs.existsSync(this.sessionsDir)) {
33
- fs.mkdirSync(this.sessionsDir, { recursive: true, mode: 0o755 });
34
- }
35
- } catch (error: any) {
36
- // On permission errors, try alternative location
37
- if (error.code === 'EACCES' || error.code === 'EPERM') {
38
- // Fallback to temp directory
39
- this.sessionsDir = path.join(os.tmpdir(), 'vigthoria-sessions');
40
- if (!fs.existsSync(this.sessionsDir)) {
41
- fs.mkdirSync(this.sessionsDir, { recursive: true });
42
- }
43
- }
44
- // Silently continue if directory creation fails
45
- }
46
- }
47
-
48
- /**
49
- * Generate unique session ID
50
- */
51
- private generateId(): string {
52
- const timestamp = Date.now().toString(36);
53
- const random = Math.random().toString(36).substring(2, 8);
54
- return `${timestamp}-${random}`;
55
- }
56
-
57
- /**
58
- * Create a new session
59
- */
60
- create(project: string, model: string, agentMode: boolean = false): Session {
61
- const session: Session = {
62
- id: this.generateId(),
63
- name: `Session ${new Date().toLocaleString()}`,
64
- project,
65
- model,
66
- messages: [],
67
- createdAt: new Date().toISOString(),
68
- updatedAt: new Date().toISOString(),
69
- agentMode,
70
- };
71
-
72
- this.save(session);
73
- return session;
74
- }
75
-
76
- /**
77
- * Save session to disk
78
- */
79
- save(session: Session): void {
80
- session.updatedAt = new Date().toISOString();
81
- const filePath = path.join(this.sessionsDir, `${session.id}.json`);
82
- fs.writeFileSync(filePath, JSON.stringify(session, null, 2), 'utf-8');
83
- }
84
-
85
- /**
86
- * Load session by ID
87
- */
88
- load(id: string): Session | null {
89
- const filePath = path.join(this.sessionsDir, `${id}.json`);
90
-
91
- if (!fs.existsSync(filePath)) {
92
- return null;
93
- }
94
-
95
- try {
96
- const content = fs.readFileSync(filePath, 'utf-8');
97
- return JSON.parse(content) as Session;
98
- } catch {
99
- return null;
100
- }
101
- }
102
-
103
- /**
104
- * Get the most recent session for a project
105
- */
106
- getLatest(project: string): Session | null {
107
- const sessions = this.list();
108
- const projectSessions = sessions
109
- .filter(s => s.project === project)
110
- .sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime());
111
-
112
- return projectSessions.length > 0 ? this.load(projectSessions[0].id) : null;
113
- }
114
-
115
- /**
116
- * List all sessions (metadata only)
117
- */
118
- list(): Omit<Session, 'messages'>[] {
119
- const files = fs.readdirSync(this.sessionsDir)
120
- .filter(f => f.endsWith('.json'));
121
-
122
- return files.map(f => {
123
- try {
124
- const content = fs.readFileSync(path.join(this.sessionsDir, f), 'utf-8');
125
- const session = JSON.parse(content) as Session;
126
- // Return without messages for efficiency
127
- const { messages, ...metadata } = session;
128
- return { ...metadata, messages: [] };
129
- } catch {
130
- return null;
131
- }
132
- }).filter(Boolean) as Omit<Session, 'messages'>[];
133
- }
134
-
135
- /**
136
- * Delete a session
137
- */
138
- delete(id: string): boolean {
139
- const filePath = path.join(this.sessionsDir, `${id}.json`);
140
-
141
- if (fs.existsSync(filePath)) {
142
- fs.unlinkSync(filePath);
143
- return true;
144
- }
145
-
146
- return false;
147
- }
148
-
149
- /**
150
- * Clear all sessions
151
- */
152
- clearAll(): number {
153
- const files = fs.readdirSync(this.sessionsDir)
154
- .filter(f => f.endsWith('.json'));
155
-
156
- files.forEach(f => fs.unlinkSync(path.join(this.sessionsDir, f)));
157
- return files.length;
158
- }
159
-
160
- /**
161
- * Add message to session
162
- */
163
- addMessage(session: Session, message: ChatMessage): void {
164
- session.messages.push(message);
165
- this.save(session);
166
- }
167
-
168
- /**
169
- * Get session summary for display
170
- */
171
- getSummary(session: Session): string {
172
- const userMessages = session.messages.filter(m => m.role === 'user');
173
- const preview = userMessages.length > 0
174
- ? userMessages[0].content.substring(0, 50) + '...'
175
- : 'Empty session';
176
-
177
- return `[${session.id}] ${preview} (${userMessages.length} messages)`;
178
- }
179
- }