-
Notifications
You must be signed in to change notification settings - Fork 2
update readme #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
update readme #60
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # dependencies (bun install) | ||
| node_modules | ||
|
|
||
| # output | ||
| out | ||
| dist | ||
| *.tgz | ||
|
|
||
| # code coverage | ||
| coverage | ||
| *.lcov | ||
|
|
||
| # logs | ||
| logs | ||
| _.log | ||
| report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json | ||
|
|
||
| # dotenv environment variable files | ||
| .env | ||
| .env.development.local | ||
| .env.test.local | ||
| .env.production.local | ||
| .env.local | ||
|
|
||
| # caches | ||
| .eslintcache | ||
| .cache | ||
| *.tsbuildinfo | ||
|
|
||
| # IntelliJ based IDEs | ||
| .idea | ||
|
|
||
| # Finder (MacOS) folder config | ||
| .DS_Store | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| --- | ||
| description: Use Bun instead of Node.js, npm, pnpm, or vite. | ||
| globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json" | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| Default to using Bun instead of Node.js. | ||
|
|
||
| - Use `bun <file>` instead of `node <file>` or `ts-node <file>` | ||
| - Use `bun test` instead of `jest` or `vitest` | ||
| - Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild` | ||
| - Use `bun install` instead of `npm install` or `yarn install` or `pnpm install` | ||
| - Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>` | ||
| - Use `bunx <package> <command>` instead of `npx <package> <command>` | ||
| - Bun automatically loads .env, so don't use dotenv. | ||
|
|
||
| ## APIs | ||
|
|
||
| - `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`. | ||
| - `bun:sqlite` for SQLite. Don't use `better-sqlite3`. | ||
|
Comment on lines
+15
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's see if the file structure exists and read CLAUDE.md
find . -path "*/apps/supercode-cli/server/CLAUDE.md" -type fRepository: yashdev9274/supercli Length of output: 101 🏁 Script executed: # Also check for index.ts
find . -path "*/apps/supercode-cli/server/src/index.ts" -type fRepository: yashdev9274/supercli Length of output: 104 🏁 Script executed: # List the directory structure to understand the layout
ls -la apps/supercode-cli/server/ 2>/dev/null || echo "Directory not found"Repository: yashdev9274/supercli Length of output: 598 🏁 Script executed: # Read CLAUDE.md to see the Bun guidance at lines 15-20
cat -n apps/supercode-cli/server/CLAUDE.mdRepository: yashdev9274/supercli Length of output: 3518 🏁 Script executed: # Read the first 10 lines of index.ts to check imports
head -10 apps/supercode-cli/server/src/index.tsRepository: yashdev9274/supercli Length of output: 255 Align the Bun guidance with the scaffolded server. This file says not to use 📝 One way to soften the guidance-- Bun automatically loads .env, so don't use dotenv.
+- Prefer Bun's built-in .env loading for new services; only keep `dotenv` where existing code still depends on it.
## APIs
-- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
+- Prefer `Bun.serve()` for new services. Existing Express servers in this repo are allowed unless they are being migrated.🤖 Prompt for AI Agents |
||
| - `Bun.redis` for Redis. Don't use `ioredis`. | ||
| - `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`. | ||
| - `WebSocket` is built-in. Don't use `ws`. | ||
| - Prefer `Bun.file` over `node:fs`'s readFile/writeFile | ||
| - Bun.$`ls` instead of execa. | ||
|
|
||
| ## Testing | ||
|
|
||
| Use `bun test` to run tests. | ||
|
|
||
| ```ts#index.test.ts | ||
| import { test, expect } from "bun:test"; | ||
|
|
||
| test("hello world", () => { | ||
| expect(1).toBe(1); | ||
| }); | ||
| ``` | ||
|
|
||
| ## Frontend | ||
|
|
||
| Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind. | ||
|
|
||
| Server: | ||
|
|
||
| ```ts#index.ts | ||
| import index from "./index.html" | ||
|
|
||
| Bun.serve({ | ||
| routes: { | ||
| "/": index, | ||
| "/api/users/:id": { | ||
| GET: (req) => { | ||
| return new Response(JSON.stringify({ id: req.params.id })); | ||
| }, | ||
| }, | ||
| }, | ||
| // optional websocket support | ||
| websocket: { | ||
| open: (ws) => { | ||
| ws.send("Hello, world!"); | ||
| }, | ||
| message: (ws, message) => { | ||
| ws.send(message); | ||
| }, | ||
| close: (ws) => { | ||
| // handle close | ||
| } | ||
| }, | ||
| development: { | ||
| hmr: true, | ||
| console: true, | ||
| } | ||
| }) | ||
| ``` | ||
|
|
||
| HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle. | ||
|
|
||
| ```html#index.html | ||
| <html> | ||
| <body> | ||
| <h1>Hello, world!</h1> | ||
| <script type="module" src="./frontend.tsx"></script> | ||
| </body> | ||
| </html> | ||
| ``` | ||
|
|
||
| With the following `frontend.tsx`: | ||
|
|
||
| ```tsx#frontend.tsx | ||
| import React from "react"; | ||
| import { createRoot } from "react-dom/client"; | ||
|
|
||
| // import .css files directly and it works | ||
| import './index.css'; | ||
|
|
||
| const root = createRoot(document.body); | ||
|
|
||
| export default function Frontend() { | ||
| return <h1>Hello, world!</h1>; | ||
| } | ||
|
|
||
| root.render(<Frontend />); | ||
| ``` | ||
|
|
||
| Then, run index.ts | ||
|
|
||
| ```sh | ||
| bun --hot ./index.ts | ||
| ``` | ||
|
|
||
| For more information, read the Bun API docs in `node_modules/bun-types/docs/**.mdx`. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # server | ||
|
|
||
| To install dependencies: | ||
|
|
||
| ```bash | ||
| bun install | ||
| ``` | ||
|
|
||
| To run: | ||
|
|
||
| ```bash | ||
| bun run index.ts | ||
| ``` | ||
|
|
||
| This project was created using `bun init` in bun v1.3.5. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime. |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| { | ||
| "name": "server", | ||
| "version": "1.0.0", | ||
| "main": "src/index.ts", | ||
| "scripts": { | ||
| "dev": "nodemon src/index.ts", | ||
| "start": "bun src/index.ts", | ||
| "build": "tsc", | ||
| "typecheck": "tsc --noEmit" | ||
| }, | ||
| "nodemonConfig": { | ||
| "watch": ["src"], | ||
| "ext": "ts,json", | ||
| "exec": "bun src/index.ts", | ||
| "ignore": ["node_modules"] | ||
| }, | ||
| "type": "module", | ||
| "dependencies": { | ||
| "cors": "^2.8.5", | ||
| "dotenv": "^17.2.3", | ||
| "express": "^5.1.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/cors": "^2.8.17", | ||
| "@types/express": "^5.0.0", | ||
| "@types/node": "^22.0.0", | ||
| "nodemon": "^3.1.0", | ||
| "typescript": "^5.7.0" | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import express from "express"; | ||
| import dotenv from "dotenv"; | ||
|
|
||
| dotenv.config(); | ||
|
|
||
| const port = process.env.PORT || 3004; | ||
| const app = express(); | ||
|
|
||
| app.get("/handle", (req, res)=>{ | ||
| res.send("OK") | ||
| }) | ||
|
|
||
| app.listen(port, () => { | ||
| console.log(`Server is running on port ${port}`); | ||
|
Comment on lines
+6
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check the file exists and read the full context
head -30 apps/supercode-cli/server/src/index.tsRepository: yashdev9274/supercli Length of output: 340 🏁 Script executed: # Search for any existing PORT validation or parsing in the codebase
rg -i "port" apps/supercode-cli/server/src/ -A 2 -B 2Repository: yashdev9274/supercli Length of output: 800 🏁 Script executed: # Check if dotenv is imported and configured
rg "dotenv" apps/supercode-cli/server/src/ -A 2Repository: yashdev9274/supercli Length of output: 345 Normalize and validate
🔧 Proposed fix dotenv.config();
-const port = process.env.PORT || 3004;
+const rawPort = process.env.PORT;
+const port = rawPort ? Number(rawPort) : 3004;
+if (!Number.isInteger(port) || port < 0 || port > 65535) {
+ throw new Error(`Invalid PORT: ${rawPort}`);
+}
const app = express();🤖 Prompt for AI Agents |
||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "compilerOptions": { | ||
| // Environment setup & latest features | ||
| "lib": ["ESNext"], | ||
| "target": "ESNext", | ||
| "module": "Preserve", | ||
| "moduleDetection": "force", | ||
| "jsx": "react-jsx", | ||
| "allowJs": true, | ||
|
|
||
| // Bundler mode | ||
| "moduleResolution": "bundler", | ||
| "allowImportingTsExtensions": true, | ||
| "verbatimModuleSyntax": true, | ||
| "noEmit": true, | ||
|
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Checking package.json build script ==="
cat -n apps/supercode-cli/server/package.json | head -15
echo ""
echo "=== Checking tsconfig.json compiler options ==="
cat -n apps/supercode-cli/server/tsconfig.json | head -20Repository: yashdev9274/supercli Length of output: 1215
Line 15 sets Either remove 🤖 Prompt for AI Agents |
||
|
|
||
| // Best practices | ||
| "strict": true, | ||
| "skipLibCheck": true, | ||
| "noFallthroughCasesInSwitch": true, | ||
| "noUncheckedIndexedAccess": true, | ||
| "noImplicitOverride": true, | ||
|
|
||
| // Some stricter flags (disabled by default) | ||
| "noUnusedLocals": false, | ||
| "noUnusedParameters": false, | ||
| "noPropertyAccessFromIndexSignature": false | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the log-file globs.
_.logonly matches a literal underscore filename, and the crash-report pattern is missing*. Most generated logs will still show up as untracked.🧹 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents