Complete Python integration system for opencode with interactive configuration, smart detection, and command automation.
everything-opencode/
├── scripts/interactive/ # Core interactive system
│ ├── prompts.js # Interactive prompts (color-coded UX)
│ ├── config-manager.js # Configuration management
│ └── project-detector.js # Language detection with confidence scoring
├── languages/python/ # Python-specific wizards
│ └── config-wizard.js # Python configuration wizard
├── scripts/python/ # Python utilities
│ └── tool-detector.js # Python tool detection
├── scripts/commands/ # Command implementations
│ ├── python-command-runner.js # Base command runner
│ ├── python-test.js # /python-test command
│ ├── python-lint.js # /python-lint command
│ ├── python-typecheck.js # /python-typecheck command
│ ├── python-deps.js # /python-deps command
│ └── python-setup.js # /python-setup command
├── commands/ # Command documentation
│ ├── python-test.md
│ ├── python-lint.md
│ ├── python-typecheck.md
│ ├── python-deps.md
│ └── python-setup.md
├── examples/python-projects/ # Project templates
│ └── README.md
├── scripts/interactive-setup.js # Main setup script
├── PYTHON-INTEGRATION.md # Technical documentation
└── INTEGRATION-GUIDE.md # This guide
- 6 languages: Python (priority), PineScript, TypeScript, Go, Rust
- Confidence scoring: 0-0.95 based on multiple indicators
- Python project types: FastAPI, Django, Flask, Data Science, ML, CLI, Library
- PineScript project types: Indicator, Strategy, Library with version detection (v4, v5, v6)
- Go project types: CLI, Web Service, Library, Module, Workspace (Go 1.18+)
- Automatic primary language determination
- Color-coded prompts for better UX
- Multiple choice with descriptions for informed decisions
- Yes/no confirmations with smart defaults
- Progress indicators for long operations
- User approval before saving configuration
- 30+ tools detected with version checking
- Installation guides per platform (macOS, Linux, Windows)
- Compatibility checking with version constraints
- Priority-based recommendations
- /python-test - Run tests with configured test runner
- /python-lint - Run linter and formatter
- /python-typecheck - Run type checker
- /python-deps - Manage dependencies
- /python-setup - Configure Python project
- /pine-setup - Configure PineScript project with interactive wizard
- /pine-validate - Validate PineScript syntax and version compatibility
- /pine-backtest - Run backtesting on strategies with performance metrics
- /pine-optimize - Optimize strategy parameters with grid search
- /pine-convert - Convert between PineScript versions (v4 ↔ v5 ↔ v6)
- /pine-alert - Configure alert system with webhooks and notifications
- /go-setup - Configure Go project with Go-specific improvements (CLI, web, library, workspace)
- /go-build - Build Go projects with cross-compilation for 5 platforms and race detection
- /go-test - Run comprehensive tests with coverage, benchmarks, and race detection
- /go-lint - Lint code with multiple linter support (golangci-lint, staticcheck, revive)
- /go-format - Format code with gofmt/goimports and formatting checks
- /go-mod - Manage modules with security auditing and update management
- /go-clean - Clean build artifacts and cache
- /go-run - Run Go programs with enhanced features
- /go-security - Security scanning for Go code and dependencies
- /elixir-setup - Configure Elixir project with Elixir-specific improvements (Application, Phoenix, Umbrella, Library, OTP)
- /elixir-compile - Compile Elixir project with optimizations and error handling
- /elixir-test - Run ExUnit tests with coverage, filtering, and performance analysis
- /elixir-lint - Lint code with Credo for code quality and consistency
- /elixir-format - Format code with Elixir's built-in formatter
- /elixir-deps - Manage dependencies with Mix and Hex package manager
- /elixir-typecheck - Type check with Dialyzer for static analysis
# Run interactive setup
node scripts/interactive-setup.js
# Or quick setup
node scripts/interactive-setup.js quick
# Or Python-specific setup
node scripts/commands/python-setup.js# Run tests
node scripts/commands/python-test.js
# Lint and format code
node scripts/commands/python-lint.js --fix
# Type checking
node scripts/commands/python-typecheck.js --strict
# Manage dependencies
node scripts/commands/python-deps.js install
node scripts/commands/python-deps.js add fastapi --dev
# Reconfigure project
node scripts/commands/python-setup.js --reconfigure# Test project detection
node scripts/interactive-setup.js detect
# Test tool detection
node scripts/interactive-setup.js tools
# Show current configuration
node scripts/interactive-setup.js configSaved to .opencode/project-config.json:
{
"project": "/path/to/project",
"configuredAt": "2025-01-25T10:30:00.000Z",
"primaryLanguage": "python",
"python": {
"projectType": "fastapi",
"dependencyManager": "uv",
"testRunner": "pytest",
"linter": "ruff",
"formatter": "ruff",
"typeChecker": "pyright",
"tools": {
"python": { "installed": true, "version": "3.11.0" },
"uv": { "installed": true, "version": "0.1.0" },
"pytest": { "installed": true, "version": "7.4.0" },
"ruff": { "installed": true, "version": "0.1.0" },
"pyright": { "installed": true, "version": "1.1.0" }
},
"fastapiOptions": {
"includeDocs": true
},
"userApproved": true
}
}- Dependency manager: uv (fast, modern)
- Test runner: pytest (feature-rich)
- Linter: ruff (extremely fast)
- Formatter: ruff format (consistent)
- Type checker: pyright (fast, good editor integration)
- Use detected tools if available
- Migrate gradually to recommended tools
- Maintain compatibility with existing workflow
The Python commands are designed to integrate with opencode's command system:
- Command discovery - Commands are documented in
commands/directory - Configuration-aware - Commands read from
.opencode/project-config.json - Interactive feedback - Color-coded output and progress indicators
- Exit codes - Proper exit codes for automation
The system provides context for AI assistance:
- Project type and structure
- Installed tools and versions
- Configuration preferences
- Common patterns for the project type
# Typical workflow
/python-setup # Configure project
/python-deps install # Install dependencies
/python-lint --fix # Fix linting issues
/python-test # Run tests
/python-typecheck # Type checking
# ... develop ...
/python-lint # Check code quality
/python-test --coverage # Test with coverage- Add tool definition to
scripts/python/tool-detector.js:
toolName: {
command: 'tool --version',
description: 'Tool description',
installGuide: {
macos: 'brew install tool',
linux: 'apt-get install tool',
windows: 'Download from...'
},
priority: 5
}- Add to configuration schema in
scripts/interactive/config-manager.js - Add to wizard options in
languages/python/config-wizard.js
- Add detection logic to
scripts/interactive/project-detector.js:
// Check for project type markers
const hasMarkers = await checkPythonProjectType(projectPath, 'new-type', [
'import newframework',
'from newframework import',
]);- Add configuration options to wizard
- Add project templates to
examples/python-projects/
- Create command documentation in
commands/directory - Implement command in
scripts/commands/directory - Use
PythonCommandRunnerbase class - Test with sample project
# Test project detection
node -e "const ProjectDetector = require('./scripts/interactive/project-detector'); const d = new ProjectDetector(); d.getProjectSummary().then(console.log)"
# Test tool detection
node -e "const PythonToolDetector = require('./scripts/python/tool-detector'); const d = new PythonToolDetector(); d.detectAll().then(r => d.printResults(r))"
# Test command runner
node scripts/commands/python-test.js --help- Create test Python project
- Run
/python-setupto configure - Test each command functionality
- Verify configuration persistence
- File scanning: Limited to first 10 Python files for import detection
- Glob patterns: Efficient file pattern matching
- Caching: Configuration cached after first detection
- Parallel detection: Language detectors run independently
- Lazy initialization: Configuration loaded only when needed
- Tool checking: Tools checked once per command
- Parallel execution: Where supported (test parallelization)
- Incremental checking:
--diffoption for changed files only
- User approval: Configurations only saved with user consent
- No secrets: Configuration files don't contain secrets
- Validation: JSON schema validation for configuration
- Import/export: Safe configuration sharing
- Command validation: Validate commands before execution
- No arbitrary execution: Commands are predefined
- Environment isolation: Commands run in project directory
- Exit code handling: Proper error reporting
# Force Python project type
node scripts/commands/python-setup.js --project-type python
# Check detection manually
node scripts/interactive-setup.js detect# Detect tools manually
node scripts/interactive-setup.js tools
# Install missing tools
curl -LsSf https://astral.sh/uv/install.sh | sh
pip install pytest ruff pyright# View current configuration
cat .opencode/project-config.json
# Remove and reconfigure
rm .opencode/project-config.json
node scripts/commands/python-setup.js# Test with --help
node scripts/commands/python-test.js --help
# Check Python installation
python --version
# Verify virtual environment
source .venv/bin/activate # Linux/Mac
.venv\Scripts\activate # Windows# Verbose output
node scripts/commands/python-test.js --verbose
# Debug initialization
node -e "const runner = require('./scripts/commands/python-command-runner'); new runner().initialize().catch(console.error)"- Python skills - AI assistance patterns for Python projects
- Python agents - Specialized agents for different project types
- Template generation - Code generation from templates
- Migration tools - Tool migration assistance
- CI/CD integration - GitHub Actions, GitLab CI templates
- Editor integration - VS Code, PyCharm configuration
- Package publishing - PyPI publishing assistance
- Documentation generation - Auto-documentation tools
- TypeScript integration - Node.js/TypeScript project support
- Go integration - Go project configuration
- Rust integration - Rust project setup
- PineScript integration - TradingView strategy development
- Follow existing patterns - Maintain consistency
- Add tests - Test new functionality
- Update documentation - Keep docs current
- Use interactive prompts - For user interaction
- Store configurations properly - In
.opencode/project-config.json
- JavaScript: ES6+ with async/await
- Python: PEP 8 with type hints (for templates)
- Documentation: Markdown with examples
- Error handling: Graceful degradation with clear messages
- Unit tests - Individual component testing
- Integration tests - End-to-end workflow testing
- Manual testing - Interactive testing with sample projects
- Documentation testing - Verify examples work
- Check documentation -
PYTHON-INTEGRATION.mdandINTEGRATION-GUIDE.md - Test commands - Use
--helpflag for command usage - Examine configuration - Check
.opencode/project-config.json - Create test case - Reproduce issue with minimal example
- Describe the problem - What happened vs expected
- Include configuration - Project type and tools
- Provide reproduction steps - How to reproduce the issue
- Share error messages - Complete error output
Part of the everything-opencode project. See project LICENSE for details.
🎉 Python Integration Complete! The system is ready for use and extensible for future enhancements.