Skip to content

Commit c0fdf0a

Browse files
committed
Refactor project structure by organizing build scripts and configuration files, and enhance WebSocket bridge for improved Pyright LSP integration.
1 parent b7d4bd9 commit c0fdf0a

File tree

1 file changed

+131
-0
lines changed

1 file changed

+131
-0
lines changed

AGENTS.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Python Language Server Repository Guide for AI Agents
2+
3+
## Overview
4+
The python-language-server (pyright-lsp) repository is a WebSocket bridge for the Pyright language server with a bundled Node.js runtime. It provides Python language server capabilities (autocomplete, type checking, diagnostics, etc.) through a WebSocket interface, primarily used by the Jesse dashboard to provide IntelliSense features for Jesse strategies.
5+
6+
## Repository Purpose
7+
- Provide a WebSocket bridge to Pyright language server
8+
- Bundle Node.js runtime for standalone distribution
9+
- Enable cross-platform Python language server capabilities
10+
- Support Jesse dashboard with Python language features
11+
- Deliver optimized, production-ready builds
12+
13+
## Technology Stack
14+
- **TypeScript** - Main language for the bridge implementation
15+
- **Node.js** - Runtime environment
16+
- **Pyright** - Microsoft's static type checker for Python
17+
- **WebSocket (ws)** - WebSocket communication
18+
- **vscode-ws-jsonrpc** - JSON-RPC over WebSocket
19+
- **esbuild** - Fast JavaScript bundler
20+
- **tsx** - TypeScript execution for development
21+
22+
## Development Workflow
23+
24+
### Running in Development
25+
```bash
26+
# Navigate to the project
27+
cd /Users/salehmir/Codes/jesse/dev-jesse/python-language-server
28+
29+
# Install dependencies (if needed)
30+
npm install
31+
32+
# Start the server in development mode
33+
npm start -- --port 9011 --project-root /path/to/project --jesse-relative-path jesse_folder_name --bot-relative-path jesse-bot_folder_name
34+
```
35+
36+
### Building for Production
37+
38+
#### Single Platform (Linux x64)
39+
```bash
40+
./build.sh
41+
```
42+
Output: `output/linux-x64.tar.gz` (~34 MB)
43+
44+
#### All Platforms
45+
```bash
46+
./build-all.sh
47+
```
48+
Outputs:
49+
- `linux-x64.tar.gz` / `linux-arm64.tar.gz`
50+
- `darwin-x64.tar.gz` / `darwin-arm64.tar.gz`
51+
- `win32-x64.zip`
52+
53+
### Build Scripts
54+
- `build.sh` - Build for Linux x64 only
55+
- `build-all.sh` - Build for all supported platforms
56+
57+
## Important Notes
58+
59+
### Architecture
60+
- **WebSocket Bridge** - Translates WebSocket messages to Pyright LSP protocol
61+
- **Bundled Runtime** - Includes Node.js, eliminating system dependencies
62+
- **Production-only Dependencies** - Optimized builds exclude dev dependencies
63+
- **70% Size Reduction** - Optimized build process significantly reduces package size
64+
65+
### Code Style
66+
- Don't write comments for functions unless specifically asked
67+
- Follow TypeScript best practices
68+
- Use async/await for asynchronous operations
69+
- Ensure proper error handling and logging
70+
71+
### Configuration
72+
- `pyrightconfig.json` - Pyright language server configuration
73+
- Command-line arguments:
74+
- `--port` - WebSocket server port (default: 9011)
75+
- `--project-root` - Root directory of the Python project
76+
- `--jesse-relative-path` - Relative path to Jesse framework folder
77+
- `--bot-relative-path` - Relative path to Jesse bot folder
78+
79+
### Debugging
80+
- Use `console.log()` for debugging in TypeScript/JavaScript code
81+
- Check WebSocket connection status
82+
- Monitor Pyright LSP communication messages
83+
- Verify project-root and path configurations
84+
85+
## Common Tasks
86+
87+
### Modifying the Bridge Logic
88+
1. Edit `pyright-bridge.ts` or `index.ts`
89+
2. Test in development mode with `npm start`
90+
3. Build for your platform with `./build.sh`
91+
4. Test the built package
92+
93+
### Adding New Features
94+
1. Implement the feature in TypeScript
95+
2. Test locally in development mode
96+
3. Build and verify the production bundle works
97+
4. Test cross-platform compatibility if needed
98+
99+
### Updating Dependencies
100+
1. Update `package.json`
101+
2. Run `npm install`
102+
3. Test in development mode
103+
4. Rebuild and verify production builds
104+
105+
### Deployment
106+
After building, the output packages are ready for deployment:
107+
108+
**Linux/macOS:**
109+
```bash
110+
tar -xzf linux-x64.tar.gz
111+
cd linux-x64
112+
./start.sh --port 9011 --project-root /path/to/project --jesse-relative-path jesse_folder_name --bot-relative-path jesse-bot_folder_name
113+
```
114+
115+
**Windows:**
116+
```cmd
117+
REM Extract win32-x64.zip
118+
cd win32-x64
119+
start.bat --port 9011 --project-root C:\path\to\project --jesse-relative-path jesse_folder_name --bot-relative-path jesse-bot_folder_name
120+
```
121+
122+
## File Structure
123+
- `index.ts` - Entry point
124+
- `pyright-bridge.ts` - WebSocket bridge implementation
125+
- `pyrightconfig.json` - Pyright configuration
126+
- `package.json` - Node.js project configuration and dependencies
127+
- `build.sh` - Build script for Linux x64
128+
- `build-all.sh` - Build script for all platforms
129+
- `output/` - Build output directory (generated)
130+
131+

0 commit comments

Comments
 (0)