diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..036b376 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,12 @@ +name: CI +on: + pull_request: + push: + +jobs: + typecheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: npm i + - run: tsc diff --git a/package.json b/package.json index 6658106..fa09617 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "test": "vitest run" }, "devDependencies": { + "@types/node": "20.14.2", + "typescript": "5.4.5", "vitest": "1.6.0" } } diff --git a/src/chat.js b/src/chat.js index ce33c66..2009d96 100644 --- a/src/chat.js +++ b/src/chat.js @@ -11,6 +11,9 @@ const systemPrompt = 'You are a machine learning web application named "hyperpar 'The quickest way to get started is to upload a dataset and start exploring.' const messages = [{ role: 'system', content: systemPrompt }] +/** + * @param {Object} chatInput + */ function sendToServer(chatInput) { return new Promise((resolve, reject) => { const json = JSON.stringify(chatInput) @@ -44,6 +47,9 @@ function sendToServer(chatInput) { }) } +/** + * @param {string[]} args + */ function write(...args) { args.forEach(s => process.stdout.write(s)) } @@ -60,7 +66,7 @@ function chat() { write(colors.system, 'question: ', colors.normal) - process.stdin.on('data', async (input) => { + process.stdin.on('data', async (/** @type {string} */ input) => { input = input.trim() if (input === 'exit') { process.exit() diff --git a/src/cli.js b/src/cli.js index 19bbd0c..b0c029a 100644 --- a/src/cli.js +++ b/src/cli.js @@ -2,7 +2,6 @@ if (process.argv[2] === 'chat') { require('./chat').chat() - return } else { console.log('usage: hyperparam chat') } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..c3afbc1 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "lib": ["esnext", "dom"], + "module": "nodenext", + "noEmit": true, + "resolveJsonModule": true, + "strict": true, + }, + "include": ["src", "test"] +}