Skip to content

feat: add TypeScript module for Python run configuration#1

Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1770118341-typescript-run-configuration
Open

feat: add TypeScript module for Python run configuration#1
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1770118341-typescript-run-configuration

Conversation

@devin-ai-integration
Copy link
Copy Markdown

Summary

This PR adds a new TypeScript/Node.js module that migrates the TRunConfiguration class and TPythonControl.Run/Debug methods from the Delphi codebase (Source/cPyControl.pas and Source/cPySupportTypes.pas) to TypeScript.

The module provides:

  • RunConfiguration interface with script path, arguments, working directory, and environment variables
  • PythonRunner class with run() and debug() methods using Node.js child_process.spawn()
  • DebuggerState and PythonEngineType enums matching the original Delphi types
  • Custom error classes for validation (missing Python, missing script, invalid directory)
  • Event emitter pattern for stdout/stderr/exit/state changes
  • Output file writing support

The debug functionality currently uses Python's built-in pdb module and is structured to support future DAP (Debug Adapter Protocol) integration.

Review & Testing Checklist for Human

  • Test with actual Python scripts - No unit tests are included. Manually verify that run() and debug() work correctly with real Python scripts on your target platform
  • Verify cross-platform behavior - The pause() and resume() methods use Unix signals (SIGSTOP/SIGCONT) which are no-ops on Windows. Confirm this is acceptable
  • Review breakpoint handling - The BreakpointInfo interface is defined in DebugOptions but is not actually used in buildDebugArgs(). Determine if breakpoint support should be implemented or removed
  • Validate debug experience - The debug mode uses pdb which provides basic debugging. Verify this meets requirements or if more sophisticated debugging is needed

Test Plan

  1. Create a simple Python script (e.g., print("hello"))
  2. Use the module to run it: const result = await run({ scriptPath: '/path/to/script.py' })
  3. Verify stdout contains expected output
  4. Test debug mode with initStepIn: true to confirm pdb launches correctly

Notes

  • Build passes: npm run build succeeds
  • Lint passes: npm run lint succeeds (with TypeScript version warning)
  • The module is placed in ts-src/ directory as a new TypeScript project within the repo

Link to Devin run: https://app.devin.ai/sessions/f5aa9b6e7b64408f9ff935d3eee99b31
Requested by: Joao Esteves (@joao-cognition)

Migrate TRunConfiguration class and TPythonControl.Run/Debug methods
from Delphi cPyControl.pas to TypeScript/Node.js.

Features:
- RunConfiguration interface with script path, arguments, working
  directory, and environment variables
- PythonRunner class with run() and debug() methods
- DebuggerState enum matching Delphi TDebuggerState
- PythonEngineType enum matching Delphi TPythonEngineType
- Cross-platform support (Windows, macOS, Linux)
- Error handling for missing Python, scripts, and directories
- Event emitter for stdout, stderr, exit, and state changes
- Output file writing support
- Prepared for future DAP integration

Co-Authored-By: Joao Esteves <joao.esteves@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants