rivet-design 0.1.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 (80) hide show
  1. package/LICENSE.md +674 -0
  2. package/README.md +112 -0
  3. package/bin/rivet.js +27 -0
  4. package/dist/index-core.d.ts +15 -0
  5. package/dist/index-core.d.ts.map +1 -0
  6. package/dist/index-core.js +38 -0
  7. package/dist/index-core.js.map +1 -0
  8. package/dist/index.d.ts +12 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +217 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/routes/components.d.ts +2 -0
  13. package/dist/routes/components.d.ts.map +1 -0
  14. package/dist/routes/components.js +58 -0
  15. package/dist/routes/components.js.map +1 -0
  16. package/dist/routes/git.d.ts +3 -0
  17. package/dist/routes/git.d.ts.map +1 -0
  18. package/dist/routes/git.js +52 -0
  19. package/dist/routes/git.js.map +1 -0
  20. package/dist/routes/modifications.d.ts +3 -0
  21. package/dist/routes/modifications.d.ts.map +1 -0
  22. package/dist/routes/modifications.js +241 -0
  23. package/dist/routes/modifications.js.map +1 -0
  24. package/dist/routes/selection.d.ts +2 -0
  25. package/dist/routes/selection.d.ts.map +1 -0
  26. package/dist/routes/selection.js +38 -0
  27. package/dist/routes/selection.js.map +1 -0
  28. package/dist/scripts/selection-script.js +724 -0
  29. package/dist/server.d.ts +9 -0
  30. package/dist/server.d.ts.map +1 -0
  31. package/dist/server.js +93 -0
  32. package/dist/server.js.map +1 -0
  33. package/dist/services/ComponentSearchService.d.ts +12 -0
  34. package/dist/services/ComponentSearchService.d.ts.map +1 -0
  35. package/dist/services/ComponentSearchService.js +61 -0
  36. package/dist/services/ComponentSearchService.js.map +1 -0
  37. package/dist/services/FileModificationService.d.ts +29 -0
  38. package/dist/services/FileModificationService.d.ts.map +1 -0
  39. package/dist/services/FileModificationService.js +82 -0
  40. package/dist/services/FileModificationService.js.map +1 -0
  41. package/dist/services/LLMService.d.ts +60 -0
  42. package/dist/services/LLMService.d.ts.map +1 -0
  43. package/dist/services/LLMService.js +201 -0
  44. package/dist/services/LLMService.js.map +1 -0
  45. package/dist/services/LocalGitService.d.ts +33 -0
  46. package/dist/services/LocalGitService.d.ts.map +1 -0
  47. package/dist/services/LocalGitService.js +252 -0
  48. package/dist/services/LocalGitService.js.map +1 -0
  49. package/dist/services/ProjectDetectionService.d.ts +26 -0
  50. package/dist/services/ProjectDetectionService.d.ts.map +1 -0
  51. package/dist/services/ProjectDetectionService.js +147 -0
  52. package/dist/services/ProjectDetectionService.js.map +1 -0
  53. package/dist/services/ScriptInjectionService.d.ts +8 -0
  54. package/dist/services/ScriptInjectionService.d.ts.map +1 -0
  55. package/dist/services/ScriptInjectionService.js +178 -0
  56. package/dist/services/ScriptInjectionService.js.map +1 -0
  57. package/dist/services/SessionService.d.ts +26 -0
  58. package/dist/services/SessionService.d.ts.map +1 -0
  59. package/dist/services/SessionService.js +141 -0
  60. package/dist/services/SessionService.js.map +1 -0
  61. package/dist/types/change-types.d.ts +93 -0
  62. package/dist/types/change-types.d.ts.map +1 -0
  63. package/dist/types/change-types.js +4 -0
  64. package/dist/types/change-types.js.map +1 -0
  65. package/dist/types/proxy-types.d.ts +34 -0
  66. package/dist/types/proxy-types.d.ts.map +1 -0
  67. package/dist/types/proxy-types.js +3 -0
  68. package/dist/types/proxy-types.js.map +1 -0
  69. package/dist/types/types.d.ts +15 -0
  70. package/dist/types/types.d.ts.map +1 -0
  71. package/dist/types/types.js +3 -0
  72. package/dist/types/types.js.map +1 -0
  73. package/dist/utils/logger.d.ts +20 -0
  74. package/dist/utils/logger.d.ts.map +1 -0
  75. package/dist/utils/logger.js +51 -0
  76. package/dist/utils/logger.js.map +1 -0
  77. package/package.json +86 -0
  78. package/src/ui/dist/assets/main-DuNgkeFM.js +105 -0
  79. package/src/ui/dist/assets/main-DzZ9GWvo.css +1 -0
  80. package/src/ui/dist/index.html +14 -0
