rivet-design 0.1.21 → 0.1.23

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 (101) hide show
  1. package/README.md +15 -5
  2. package/dist/config/proxy.d.ts.map +1 -1
  3. package/dist/config/proxy.js +1 -0
  4. package/dist/config/proxy.js.map +1 -1
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +12 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/routes/electron.d.ts +8 -0
  10. package/dist/routes/electron.d.ts.map +1 -0
  11. package/dist/routes/electron.js +64 -0
  12. package/dist/routes/electron.js.map +1 -0
  13. package/dist/routes/git.d.ts.map +1 -1
  14. package/dist/routes/git.js +21 -0
  15. package/dist/routes/git.js.map +1 -1
  16. package/dist/routes/modifications.d.ts +2 -1
  17. package/dist/routes/modifications.d.ts.map +1 -1
  18. package/dist/routes/modifications.js +8 -2
  19. package/dist/routes/modifications.js.map +1 -1
  20. package/dist/server.d.ts.map +1 -1
  21. package/dist/server.js +69 -14
  22. package/dist/server.js.map +1 -1
  23. package/dist/services/AuthService.d.ts +1 -0
  24. package/dist/services/AuthService.d.ts.map +1 -1
  25. package/dist/services/AuthService.js +1 -1
  26. package/dist/services/AuthService.js.map +1 -1
  27. package/dist/services/ConfigManager.d.ts +7 -2
  28. package/dist/services/ConfigManager.d.ts.map +1 -1
  29. package/dist/services/ConfigManager.js +11 -3
  30. package/dist/services/ConfigManager.js.map +1 -1
  31. package/dist/services/ElectronBridgeService.d.ts +121 -0
  32. package/dist/services/ElectronBridgeService.d.ts.map +1 -0
  33. package/dist/services/ElectronBridgeService.js +299 -0
  34. package/dist/services/ElectronBridgeService.js.map +1 -0
  35. package/dist/services/LLMService.d.ts +4 -0
  36. package/dist/services/LLMService.d.ts.map +1 -1
  37. package/dist/services/LLMService.js +48 -1
  38. package/dist/services/LLMService.js.map +1 -1
  39. package/dist/services/LocalGitService.d.ts +5 -0
  40. package/dist/services/LocalGitService.d.ts.map +1 -1
  41. package/dist/services/LocalGitService.js +24 -0
  42. package/dist/services/LocalGitService.js.map +1 -1
  43. package/dist/services/ProjectDetectionService.d.ts +2 -2
  44. package/dist/services/ProjectDetectionService.d.ts.map +1 -1
  45. package/dist/services/ProjectDetectionService.js +12 -6
  46. package/dist/services/ProjectDetectionService.js.map +1 -1
  47. package/dist/services/SessionService.d.ts +1 -0
  48. package/dist/services/SessionService.d.ts.map +1 -1
  49. package/dist/services/SessionService.js +13 -0
  50. package/dist/services/SessionService.js.map +1 -1
  51. package/package.json +3 -1
  52. package/src/ui/dist/assets/main-BOyShc8c.js +217 -0
  53. package/src/ui/dist/assets/main-Bkokm1KG.css +1 -0
  54. package/src/ui/dist/index.html +2 -2
  55. package/dist/jest.config.d.ts +0 -4
  56. package/dist/jest.config.d.ts.map +0 -1
  57. package/dist/jest.config.js +0 -73
  58. package/dist/jest.config.js.map +0 -1
  59. package/dist/proxy/proxy-config.d.ts +0 -2
  60. package/dist/proxy/proxy-config.d.ts.map +0 -1
  61. package/dist/proxy/proxy-config.js +0 -59
  62. package/dist/proxy/proxy-config.js.map +0 -1
  63. package/dist/routes/config.d.ts +0 -2
  64. package/dist/routes/config.d.ts.map +0 -1
  65. package/dist/routes/config.js +0 -16
  66. package/dist/routes/config.js.map +0 -1
  67. package/dist/routes/selection.d.ts +0 -2
  68. package/dist/routes/selection.d.ts.map +0 -1
  69. package/dist/routes/selection.js +0 -32
  70. package/dist/routes/selection.js.map +0 -1
  71. package/dist/scripts/selection-script.js +0 -846
  72. package/dist/services/__tests__/FileModificationService.test.d.ts +0 -2
  73. package/dist/services/__tests__/FileModificationService.test.d.ts.map +0 -1
  74. package/dist/services/__tests__/FileModificationService.test.js +0 -297
  75. package/dist/services/__tests__/FileModificationService.test.js.map +0 -1
  76. package/dist/services/__tests__/LLMService.spec.d.ts +0 -2
  77. package/dist/services/__tests__/LLMService.spec.d.ts.map +0 -1
  78. package/dist/services/__tests__/LLMService.spec.js +0 -270
  79. package/dist/services/__tests__/LLMService.spec.js.map +0 -1
  80. package/dist/services/__tests__/LocalGitService.test.d.ts +0 -2
  81. package/dist/services/__tests__/LocalGitService.test.d.ts.map +0 -1
  82. package/dist/services/__tests__/LocalGitService.test.js +0 -249
  83. package/dist/services/__tests__/LocalGitService.test.js.map +0 -1
  84. package/dist/shared/FileSystemAdapter.d.ts +0 -9
  85. package/dist/shared/FileSystemAdapter.d.ts.map +0 -1
  86. package/dist/shared/FileSystemAdapter.js +0 -7
  87. package/dist/shared/FileSystemAdapter.js.map +0 -1
  88. package/dist/shared/LLMService.d.ts +0 -58
  89. package/dist/shared/LLMService.d.ts.map +0 -1
  90. package/dist/shared/LLMService.js +0 -169
  91. package/dist/shared/LLMService.js.map +0 -1
  92. package/dist/shared/types.d.ts +0 -25
  93. package/dist/shared/types.d.ts.map +0 -1
  94. package/dist/shared/types.js +0 -6
  95. package/dist/shared/types.js.map +0 -1
  96. package/dist/types/types.d.ts +0 -15
  97. package/dist/types/types.d.ts.map +0 -1
  98. package/dist/types/types.js +0 -3
  99. package/dist/types/types.js.map +0 -1
  100. package/src/ui/dist/assets/main-DqRH7DiB.js +0 -144
  101. package/src/ui/dist/assets/main-DuoX_Unn.css +0 -1
