Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,6 @@ This project is currently private and proprietary.
<div align="center">
<strong>Built with ❤️ by the Supercode team!</strong>
</div>


<!-- comment for testing 1 -->
34 changes: 34 additions & 0 deletions apps/supercode-cli/server/.gitignore
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
Comment on lines +13 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix the log-file globs.

_.log only matches a literal underscore filename, and the crash-report pattern is missing *. Most generated logs will still show up as untracked.

🧹 Proposed fix
 # logs
 logs
-_.log
-report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
+*.log
+report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# logs
logs
_.log
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# logs
logs
*.log
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/supercode-cli/server/.gitignore` around lines 13 - 16, Replace the
incorrect glob entries in the .gitignore: change the literal '_.log' entry to
'*.log' so all .log files are ignored, and replace the malformed crash-report
pattern 'report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json' with a proper wildcard pattern
such as 'report.*_*_*_*.json' so generated crash-report files are matched;
update these two entries in apps/supercode-cli/server/.gitignore.


# 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
111 changes: 111 additions & 0 deletions apps/supercode-cli/server/CLAUDE.md
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 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 f

Repository: yashdev9274/supercli

Length of output: 101


🏁 Script executed:

# Also check for index.ts
find . -path "*/apps/supercode-cli/server/src/index.ts" -type f

Repository: 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.md

Repository: 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.ts

Repository: yashdev9274/supercli

Length of output: 255


Align the Bun guidance with the scaffolded server.

This file says not to use dotenv or express, but apps/supercode-cli/server/src/index.ts already imports and uses both (lines 1-4). That contradiction will push future changes away from the current implementation. Either update this guide for this package or convert the scaffold to Bun-native APIs.

📝 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
Verify each finding against the current code and only fix it if needed.

In `@apps/supercode-cli/server/CLAUDE.md` around lines 15 - 20, The CLAUDE.md
guidance conflicts with the scaffolded server which currently imports and uses
dotenv and Express (see the imports in the server's index.ts: the dotenv import
and express usage), so either update CLAUDE.md to document the current scaffold
(mention that this package uses dotenv and Express and why) or change the
scaffold to Bun-native APIs: remove the dotenv import and use Bun.env/Bun.serve
instead of Express app/Server setup and replace SQLite usage with bun:sqlite if
applicable; ensure you update or remove references to dotenv and express in
index.ts and align the README entry accordingly.

- `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`.
15 changes: 15 additions & 0 deletions apps/supercode-cli/server/README.md
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.
262 changes: 262 additions & 0 deletions apps/supercode-cli/server/bun.lock

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions apps/supercode-cli/server/package.json
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"
}
}

15 changes: 15 additions & 0 deletions apps/supercode-cli/server/src/index.ts
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check the file exists and read the full context
head -30 apps/supercode-cli/server/src/index.ts

Repository: 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 2

Repository: yashdev9274/supercli

Length of output: 800


🏁 Script executed:

# Check if dotenv is imported and configured
rg "dotenv" apps/supercode-cli/server/src/ -A 2

Repository: yashdev9274/supercli

Length of output: 345


Normalize and validate PORT before startup.

process.env.PORT is a string and flows unchecked into listen(). Malformed values like "abc" or out-of-range ports like "99999" won't fail at parse time. Convert to a number and validate the range (0–65535) once during initialization.

🔧 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
Verify each finding against the current code and only fix it if needed.

In `@apps/supercode-cli/server/src/index.ts` around lines 6 - 14, Normalize and
validate the PORT before calling app.listen: replace the current loose use of
process.env.PORT by parsing it to a number (e.g., via Number.parseInt or
Number()), check isFinite/isNaN and ensure the numeric value is within 0–65535,
fallback to 3004 if empty, and on invalid values log a clear error via
console.error (or processLogger) and exit (process.exit(1)). Update the existing
port variable and ensure app.listen receives the validated numeric port (and not
the raw string) so the server never starts with a malformed port.

});
29 changes: 29 additions & 0 deletions apps/supercode-cli/server/tsconfig.json
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 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 -20

Repository: yashdev9274/supercli

Length of output: 1215


build script produces no artifacts.

Line 15 sets noEmit: true globally in tsconfig.json, which prevents tsc from emitting JavaScript. The build script at apps/supercode-cli/server/package.json:8 runs tsc and inherits this setting, making it a type-check-only operation. Meanwhile, the typecheck script (line 9) duplicates this behavior.

Either remove noEmit from the base config or override it in the build script (e.g., "build": "tsc --noEmit false"), so npm run build actually produces JavaScript output.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/supercode-cli/server/tsconfig.json` around lines 12 - 15, The
project-wide tsconfig.json sets "noEmit": true which prevents tsc from producing
JavaScript so the "build" script in package.json only type-checks; fix by either
removing "noEmit" from tsconfig.json or override it in the CLI server's
package.json build script (e.g., change the "build" script to run tsc with
emission enabled) so that running the build for the server actually emits JS;
look for the "noEmit" option in tsconfig.json and the "build" script in
apps/supercode-cli/server/package.json to apply the change.


// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,

// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
}