@@ -0,0 +1,9 @@
1
+ import { CLIOptions } from '.';
2
+ import { Framework } from './services/ProjectDetectionService';
3
+ export declare const DIST_UI_PATH: string;
4
+ export type ServerOptions = Omit<CLIOptions, 'help' | 'version' | 'debug'> & {
5
+ framework: Framework;
6
+ };
7
+ export declare const startServer: (options: ServerOptions) => Promise<void>;
8
+ export default startServer;
9
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;AAK/B,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAI/D,eAAO,MAAM,YAAY,QAAyC,CAAC;AAEnE,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,GAAG;IAC3E,SAAS,EAAE,SAAS,CAAC;CACtB,CAAA;AAKD,eAAO,MAAM,WAAW,GAAU,SAAS,aAAa,KAAG,OAAO,CAAC,IAAI,CAyFtE,CAAC;AAIF,eAAe,WAAW,CAAC"}
package/dist/server.js ADDED
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.startServer = exports.DIST_UI_PATH = void 0;
7
+ const express_1 = __importDefault(require("express"));
8
+ const cors_1 = __importDefault(require("cors"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const index_core_1 = require("./index-core");
11
+ const selection_1 = require("./routes/selection");
12
+ const components_1 = require("./routes/components");
13
+ const modifications_1 = require("./routes/modifications");
14
+ const git_1 = require("./routes/git");
15
+ const log = (0, index_core_1.createLogger)('RivetServer');
16
+ exports.DIST_UI_PATH = path_1.default.join(__dirname, '../src/ui/dist');
17
+ const DEFAULT_PORT = 4000;
18
+ const DEFAULT_USER_PORT = 3000;
19
+ const startServer = async (options) => {
20
+ const { port = DEFAULT_PORT, userPort = DEFAULT_USER_PORT, trackWithGit = false, framework = 'nextjs', injectPath, } = options;
21
+ const sessionService = trackWithGit
22
+ ? new index_core_1.SessionService(process.cwd(), true)
23
+ : null;
24
+ if (sessionService) {
25
+ try {
26
+ await sessionService.initializeSession();
27
+ log.info('Git session initialized successfully');
28
+ }
29
+ catch (error) {
30
+ log.warn('Failed to initialize git session, continuing without git tracking:', error);
31
+ }
32
+ // Setup cleanup on process exit
33
+ const cleanup = async () => {
34
+ log.info('Server shutting down, cleaning up session...');
35
+ try {
36
+ await sessionService.cleanupSession(framework, injectPath);
37
+ }
38
+ catch (error) {
39
+ log.error('Failed to cleanup session:', error);
40
+ }
41
+ };
42
+ process.on('SIGINT', cleanup);
43
+ process.on('SIGTERM', cleanup);
44
+ process.on('exit', cleanup);
45
+ }
46
+ const app = (0, express_1.default)();
47
+ // CORS configuration for local development
48
+ app.use((0, cors_1.default)({
49
+ origin: [`http://localhost:${port}`, `http://127.0.0.1:${port}`],
50
+ credentials: true,
51
+ methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
52
+ allowedHeaders: ['Content-Type', 'Authorization'],
53
+ }));
54
+ app.use(express_1.default.json());
55
+ // Request logging middleware
56
+ app.use((req, res, next) => {
57
+ log.debug(`${req.method} ${req.originalUrl}`);
58
+ next();
59
+ });
60
+ // Serve Rivet UI at /rivet
61
+ app.use('/rivet', express_1.default.static(exports.DIST_UI_PATH));
62
+ log.info(`Serving UI assets from: ${exports.DIST_UI_PATH}`);
63
+ // Redirect root to /rivet
64
+ app.get('/', (req, res) => {
65
+ res.redirect('/rivet');
66
+ });
67
+ // API routes for Rivet functionality
68
+ app.use('/api', (0, selection_1.createSelectionRouter)(userPort));
69
+ app.use('/api', (0, components_1.createComponentRouter)());
70
+ app.use('/api', (0, modifications_1.createModificationRouter)(sessionService));
71
+ app.use('/api', (0, git_1.createGitRouter)(sessionService));
72
+ // Health check
73
+ app.get('/health', (req, res) => {
74
+ res.json({
75
+ status: 'healthy',
76
+ timestamp: new Date().toISOString(),
77
+ ports: {
78
+ rivet: port,
79
+ userDevServer: userPort
80
+ }
81
+ });
82
+ });
83
+ // Start server
84
+ await new Promise((resolve) => {
85
+ app.listen(port, () => {
86
+ log.info(`🎨 Rivet server running on http://localhost:${port}`);
87
+ resolve();
88
+ });
89
+ });
90
+ };
91
+ exports.startServer = startServer;
92
+ exports.default = exports.startServer;
93
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAC9B,gDAAwB;AACxB,gDAAwB;AACxB,6CAA4D;AAE5D,kDAA2D;AAC3D,oDAA4D;AAC5D,0DAAkE;AAClE,sCAA+C;AAG/C,MAAM,GAAG,GAAG,IAAA,yBAAY,EAAC,aAAa,CAAC,CAAC;AAE3B,QAAA,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;AAMnE,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAExB,MAAM,WAAW,GAAG,KAAK,EAAE,OAAsB,EAAiB,EAAE;IACzE,MAAM,EACJ,IAAI,GAAG,YAAY,EACnB,QAAQ,GAAG,iBAAiB,EAC5B,YAAY,GAAG,KAAK,EACpB,SAAS,GAAG,QAAQ,EACpB,UAAU,GACX,GAAG,OAAO,CAAC;IAEZ,MAAM,cAAc,GAAG,YAAY;QACjC,CAAC,CAAC,IAAI,2BAAc,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC;QACzC,CAAC,CAAC,IAAI,CAAC;IAET,IAAI,cAAc,EAAE,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,cAAc,CAAC,iBAAiB,EAAE,CAAC;YACzC,GAAG,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;QACnD,CAAC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C,IAAI,EAAE,CAAC,CAAC;YAChE,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAzFW,QAAA,WAAW,eAyFtB;AAIF,kBAAe,mBAAW,CAAC"}
@@ -0,0 +1,12 @@
1
+ export type ComponentMatch = {
2
+ filePath: string;
3
+ confidence: number;
4
+ };
5
+ export declare class ComponentSearchService {
6
+ private log;
7
+ /**
8
+ * Find components that contain the selected element's className, id, or text
9
+ */
10
+ findMatchingComponents(projectPath: string, element: any): Promise<ComponentMatch[]>;
11
+ }
12
+ //# sourceMappingURL=ComponentSearchService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentSearchService.d.ts","sourceRoot":"","sources":["../../src/services/ComponentSearchService.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAA;AAED,qBAAa,sBAAsB;IACjC,OAAO,CAAC,GAAG,CAA0C;IAErD;;OAEG;IACG,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;CAkD3F"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ComponentSearchService = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const glob_1 = require("glob");
10
+ const logger_1 = require("../utils/logger");
11
+ class ComponentSearchService {
12
+ constructor() {
13
+ this.log = (0, logger_1.createLogger)('ComponentSearchService');
14
+ }
15
+ /**
16
+ * Find components that contain the selected element's className, id, or text
17
+ */
18
+ async findMatchingComponents(projectPath, element) {
19
+ // Get search terms
20
+ const searchTerms = [
21
+ element.className?.split(' ')[0], // First class name
22
+ element.id,
23
+ element.textContent?.trim().substring(0, 30)
24
+ ].filter(term => term && term.length > 2);
25
+ if (searchTerms.length === 0) {
26
+ return [];
27
+ }
28
+ this.log.info(`Searching for: ${searchTerms.join(', ')}`);
29
+ // Determine file patterns based on framework
30
+ const filePatterns = '**/*.{tsx,jsx,ts,js,html,css}';
31
+ // Find component files
32
+ const files = await (0, glob_1.glob)(filePatterns, {
33
+ cwd: projectPath,
34
+ ignore: ['**/node_modules/**', '**/.next/**', '**/dist/**']
35
+ });
36
+ const matches = [];
37
+ // Search each file
38
+ for (const file of files) {
39
+ const filePath = path_1.default.join(projectPath, file);
40
+ const content = fs_1.default.readFileSync(filePath, 'utf-8');
41
+ let confidence = 0;
42
+ for (const term of searchTerms) {
43
+ if (content.includes(term)) {
44
+ confidence += 1;
45
+ }
46
+ }
47
+ if (confidence > 0) {
48
+ matches.push({
49
+ filePath: file,
50
+ confidence,
51
+ });
52
+ }
53
+ }
54
+ // Return top matches
55
+ const topMatches = matches.sort((a, b) => b.confidence - a.confidence).slice(0, 3);
56
+ this.log.debug(`Found ${matches.length} matches, returning top ${topMatches.length}`);
57
+ return topMatches;
58
+ }
59
+ }
60
+ exports.ComponentSearchService = ComponentSearchService;
61
+ //# sourceMappingURL=ComponentSearchService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentSearchService.js","sourceRoot":"","sources":["../../src/services/ComponentSearchService.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,+BAA4B;AAC5B,4CAA+C;AAO/C,MAAa,sBAAsB;IAAnC;QACU,QAAG,GAAG,IAAA,qBAAY,EAAC,wBAAwB,CAAC,CAAC;IAuDvD,CAAC;IArDC;;OAEG;IACH,KAAK,CAAC,sBAAsB,CAAC,WAAmB,EAAE,OAAY;QAC5D,mBAAmB;QACnB,MAAM,WAAW,GAAG;YAClB,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC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QAAQ,EAAE,IAAI;oBACd,UAAU;iBACX,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,qBAAqB;QACrB,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACnF,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,OAAO,CAAC,MAAM,2BAA2B,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QACtF,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAxDD,wDAwDC"}
@@ -0,0 +1,29 @@
1
+ import { ChangeRequest, ElementContext } from '../types/change-types';
2
+ /**
3
+ * Pure code transformation service
4
+ *
5
+ * Takes component code and modification instructions,
6
+ * returns modified code. No file I/O operations.
7
+ */
8
+ export declare class FileModificationService {
9
+ private llmService;
10
+ private log;
11
+ constructor();
12
+ /**
13
+ * Transform component code based on change request
14
+ * @param componentCode The original component source code
15
+ * @param element The selected element context
16
+ * @param change The modification request (CSS or LLM)
17
+ * @param fileName Optional filename for better LLM context
18
+ * @returns Modified component code
19
+ */
20
+ modifyCode(componentCode: string, element: ElementContext, change: ChangeRequest, fileName?: string): Promise<string>;
21
+ /**
22
+ * Generate a simple text diff between original and modified code
23
+ * @param original Original code
24
+ * @param modified Modified code
25
+ * @returns Simple diff string
26
+ */
27
+ generateDiff(original: string, modified: string): string;
28
+ }
29
+ //# sourceMappingURL=FileModificationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileModificationService.d.ts","sourceRoot":"","sources":["../../src/services/FileModificationService.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EAGf,MAAM,uBAAuB,CAAC;AAI/B;;;;;GAKG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,GAAG,CAA2C;;IAMtD;;;;;;;OAOG;IACG,UAAU,CACd,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,aAAa,EACrB,QAAQ,GAAE,MAAwB,GACjC,OAAO,CAAC,MAAM,CAAC;IAqClB;;;;;OAKG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;CAmBzD"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileModificationService = void 0;
4
+ const LLMService_1 = require("./LLMService");
5
+ const logger_1 = require("../utils/logger");
6
+ /**
7
+ * Pure code transformation service
8
+ *
9
+ * Takes component code and modification instructions,
10
+ * returns modified code. No file I/O operations.
11
+ */
12
+ class FileModificationService {
13
+ constructor() {
14
+ this.log = (0, logger_1.createLogger)('FileModificationService');
15
+ this.llmService = new LLMService_1.LLMService();
16
+ }
17
+ /**
18
+ * Transform component code based on change request
19
+ * @param componentCode The original component source code
20
+ * @param element The selected element context
21
+ * @param change The modification request (CSS or LLM)
22
+ * @param fileName Optional filename for better LLM context
23
+ * @returns Modified component code
24
+ */
25
+ async modifyCode(componentCode, element, change, fileName = 'component.tsx') {
26
+ // Generate instruction based on change type
27
+ const instruction = change.type === 'css'
28
+ ? this.llmService.generateCSSPrompt(change.data.styles)
29
+ : change.data.instruction;
30
+ // Prepare LLM request
31
+ const llmRequest = {
32
+ instruction,
33
+ context: {
34
+ element: {
35
+ tagName: element.tagName,
36
+ id: element.id,
37
+ className: element.className,
38
+ textContent: element.textContent,
39
+ attributes: element.attributes || {},
40
+ innerHTML: element.innerHTML,
41
+ computedStyles: element.computedStyles,
42
+ boundingRect: element.boundingRect,
43
+ filePath: element.filePath,
44
+ xpath: element.xpath
45
+ },
46
+ componentCode,
47
+ fileName
48
+ },
49
+ temperature: 0.7
50
+ };
51
+ this.log.info(`Modifying code with ${change.type} change: ${instruction.substring(0, 100)}...`);
52
+ // Get modified code from LLM
53
+ const result = await this.llmService.modifyCode(llmRequest);
54
+ this.log.info(`✅ Code modification result: ${result.changes}`);
55
+ return result.modifiedCode;
56
+ }
57
+ /**
58
+ * Generate a simple text diff between original and modified code
59
+ * @param original Original code
60
+ * @param modified Modified code
61
+ * @returns Simple diff string
62
+ */
63
+ generateDiff(original, modified) {
64
+ const originalLines = original.split('\n');
65
+ const modifiedLines = modified.split('\n');
66
+ let diff = '';
67
+ const maxLines = Math.max(originalLines.length, modifiedLines.length);
68
+ for (let i = 0; i < maxLines; i++) {
69
+ const originalLine = originalLines[i] || '';
70
+ const modifiedLine = modifiedLines[i] || '';
71
+ if (originalLine !== modifiedLine) {
72
+ if (originalLine)
73
+ diff += `- ${originalLine}\n`;
74
+ if (modifiedLine)
75
+ diff += `+ ${modifiedLine}\n`;
76
+ }
77
+ }
78
+ return diff;
79
+ }
80
+ }
81
+ exports.FileModificationService = FileModificationService;
82
+ //# sourceMappingURL=FileModificationService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileModificationService.js","sourceRoot":"","sources":["../../src/services/FileModificationService.ts"],"names":[],"mappings":";;;AAMA,6CAAsD;AACtD,4CAA+C;AAE/C;;;;;GAKG;AACH,MAAa,uBAAuB;IAIlC;QAFQ,QAAG,GAAG,IAAA,qBAAY,EAAC,yBAAyB,CAAC,CAAC;QAGpD,IAAI,CAAC,UAAU,GAAG,IAAI,uBAAU,EAAE,CAAC;IACrC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU,CACd,aAAqB,EACrB,OAAuB,EACvB,MAAqB,EACrB,WAAmB,eAAe;QAElC,4CAA4C;QAC5C,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,KAAK,KAAK;YACvC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAE,MAAM,CAAC,IAAsB,CAAC,MAAM,CAAC;YAC1E,CAAC,CAAE,MAAM,CAAC,IAAsB,CAAC,WAA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AAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAEtE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAC5C,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAE5C,IAAI,YAAY,KAAK,YAAY,EAAE,CAAC;gBAClC,IAAI,YAAY;oBAAE,IAAI,IAAI,KAAK,YAAY,IAAI,CAAC;gBAChD,IAAI,YAAY;oBAAE,IAAI,IAAI,KAAK,YAAY,IAAI,CAAC;YAClD,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAnFD,0DAmFC"}
@@ -0,0 +1,60 @@
1
+ import { z } from 'zod';
2
+ import { ElementContext } from '@rivet/core';
3
+ declare const CodeModificationSchema: z.ZodObject<{
4
+ modifiedCode: z.ZodString;
5
+ changes: z.ZodString;
6
+ }, z.core.$strip>;
7
+ export type CodeModificationResult = z.infer<typeof CodeModificationSchema>;
8
+ export type BE_BoundingRect = {
9
+ x: number;
10
+ y: number;
11
+ width: number;
12
+ height: number;
13
+ top: number;
14
+ left: number;
15
+ right: number;
16
+ bottom: number;
17
+ };
18
+ export type BE_ElementContext = {
19
+ xpath: string;
20
+ tagName: string;
21
+ className: string;
22
+ id: string;
23
+ textContent: string;
24
+ attributes: Record<string, string>;
25
+ filePath: string;
26
+ boundingRect: BE_BoundingRect;
27
+ };
28
+ type LLMContext = {
29
+ element: ElementContext;
30
+ componentCode: string;
31
+ fileName: string;
32
+ };
33
+ export type LLMRequest = {
34
+ instruction: string;
35
+ context: LLMContext;
36
+ temperature?: number;
37
+ };
38
+ export type MultiElementLLMRequest = {
39
+ instruction: string;
40
+ context: LLMContext[];
41
+ temperature?: number;
42
+ };
43
+ export declare class LLMService {
44
+ private log;
45
+ private proxyUrl;
46
+ constructor(proxyUrl?: string);
47
+ private makeProxyRequest;
48
+ modifyCode(request: LLMRequest): Promise<CodeModificationResult>;
49
+ modifyMultipleElements(request: MultiElementLLMRequest): Promise<CodeModificationResult>;
50
+ private buildCodeModificationPrompt;
51
+ private buildMultiElementPrompt;
52
+ private buildCSSFilePrompt;
53
+ private buildReactComponentPrompt;
54
+ /**
55
+ * Generate CSS-specific prompt from style properties
56
+ */
57
+ generateCSSPrompt(styles: Record<string, string>): string;
58
+ }
59
+ export {};
60
+ //# sourceMappingURL=LLMService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LLMService.d.ts","sourceRoot":"","sources":["../../src/services/LLMService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQ7C,QAAA,MAAM,sBAAsB;;;iBAG1B,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAG5E,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,eAAe,CAAC;CAC/B,CAAA;AAGD,KAAK,UAAU,GAAG;IAChB,OAAO,EAAE,cAAc,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,UAAU,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAA;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAA8B;IACzC,OAAO,CAAC,QAAQ,CAAS;gBAEb,QAAQ,CAAC,EAAE,MAAM;YAKf,gBAAgB;IAwCxB,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAqBhE,sBAAsB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAqB9F,OAAO,CAAC,2BAA2B;IAWnC,OAAO,CAAC,uBAAuB;IA2B/B,OAAO,CAAC,kBAAkB;IA2B1B,OAAO,CAAC,yBAAyB;IAiCjC;;OAEG;IACH,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;CAkB1D"}
@@ -0,0 +1,201 @@
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_PROXY_URL = 'https://rivet-proxy.onrender.com';
9
+ // Zod schema for structured LLM responses
10
+ const CodeModificationSchema = zod_1.z.object({
11
+ modifiedCode: zod_1.z.string().describe('The complete updated component code'),
12
+ changes: zod_1.z.string().describe('Description of what was changed'),
13
+ });
14
+ class LLMService {
15
+ constructor(proxyUrl) {
16
+ this.log = (0, logger_1.createLogger)('LLMService');
17
+ this.proxyUrl = proxyUrl || DEFAULT_PROXY_URL;
18
+ }
19
+ async makeProxyRequest(prompt, temperature) {
20
+ const proxyRequest = {
21
+ provider: 'anthropic',
22
+ model: ANTHROPIC_MODEL,
23
+ messages: [],
24
+ prompt,
25
+ temperature,
26
+ maxTokens: CLAUDE_MAX_OUTPUT_TOKENS,
27
+ stream: false,
28
+ schema: 'CodeModificationSchema'
29
+ };
30
+ try {
31
+ const response = await fetch(`${this.proxyUrl}/api/generate`, {
32
+ method: 'POST',
33
+ headers: {
34
+ 'Content-Type': 'application/json',
35
+ 'X-Rivet-Client': 'rivet-cli'
36
+ },
37
+ body: JSON.stringify(proxyRequest)
38
+ });
39
+ if (!response.ok) {
40
+ const errorData = await response.json().catch(() => ({ error: 'Unknown error' }));
41
+ throw new Error(`Proxy request failed: ${errorData.error || response.statusText}`);
42
+ }
43
+ const result = await response.json();
44
+ if (!result.success || !result.data) {
45
+ throw new Error(`Proxy returned error: ${result.error || 'No response data'}`);
46
+ }
47
+ return result.data;
48
+ }
49
+ catch (error) {
50
+ this.log.error('Proxy request error:', error);
51
+ throw new Error(`Proxy request failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
52
+ }
53
+ }
54
+ async modifyCode(request) {
55
+ const { instruction, context, temperature } = request;
56
+ const prompt = this.buildCodeModificationPrompt(instruction, context);
57
+ try {
58
+ const result = await this.makeProxyRequest(prompt, temperature);
59
+ // Validate against our schema (proxy should return structured data)
60
+ const validation = CodeModificationSchema.safeParse(result);
61
+ if (!validation.success) {
62
+ throw new Error(`Invalid response format: ${validation.error.message}`);
63
+ }
64
+ return validation.data;
65
+ }
66
+ catch (error) {
67
+ this.log.error('Code modification error:', error);
68
+ throw new Error(`Failed to modify code: ${error instanceof Error ? error.message : 'Unknown error'}`);
69
+ }
70
+ }
71
+ async modifyMultipleElements(request) {
72
+ const { instruction, context, temperature } = request;
73
+ const prompt = this.buildMultiElementPrompt(instruction, context);
74
+ try {
75
+ const result = await this.makeProxyRequest(prompt, temperature);
76
+ // Validate against our schema (proxy should return structured data)
77
+ const validation = CodeModificationSchema.safeParse(result);
78
+ if (!validation.success) {
79
+ throw new Error(`Invalid response format: ${validation.error.message}`);
80
+ }
81
+ return validation.data;
82
+ }
83
+ catch (error) {
84
+ this.log.error('Multi-element modification error:', error);
85
+ throw new Error(`Failed to modify multiple elements: ${error instanceof Error ? error.message : 'Unknown error'}`);
86
+ }
87
+ }
88
+ buildCodeModificationPrompt(instruction, context) {
89
+ const { element, componentCode, fileName } = context;
90
+ const isCSS = fileName.endsWith('.css') || fileName.endsWith('.scss') || fileName.endsWith('.sass');
91
+ if (isCSS) {
92
+ return this.buildCSSFilePrompt(instruction, context);
93
+ }
94
+ else {
95
+ return this.buildReactComponentPrompt(instruction, context);
96
+ }
97
+ }
98
+ buildMultiElementPrompt(instruction, contexts) {
99
+ return `You are a React/TypeScript / frontend expert. Modify these selected elements based on the user's instruction.
100
+
101
+ ${contexts.map((ctx, i) => `
102
+ ELEMENT ${i + 1}: <${ctx.element.tagName}> in ${ctx.fileName}
103
+ - Classes: ${ctx.element.className || 'none'}
104
+ - ID: ${ctx.element.id || 'none'}
105
+ - Text: "${ctx.element.textContent?.substring(0, 50) || 'none'}"
106
+
107
+ FILE: ${ctx.fileName}
108
+ CURRENT CODE:
109
+ ${ctx.componentCode}
110
+ `).join('\n')}
111
+
112
+ USER INSTRUCTION: ${instruction}
113
+
114
+ Apply the requested changes across these elements. You may need to:
115
+ - Modify individual element styles or content
116
+ - Adjust layout relationships between elements
117
+ - Update parent container layouts
118
+ - Make structural changes to accommodate the request
119
+
120
+ Focus on the primary file that contains most of these elements, and return the complete updated code for that component. If elements span multiple files, prioritize the most important changes.
121
+
122
+ Important: make the smallest changes possible to achieve the user's instruction. Provide the complete modified component code and describe the changes made.`;
123
+ }
124
+ buildCSSFilePrompt(instruction, context) {
125
+ const { element, componentCode } = context;
126
+ return `You are a CSS expert. Modify the following CSS code based on the user's instruction.
127
+
128
+ SELECTED ELEMENT CONTEXT:
129
+ - Tag: ${element.tagName}
130
+ - ID: ${element.id || 'none'}
131
+ - Classes: ${element.className || 'none'}
132
+ - Text Content: "${element.textContent?.trim().substring(0, 50) || 'none'}"
133
+ - Attributes: ${JSON.stringify(element.attributes)}
134
+
135
+ CURRENT CSS FILE:
136
+ ${componentCode}
137
+
138
+ USER INSTRUCTION: ${instruction}
139
+
140
+ REQUIREMENTS:
141
+ - Target the selected element (${element.tagName}) with appropriate selectors
142
+ - Use maximum specificity when necessary (ID > class > tag)
143
+ - Add !important declarations for overriding existing styles when needed
144
+ - Preserve existing CSS structure and maintain file formatting
145
+ - Return the complete updated CSS file
146
+
147
+ Provide the modified CSS code and describe what changes were made.`;
148
+ }
149
+ buildReactComponentPrompt(instruction, context) {
150
+ const { element, componentCode, fileName } = context;
151
+ return `You are a React/TypeScript expert specializing in visual modifications. Modify the component based on the user's instruction.
152
+
153
+ SELECTED ELEMENT CONTEXT:
154
+ - Element: <${element.tagName}>
155
+ - ID: ${element.id || 'none'}
156
+ - Classes: ${element.className || 'none'}
157
+ - Text: "${element.textContent?.trim().substring(0, 50) || 'none'}"
158
+ - Attributes: ${JSON.stringify(element.attributes)}
159
+
160
+ FILE: ${fileName}
161
+ CURRENT CODE:
162
+ ${componentCode}
163
+
164
+ INSTRUCTION: ${instruction}
165
+
166
+ CRITICAL REQUIREMENTS FOR STYLE CHANGES:
167
+ 1. **Use valid React inline styles ONLY**: style={{ color: 'red', backgroundColor: 'blue' }}
168
+ 2. **NEVER use !important in inline styles**: React doesn't support this syntax and it breaks hot reload
169
+ 3. **For strong specificity, use className + CSS instead**: Add a CSS class and use !important there
170
+ 4. **Focus modifications on the selected element**: <${element.tagName}>
171
+ 5. **Preserve all existing functionality**: Don't break props, state, or event handlers
172
+ 6. **Maintain TypeScript types**: Keep all type annotations intact
173
+ 7. **Keep imports/exports unchanged**: Don't modify import statements
174
+ 8. **Return complete component**: Provide the entire updated component code
175
+
176
+ For styling changes, prefer valid inline styles without !important. If you need !important for specificity, create a CSS class instead of using inline styles.
177
+
178
+ Provide the complete modified component and describe the changes made.`;
179
+ }
180
+ /**
181
+ * Generate CSS-specific prompt from style properties
182
+ */
183
+ generateCSSPrompt(styles) {
184
+ const fileName = 'component.tsx'; // Assume component file for CSS prompt
185
+ // Convert camelCase to kebab-case for CSS properties
186
+ const cssEntries = Object.entries(styles).map(([property, value]) => {
187
+ const cssProperty = property.replace(/([A-Z])/g, '-$1').toLowerCase();
188
+ return `${cssProperty}: ${value}`;
189
+ });
190
+ const cssString = cssEntries.join('; ');
191
+ // Use different strategies based on file type
192
+ if (fileName.endsWith('.css') || fileName.endsWith('.scss') || fileName.endsWith('.sass')) {
193
+ return `Apply these CSS styles with maximum specificity: ${cssString}`;
194
+ }
195
+ else {
196
+ return `Apply these inline styles using valid React syntax (no !important): ${cssString}`;
197
+ }
198
+ }
199
+ }
200
+ exports.LLMService = LLMService;
201
+ //# sourceMappingURL=LLMService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LLMService.js","sourceRoot":"","sources":["../../src/services/LLMService.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,4CAA+C;AAI/C,MAAM,eAAe,GAAG,0BAA0B,CAAC;AACnD,MAAM,wBAAwB,GAAG,IAAI,CAAC;AACtC,MAAM,iBAAiB,GAAG,kCAAkC,CAAC;AAE7D,2CAA2C;AAC3C,MAAM,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IACtC,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;IACxE,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;CAChE,CAAC,CAAC;AA+CH,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,CAAC,SAAS,IAAI,MAAM;WAC7B,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,MAAM;gBACjD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC;;QAE1C,QAAQ;;EAEd,aAAa;;eAEA,WAAW;;;;;;uDAM6B,OAAO,CAAC,OAAO;;;;;;;;uEAQC,CAAC;IACtE,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,MAA8B;QAC9C,MAAM,QAAQ,GAAG,eAAe,CAAC,CAAC,uCAAuC;QAEzE,qDAAqD;QACrD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE;YAClE,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;YACtE,OAAO,GAAG,WAAW,KAAK,KAAK,EAAE,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAExC,8CAA8C;QAC9C,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1F,OAAO,oDAAoD,SAAS,EAAE,CAAC;QACzE,CAAC;aAAM,CAAC;YACN,OAAO,uEAAuE,SAAS,EAAE,CAAC;QAC5F,CAAC;IACH,CAAC;CACF;AAlND,gCAkNC"}
@@ -0,0 +1,33 @@
1
+ import { ChangeRecord } from '../types/change-types';
2
+ export type RepoInfo = {
3
+ owner: string;
4
+ repo: string;
5
+ provider: 'github';
6
+ baseUrl: string;
7
+ remoteUrl: string;
8
+ };
9
+ export declare const RIVET_BOT_NAME = "Rivet Bot";
10
+ export declare const RIVET_BOT_EMAIL = "noreply@rivet.dev";
11
+ export declare class LocalGitService {
12
+ private getGit;
13
+ configureDefaultIdentity(projectPath: string): Promise<void>;
14
+ createBranch(projectPath: string, branchName: string): Promise<void>;
15
+ commitChange(projectPath: string, change: ChangeRecord, userInfo?: {
16
+ name: string;
17
+ email: string;
18
+ }): Promise<string>;
19
+ private generateCommitMessage;
20
+ getCurrentBranch(projectPath: string): Promise<string>;
21
+ getStatus(projectPath: string): Promise<{
22
+ hasChanges: boolean;
23
+ branch: string;
24
+ files: string[];
25
+ }>;
26
+ hasUncommittedChanges(projectPath: string): Promise<boolean>;
27
+ getRepositoryInfo(projectPath: string): Promise<RepoInfo>;
28
+ private parseRepoUrl;
29
+ pushBranch(projectPath: string, branchName: string): Promise<void>;
30
+ generatePullRequestUrl(projectPath: string, branchName: string, defaultBranch?: string): Promise<string>;
31
+ private getTrackedFiles;
32
+ }
33
+ //# sourceMappingURL=LocalGitService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalGitService.d.ts","sourceRoot":"","sources":["../../src/services/LocalGitService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAKF,eAAO,MAAM,cAAc,cAAc,CAAC;AAC1C,eAAO,MAAM,eAAe,sBAAsB,CAAC;AAInD,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM;IAIR,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAc5D,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,C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