@@ -1,249 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const LocalGitService_1 = require("../LocalGitService");
4
- const simple_git_1 = require("simple-git");
5
- jest.mock('simple-git');
6
- const mockSimpleGit = simple_git_1.simpleGit;
7
- describe('LocalGitService', () => {
8
- let service;
9
- // MockGit is a complex object, so we're using any to avoid type errors
10
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
- let mockGit;
12
- beforeEach(() => {
13
- service = new LocalGitService_1.LocalGitService();
14
- mockGit = {
15
- revparse: jest.fn(),
16
- status: jest.fn(),
17
- add: jest.fn(),
18
- commit: jest.fn(),
19
- checkout: jest.fn(),
20
- branch: jest.fn(),
21
- pull: jest.fn(),
22
- checkoutLocalBranch: jest.fn(),
23
- stash: jest.fn(),
24
- addConfig: jest.fn(),
25
- listConfig: jest.fn(),
26
- getRemotes: jest.fn(),
27
- push: jest.fn(),
28
- };
29
- mockSimpleGit.mockReturnValue(mockGit);
30
- });
31
- afterEach(() => {
32
- jest.clearAllMocks();
33
- });
34
- describe('getGitRootPath', () => {
35
- it('should return git instance when project path is already git root', async () => {
36
- const projectPath = '/Users/test/project';
37
- mockGit.revparse.mockResolvedValue('/Users/test/project\n');
38
- const result = await service.getGitRootPath(projectPath);
39
- expect(result).toBe(mockGit);
40
- expect(mockGit.revparse).toHaveBeenCalledWith(['--show-toplevel']);
41
- });
42
- it('should return git instance from root when project path is subdirectory', async () => {
43
- const projectPath = '/Users/test/project/client';
44
- const gitRoot = '/Users/test/project';
45
- mockGit.revparse.mockResolvedValue(`${gitRoot}\n`);
46
- // Create a separate mock for the git root instance
47
- const mockGitRoot = { ...mockGit };
48
- mockSimpleGit
49
- .mockReturnValueOnce(mockGit) // First call for initial git instance
50
- .mockReturnValueOnce(mockGitRoot); // Second call for git root instance
51
- const result = await service.getGitRootPath(projectPath);
52
- expect(result).toBe(mockGitRoot);
53
- expect(mockGit.revparse).toHaveBeenCalledWith(['--show-toplevel']);
54
- expect(mockSimpleGit).toHaveBeenCalledWith(projectPath);
55
- expect(mockSimpleGit).toHaveBeenCalledWith(gitRoot);
56
- });
57
- it('should return null when git root cannot be determined', async () => {
58
- const projectPath = '/Users/test/not-a-git-repo';
59
- mockGit.revparse.mockRejectedValue(new Error('Not a git repository'));
60
- const result = await service.getGitRootPath(projectPath);
61
- expect(result).toBeNull();
62
- expect(mockGit.revparse).toHaveBeenCalledWith(['--show-toplevel']);
63
- });
64
- it('should handle whitespace in git root path', async () => {
65
- const projectPath = '/Users/test/project/client';
66
- const gitRoot = '/Users/test/project';
67
- mockGit.revparse.mockResolvedValue(` ${gitRoot} \n`);
68
- const mockGitRoot = { ...mockGit };
69
- mockSimpleGit
70
- .mockReturnValueOnce(mockGit)
71
- .mockReturnValueOnce(mockGitRoot);
72
- const result = await service.getGitRootPath(projectPath);
73
- expect(result).toBe(mockGitRoot);
74
- expect(mockSimpleGit).toHaveBeenCalledWith(gitRoot); // Should use trimmed path
75
- });
76
- it('should handle paths with special characters', async () => {
77
- const projectPath = '/Users/test/project with spaces/client';
78
- const gitRoot = '/Users/test/project with spaces';
79
- mockGit.revparse.mockResolvedValue(`${gitRoot}\n`);
80
- const mockGitRoot = { ...mockGit };
81
- mockSimpleGit
82
- .mockReturnValueOnce(mockGit)
83
- .mockReturnValueOnce(mockGitRoot);
84
- const result = await service.getGitRootPath(projectPath);
85
- expect(result).toBe(mockGitRoot);
86
- expect(mockSimpleGit).toHaveBeenCalledWith(gitRoot);
87
- });
88
- });
89
- describe('createBranch', () => {
90
- it('should create branch from current branch', async () => {
91
- const projectPath = '/Users/test/project/client';
92
- const branchName = 'test-branch';
93
- // Mock getGitRootPath to return a git instance
94
- const mockGitRoot = {
95
- ...mockGit,
96
- status: jest.fn().mockResolvedValue({
97
- current: 'feature-branch',
98
- modified: [],
99
- created: [],
100
- deleted: [],
101
- }),
102
- checkoutLocalBranch: jest.fn().mockResolvedValue({}),
103
- };
104
- mockGit.revparse.mockResolvedValue('/Users/test/project\n');
105
- mockSimpleGit
106
- .mockReturnValueOnce(mockGit)
107
- .mockReturnValueOnce(mockGitRoot);
108
- await service.createBranch(projectPath, branchName);
109
- expect(mockGitRoot.status).toHaveBeenCalled();
110
- expect(mockGitRoot.checkoutLocalBranch).toHaveBeenCalledWith(branchName);
111
- });
112
- it('should stash files before creating branch if there are uncommitted changes', async () => {
113
- const projectPath = '/Users/test/project';
114
- const branchName = 'test-branch';
115
- const mockGitRoot = {
116
- ...mockGit,
117
- status: jest.fn().mockResolvedValue({
118
- current: 'feature-branch',
119
- modified: ['file1.js', 'file2.js'],
120
- created: ['file3.js'],
121
- deleted: [],
122
- }),
123
- add: jest.fn().mockResolvedValue({}),
124
- stash: jest.fn().mockResolvedValue({}),
125
- checkoutLocalBranch: jest.fn().mockResolvedValue({}),
126
- };
127
- mockGit.revparse.mockResolvedValue('/Users/test/project\n');
128
- mockSimpleGit.mockReturnValue(mockGitRoot);
129
- await service.createBranch(projectPath, branchName);
130
- expect(mockGitRoot.add).toHaveBeenCalledWith('file1.js');
131
- expect(mockGitRoot.add).toHaveBeenCalledWith('file2.js');
132
- expect(mockGitRoot.add).toHaveBeenCalledWith('file3.js');
133
- expect(mockGitRoot.stash).toHaveBeenCalledWith([
134
- 'push',
135
- '-m',
136
- 'Rivet: Stash before new branch creation',
137
- ]);
138
- });
139
- it('should throw error when git root cannot be determined', async () => {
140
- const projectPath = '/Users/test/not-a-git-repo';
141
- const branchName = 'test-branch';
142
- mockGit.revparse.mockRejectedValue(new Error('Not a git repository'));
143
- await expect(service.createBranch(projectPath, branchName)).rejects.toThrow('Could not determine git root');
144
- });
145
- });
146
- describe('commitChange', () => {
147
- const mockChangeRecord = {
148
- id: 'test-id',
149
- timestamp: new Date(),
150
- type: 'llm',
151
- description: 'Test change',
152
- elements: [],
153
- files: [],
154
- };
155
- it('should commit changes from git root', async () => {
156
- const projectPath = '/Users/test/project/client';
157
- const mockGitRoot = {
158
- ...mockGit,
159
- addConfig: jest.fn().mockResolvedValue({}),
160
- status: jest.fn().mockResolvedValue({
161
- modified: ['src/test.js'],
162
- created: [],
163
- deleted: [],
164
- }),
165
- add: jest.fn().mockResolvedValue({}),
166
- commit: jest.fn().mockResolvedValue({ commit: 'abc123' }),
167
- };
168
- mockGit.revparse.mockResolvedValue('/Users/test/project\n');
169
- mockSimpleGit
170
- .mockReturnValueOnce(mockGit)
171
- .mockReturnValueOnce(mockGitRoot);
172
- const result = await service.commitChange(projectPath, mockChangeRecord);
173
- expect(result).toBe('abc123');
174
- expect(mockGitRoot.status).toHaveBeenCalled();
175
- expect(mockGitRoot.add).toHaveBeenCalledWith('src/test.js');
176
- expect(mockGitRoot.commit).toHaveBeenCalled();
177
- });
178
- it('should configure git identity if user info provided', async () => {
179
- const projectPath = '/Users/test/project';
180
- const userInfo = { name: 'Test User', email: 'test@example.com' };
181
- const mockGitRoot = {
182
- ...mockGit,
183
- addConfig: jest.fn().mockResolvedValue({}),
184
- status: jest.fn().mockResolvedValue({
185
- modified: ['src/test.js'],
186
- created: [],
187
- deleted: [],
188
- }),
189
- add: jest.fn().mockResolvedValue({}),
190
- commit: jest.fn().mockResolvedValue({ commit: 'abc123' }),
191
- };
192
- mockGit.revparse.mockResolvedValue('/Users/test/project\n');
193
- mockSimpleGit.mockReturnValue(mockGitRoot);
194
- await service.commitChange(projectPath, mockChangeRecord, userInfo);
195
- expect(mockGitRoot.addConfig).toHaveBeenCalledWith('user.name', 'Test User');
196
- expect(mockGitRoot.addConfig).toHaveBeenCalledWith('user.email', 'test@example.com');
197
- });
198
- it('should throw error when no files to commit', async () => {
199
- const projectPath = '/Users/test/project';
200
- const mockGitRoot = {
201
- ...mockGit,
202
- status: jest.fn().mockResolvedValue({
203
- modified: [],
204
- created: [],
205
- deleted: [],
206
- }),
207
- };
208
- mockGit.revparse.mockResolvedValue('/Users/test/project\n');
209
- mockSimpleGit.mockReturnValue(mockGitRoot);
210
- await expect(service.commitChange(projectPath, mockChangeRecord)).rejects.toThrow('No files available to commit');
211
- });
212
- it('should throw error when git root cannot be determined', async () => {
213
- const projectPath = '/Users/test/not-a-git-repo';
214
- mockGit.revparse.mockRejectedValue(new Error('Not a git repository'));
215
- await expect(service.commitChange(projectPath, mockChangeRecord)).rejects.toThrow('Could not determine git root');
216
- });
217
- });
218
- describe('integration scenarios', () => {
219
- it('should handle real-world path scenarios', async () => {
220
- // Scenario: User runs rivet from /Users/user/project/client
221
- // Git root is at /Users/user/project
222
- const projectPath = '/Users/user/project/client';
223
- const gitRoot = '/Users/user/project';
224
- mockGit.revparse.mockResolvedValue(`${gitRoot}\n`);
225
- const mockGitRoot = { ...mockGit };
226
- mockSimpleGit
227
- .mockReturnValueOnce(mockGit)
228
- .mockReturnValueOnce(mockGitRoot);
229
- const result = await service.getGitRootPath(projectPath);
230
- expect(result).toBe(mockGitRoot);
231
- expect(mockSimpleGit).toHaveBeenNthCalledWith(1, projectPath);
232
- expect(mockSimpleGit).toHaveBeenNthCalledWith(2, gitRoot);
233
- });
234
- it('should handle monorepo scenarios', async () => {
235
- // Scenario: Monorepo with nested git operations
236
- const projectPath = '/Users/user/monorepo/packages/frontend';
237
- const gitRoot = '/Users/user/monorepo';
238
- mockGit.revparse.mockResolvedValue(`${gitRoot}\n`);
239
- const mockGitRoot = { ...mockGit };
240
- mockSimpleGit
241
- .mockReturnValueOnce(mockGit)
242
- .mockReturnValueOnce(mockGitRoot);
243
- const result = await service.getGitRootPath(projectPath);
244
- expect(result).toBe(mockGitRoot);
245
- expect(mockSimpleGit).toHaveBeenCalledWith(gitRoot);
246
- });
247
- });
248
- });
249
- //# sourceMappingURL=LocalGitService.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LocalGitService.test.js","sourceRoot":"","sources":["../../../src/services/__tests__/LocalGitService.test.ts"],"names":[],"mappings":";;AAAA,wDAAqD;AACrD,2CAAkD;AAElD,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACxB,MAAM,aAAa,GAAG,sBAAkD,CAAC;AAIzE,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,OAAwB,CAAC;IAE7B,uEAAuE;IACvE,8DAA8D;IAC9D,IAAI,OAAY,CAAC;IAEjB,UAAU,CAAC,GAAG,EAAE;QACd,OAAO,GAAG,IAAI,iCAAe,EAAE,CAAC;QAChC,OAAO,GAAG;YACR,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAgD;YACjE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;YACjB,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;YACd,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;YACjB,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;YACnB,MAAM,EAAE,IAAI,CAAC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C9D,MAAM,CAAC,aAAa,CAAC,CAAC,uBAAuB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;YAChD,gDAAgD;YAChD,MAAM,WAAW,GAAG,wCAAwC,CAAC;YAC7D,MAAM,OAAO,GAAG,sBAAsB,CAAC;YAEvC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;YAEnD,MAAM,WAAW,GAAG,EAAE,GAAG,OAAO,EAA4B,CAAC;YAC7D,aAAa;iBACV,mBAAmB,CAAC,OAAO,CAAC;iBAC5B,mBAAmB,CAAC,WAAW,CAAC,CAAC;YAEpC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;YAEzD,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACjC,MAAM,CAAC,aAAa,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- /**
2
- * FileSystem adapter interface
3
- * Allows LLMService to work with both Node fs (CLI) and VirtualFileSystem (Web)
4
- */
5
- export interface FileSystemAdapter {
6
- readFile(filePath: string): Promise<string>;
7
- writeFile(filePath: string, content: string): Promise<void>;
8
- }
9
- //# sourceMappingURL=FileSystemAdapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileSystemAdapter.d.ts","sourceRoot":"","sources":["../../src/shared/FileSystemAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * FileSystem adapter interface
4
- * Allows LLMService to work with both Node fs (CLI) and VirtualFileSystem (Web)
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- //# sourceMappingURL=FileSystemAdapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileSystemAdapter.js","sourceRoot":"","sources":["../../src/shared/FileSystemAdapter.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -1,58 +0,0 @@
1
- import { ElementContext } from '../types/change-types';
2
- import { IFileModificationService } from './types';
3
- export type AppliedModificationResult = {
4
- modifiedCode: Array<{
5
- filePath: string;
6
- modifiedCode: string;
7
- changes: string;
8
- }>;
9
- changes: string;
10
- };
11
- export type BE_BoundingRect = {
12
- x: number;
13
- y: number;
14
- width: number;
15
- height: number;
16
- top: number;
17
- left: number;
18
- right: number;
19
- bottom: number;
20
- };
21
- export type BE_ElementContext = {
22
- xpath: string;
23
- tagName: string;
24
- className: string;
25
- id: string;
26
- textContent: string;
27
- attributes: Record<string, string>;
28
- filePath: string;
29
- boundingRect: BE_BoundingRect;
30
- };
31
- type LLMContext = {
32
- element: ElementContext;
33
- componentCode: string;
34
- fileName: string;
35
- };
36
- export type LLMRequest = {
37
- instruction: string;
38
- context: LLMContext;
39
- temperature?: number;
40
- };
41
- export type MultiElementLLMRequest = {
42
- instruction: string;
43
- context: LLMContext[];
44
- temperature?: number;
45
- };
46
- export declare class LLMService {
47
- private log;
48
- private proxyUrl;
49
- private fileModService;
50
- constructor(fileModService: IFileModificationService, proxyUrl?: string);
51
- private makeProxyRequest;
52
- modifyMultipleElements(request: MultiElementLLMRequest): Promise<AppliedModificationResult>;
53
- private groupElementsByFile;
54
- private buildMultiFilePrompt;
55
- private applyMultiFileModifications;
56
- }
57
- export {};
58
- //# sourceMappingURL=LLMService.d.ts.map
@@ -1 +0,0 @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AAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAA8B;IACzC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,cAAc,CAA2B;gBAErC,cAAc,EAAE,wBAAwB,EAAE,QAAQ,CAAC,EAAE,MAAM;YAWzD,gBAAgB;IAoDxB,sBAAsB,CAC1B,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,yBAAyB,CAAC;IA2CrC,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,oBAAoB;YAyDd,2BAA2B;CAsB1C"}
@@ -1,169 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LLMService = void 0;
4
- const zod_1 = require("zod");
5
- const logger_1 = require("../utils/logger");
6
- const ANTHROPIC_MODEL = 'claude-sonnet-4-20250514';
7
- const CLAUDE_MAX_OUTPUT_TOKENS = 8192;
8
- const DEFAULT_PROD_PROXY_URL = 'https://rivet-proxy.onrender.com';
9
- // const DEFAULT_DEV_PROD_PROXY_URL = 'https://rivet-proxy-dev.onrender.com';
10
- // Zod schema for structured LLM responses
11
- const CodeModificationSchema = zod_1.z.object({
12
- modifications: zod_1.z
13
- .array(zod_1.z.object({
14
- filePath: zod_1.z.string().describe('Target file path for this modification'),
15
- search: zod_1.z.string().describe('Exact text to find in this specific file'),
16
- replacement: zod_1.z.string().describe('Replacement text'),
17
- changes: zod_1.z.string().describe('Description of changes for this file'),
18
- }))
19
- .describe('Array of file-specific modifications (can be empty if no changes needed)'),
20
- });
21
- class LLMService {
22
- constructor(fileModService, proxyUrl) {
23
- this.log = (0, logger_1.createLogger)('LLMService');
24
- if (proxyUrl) {
25
- this.proxyUrl = proxyUrl;
26
- }
27
- else {
28
- this.proxyUrl = DEFAULT_PROD_PROXY_URL;
29
- }
30
- this.fileModService = fileModService;
31
- this.log.info(`LLMService initialized with proxy URL: ${this.proxyUrl}`);
32
- }
33
- async makeProxyRequest(prompt, temperature) {
34
- const proxyRequest = {
35
- provider: 'anthropic',
36
- model: ANTHROPIC_MODEL,
37
- messages: [],
38
- prompt,
39
- temperature,
40
- maxTokens: CLAUDE_MAX_OUTPUT_TOKENS,
41
- stream: false,
42
- schema: 'CodeModificationSchema',
43
- };
44
- try {
45
- const response = await fetch(`${this.proxyUrl}/api/llm`, {
46
- method: 'POST',
47
- headers: {
48
- 'Content-Type': 'application/json',
49
- 'X-Rivet-Client': 'rivet-cli',
50
- },
51
- body: JSON.stringify(proxyRequest),
52
- });
53
- if (!response.ok) {
54
- const errorData = await response
55
- .json()
56
- .catch(() => ({ error: 'Unknown error' }));
57
- throw new Error(`Proxy request failed: ${errorData.error || response.statusText}`);
58
- }
59
- const result = await response.json();
60
- if (!result.success || !result.data) {
61
- throw new Error(`Proxy returned error: ${result.error || 'No response data'}`);
62
- }
63
- return result.data;
64
- }
65
- catch (error) {
66
- this.log.error('Proxy request error:', error);
67
- throw new Error(`Proxy request failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
68
- }
69
- }
70
- async modifyMultipleElements(request) {
71
- const { instruction, context, temperature } = request;
72
- // Group elements by file
73
- const elementsByFile = this.groupElementsByFile(context);
74
- // Use new multi-file prompt and schema
75
- const prompt = this.buildMultiFilePrompt(instruction, elementsByFile);
76
- try {
77
- const result = await this.makeProxyRequest(prompt, temperature);
78
- // Validate against multi-file schema
79
- const validation = CodeModificationSchema.safeParse(result);
80
- if (!validation.success) {
81
- this.log.error('Multi-file schema validation failed. Raw response:', result);
82
- throw new Error(`Invalid response format: ${JSON.stringify(validation.error.issues)}`);
83
- }
84
- const appliedModifications = await this.applyMultiFileModifications(validation.data.modifications);
85
- return {
86
- modifiedCode: appliedModifications,
87
- // TODO: Simplify this, changes aren't rendered in UI today
88
- changes: validation.data.modifications
89
- .map((mod) => mod.changes)
90
- .join('\n'),
91
- };
92
- }
93
- catch (error) {
94
- this.log.error('Multi-element modification error:', error);
95
- throw new Error(`Failed to modify multiple elements: ${error instanceof Error ? error.message : 'Unknown error'}`);
96
- }
97
- }
98
- groupElementsByFile(contexts) {
99
- const elementsByFile = new Map();
100
- for (const ctx of contexts) {
101
- if (!elementsByFile.has(ctx.fileName)) {
102
- elementsByFile.set(ctx.fileName, []);
103
- }
104
- elementsByFile.get(ctx.fileName).push(ctx);
105
- }
106
- return elementsByFile;
107
- }
108
- buildMultiFilePrompt(instruction, elementsByFile) {
109
- return `You are a React/TypeScript expert. Analyze these files and apply changes where relevant.
110
-
111
- INSTRUCTION: ${instruction}
112
-
113
- FILES AND ELEMENTS:
114
- ${Array.from(elementsByFile.entries())
115
- .map(([filePath, contexts]) => {
116
- // All contexts for the same file should have the same componentCode
117
- const componentCode = contexts[0].componentCode;
118
- return `
119
- ━━━ FILE: ${filePath} ━━━
120
- SELECTED ELEMENTS: ${contexts
121
- .map((ctx) => `<${ctx.element.tagName}> (classes: "${ctx.element.className || 'none'}", text: "${ctx.element.textContent?.substring(0, 30) || 'none'}")`)
122
- .join(', ')}
123
-
124
- CURRENT CODE:
125
- ${componentCode}
126
- `;
127
- })
128
- .join('\n')}
129
-
130
- REQUIREMENTS:
131
- 1. Search strings must be UNIQUE (appear exactly once in file)
132
- 2. Include 2-3 lines of context to ensure uniqueness
133
- 3. Search strings must EXACTLY match the file content (including whitespace, indentation)
134
- 4. Copy search text character-for-character from the provided code
135
- 5. ALL 4 fields required: filePath, search, replacement, changes
136
-
137
- RETURN THIS JSON FORMAT:
138
- {
139
- "modifications": [
140
- {
141
- "filePath": "path/to/file.tsx",
142
- "search": "unique multi-line block",
143
- "replacement": "modified multi-line block",
144
- "changes": "description of what changed"
145
- }
146
- ]
147
- }
148
-
149
- GOOD: Search for entire JSX blocks with context
150
- GOOD: Modify underlying component code directly
151
- BAD: Inline style changes like "style={{ marginTop: 10 }}"
152
- BAD: Single props like "title={flow.title}" (appears multiple times)
153
-
154
- If no files need modification, return: {"modifications": []}
155
-
156
- RETURN ONLY THE JSON - NO OTHER TEXT.`;
157
- }
158
- async applyMultiFileModifications(modifications) {
159
- this.log.debug(`Applying ${modifications.length} modification(s) using FileModificationService`);
160
- const results = await this.fileModService.applyModifications(modifications);
161
- return results.map((result) => ({
162
- filePath: result.filePath,
163
- modifiedCode: result.modifiedCode,
164
- changes: result.changes,
165
- }));
166
- }
167
- }
168
- exports.LLMService = LLMService;
169
- //# sourceMappingURL=LLMService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LLMService.js","sourceRoot":"","sources":["../../src/shared/LLMService.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,4CAA+C;AAK/C,MAAM,eAAe,GAAG,0BAA0B,CAAC;AACnD,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AAClE,6EAA6E;AAE7E,0CAA0C;AAC1C,MAAM,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IACtC,aAAa,EAAE,OAAC;SACb,KAAK,CACJ,OAAC,CAAC,MAAM,CAAC;QACP,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;QACvE,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;QACvE,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QACpD,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;KACrE,CAAC,CACH;SACA,QAAQ,CACP,0EAA0E,CAC3E;CACJ,CAAC,CAAC;AAqDH,MAAa,UAAU;IAKrB,YAAY,cAAwC,EAAE,QAAiB;QAJ/D,QAAG,GAAG,IAAA,qBAAY,EAAC,YAAY,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MAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;YAChD,OAAO;YACC,QAAQ;qBACC,QAAQ;iBACtB,GAAG,CACF,CAAC,GAAG,EAAE,EAAE,CACN,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,gBAAgB,GAAG,CAAC,OAAO,CAAC,SAAS,IAAI,MAAM,aAAa,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,MAAM,IAAI,CAC7I;iBACA,IAAI,CAAC,IAAI,CAAC;;;EAGf,aAAa;CACd,CAAC;QACA,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;sCA4ByB,CAAC;IACrC,CAAC;IAEO,KAAK,CAAC,2BAA2B,CACvC,aAKE;QAIF,IAAI,CAAC,GAAG,CAAC,KAAK,CACZ,YAAY,aAAa,CAAC,MAAM,gDAAgD,CACjF,CAAC;QAEF,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;QAE5E,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC9B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AA7MD,gCA6MC"}
@@ -1,25 +0,0 @@
1
- /**
2
- * Shared types for CLI and Web
3
- */
4
- export type FileModification = {
5
- filePath: string;
6
- search: string;
7
- replacement: string;
8
- changes: string;
9
- };
10
- export type ModificationResult = {
11
- filePath: string;
12
- originalCode: string;
13
- modifiedCode: string;
14
- changes: string;
15
- modificationsApplied: number;
16
- };
17
- /**
18
- * Interface for file modification services
19
- * Implemented by both Node FileModificationService and VFSFileModificationService
20
- */
21
- export interface IFileModificationService {
22
- applyModifications(modifications: FileModification[]): Promise<ModificationResult[]>;
23
- getActiveLocks(): string[];
24
- }
25
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,kBAAkB,CAChB,aAAa,EAAE,gBAAgB,EAAE,GAChC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACjC,cAAc,IAAI,MAAM,EAAE,CAAC;CAC5B"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- /**
3
- * Shared types for CLI and Web
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
@@ -1,15 +0,0 @@
1
- export type CreatePreviewRequest = {
2
- repoUrl: string;
3
- repoFullName: string;
4
- branch: string;
5
- };
6
- export type CreatePreviewResponse = {
7
- projectId: string;
8
- previewUrl: string;
9
- status: string;
10
- };
11
- export type ApiError = {
12
- error: string;
13
- details?: string;
14
- };
15
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":""}