feat: T1 scaffold — package.json, tsconfig (backend+web), vitest, dirs

- All deps declared once (express5, ws, node-pty, @xterm/xterm6, addon-fit;
  dev: typescript6, tsx, vitest4, @types/node|ws|express)
- postinstall chmod +x node-pty spawn-helper (prebuild ships it non-exec → posix_spawnp fails)
- node-pty verified: require + real PTY spawn (exitCode 0)
- npm test passes with no tests (passWithNoTests)
- tsconfig.web.json type-checks frontend; browser bundling strategy still TBD (see log)

T1 of docs/PLAN.md
This commit is contained in:
Yaojia Wang
2026-06-16 07:21:42 +02:00
parent 91d0a7189f
commit b126cf0e42
13 changed files with 2910 additions and 0 deletions

18
.gitignore vendored Normal file
View File

@@ -0,0 +1,18 @@
# dependencies
node_modules/
# build output
dist/
public/*.js
public/*.js.map
# local Claude Code settings (not shared)
.claude/settings.local.json
# logs / OS cruft
*.log
npm-debug.log*
.DS_Store
# test coverage
coverage/

2804
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

35
package.json Normal file
View File

@@ -0,0 +1,35 @@
{
"name": "web-terminal",
"version": "0.1.0",
"private": true,
"type": "module",
"description": "Browser terminal over WebSocket to the host's local shell (vibe coding). LAN-only, no auth.",
"engines": {
"node": ">=18"
},
"scripts": {
"postinstall": "chmod +x node_modules/node-pty/prebuilds/darwin-*/spawn-helper 2>/dev/null || true",
"start": "tsx src/server.ts",
"dev": "tsx watch src/server.ts",
"build": "tsc -p tsconfig.json",
"build:web": "tsc -p tsconfig.web.json",
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.web.json",
"test": "vitest run",
"test:watch": "vitest"
},
"dependencies": {
"@xterm/addon-fit": "^0.11.0",
"@xterm/xterm": "^6.0.0",
"express": "^5.2.1",
"node-pty": "^1.1.0",
"ws": "^8.21.0"
},
"devDependencies": {
"@types/express": "^5.0.6",
"@types/node": "^25.9.3",
"@types/ws": "^8.18.1",
"tsx": "^4.22.4",
"typescript": "^6.0.3",
"vitest": "^4.1.9"
}
}

0
public/.gitkeep Normal file
View File

0
src/.gitkeep Normal file
View File

0
src/http/.gitkeep Normal file
View File

0
src/session/.gitkeep Normal file
View File

0
test/.gitkeep Normal file
View File

0
test/helpers/.gitkeep Normal file
View File

View File

21
tsconfig.json Normal file
View File

@@ -0,0 +1,21 @@
{
"// note": "Backend (Node) config. Used by `npm run build` (emits dist/) and `npm start` via tsx. Tests are transpiled by vitest (esbuild), not tsc.",
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"lib": ["ES2022"],
"types": ["node"],
"strict": true,
"noUncheckedIndexedAccess": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"rootDir": "src",
"outDir": "dist",
"declaration": false,
"sourceMap": true
},
"include": ["src"]
}

17
tsconfig.web.json Normal file
View File

@@ -0,0 +1,17 @@
{
"// note": "Frontend (browser) config for public/*.ts. moduleResolution Bundler lets bare imports (@xterm/xterm) type-check. NOTE: emits nothing — the actual browser bundle strategy (esbuild/import-map/CDN) is unresolved; see T1 log entry. This config currently serves as type-check for the frontend.",
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"types": [],
"strict": true,
"noUncheckedIndexedAccess": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true
},
"include": ["public"]
}

15
vitest.config.ts Normal file
View File

@@ -0,0 +1,15 @@
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
include: ['test/**/*.test.ts'],
environment: 'node',
// Scaffold has no tests yet; don't fail the script until modules add theirs.
passWithNoTests: true,
// Coverage target is the global 80% rule; enable with `--coverage` once modules exist.
coverage: {
provider: 'v8',
include: ['src/**/*.ts', 'public/**/*.ts'],
},
},
})