evgenyigumnov / rustsn

This Rust-based tool generates, compiles, and tests code using LLMs, resolves dependencies, and provides explanations of existing code through embeddings.
Apache License 2.0
60 stars 15 forks source link

Add JavaScript support #2

Closed evgenyigumnov closed 1 month ago

evgenyigumnov commented 1 month ago
  1. create folder "javascript"
  2. create copy of "prompt.txt" in folder "javascript"

Launch example

rustsn --lang=javascript

Example query:

take 2 params and add them and return result

Example generation:

package.json

{
  "name": "solution",
  "version": "1.0.0",
  "description": "Minimalistic project",
  "main": "src/solution.js",
  "scripts": {
    "test": "jest",
    "build": "webpack  --mode development"
  },
  "devDependencies": {
    "jest": "^29.0.0"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

src/solution.js

function solution(a, b) {
  return a + b;
}

module.exports = solution;

src/solution.test.js

const solution= require('./solution');

test('test1', () => {
  expect(solution(1, 2)).toBe(3);
});

test('test2', () => {
  expect(solution(-1, -2)).toBe(-3);
});

test('test3', () => {
  expect(solution('1', 2)).toBe('12');
});

Example install dependecies

npm install

Example launch compilation

npm run build

Example launch test

npm test