File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import type { Plugin } from "@opencode-ai/plugin"
2+
3+ export const PythonLinterPlugin : Plugin = async ( { $, directory } ) => {
4+ return {
5+ event : async ( { event } ) => {
6+ // Only process file.edited events for Python files
7+ if ( event . type !== "file.edited" ) {
8+ return
9+ }
10+
11+ const file = ( event as { type : "file.edited" ; file : string } ) . file
12+
13+ if ( ! file . endsWith ( '.py' ) ) {
14+ return
15+ }
16+
17+ console . log ( `[python-linter] Linting: ${ file } ` )
18+
19+ try {
20+ // Run ruff check with auto-fix
21+ await $ `cd ${ directory } && ruff check --fix ${ file } ` . quiet ( )
22+ console . log ( `[python-linter] ruff check: OK` )
23+ } catch ( e ) {
24+ // ruff may not be installed or may have unfixable errors - continue
25+ console . log ( `[python-linter] ruff check: skipped (${ e instanceof Error ? e . message : 'not installed' } )` )
26+ }
27+
28+ try {
29+ // Run ruff format
30+ await $ `cd ${ directory } && ruff format ${ file } ` . quiet ( )
31+ console . log ( `[python-linter] ruff format: OK` )
32+ } catch ( e ) {
33+ // ruff format may not be installed - continue
34+ console . log ( `[python-linter] ruff format: skipped` )
35+ }
36+
37+ try {
38+ // Run ty type checker
39+ await $ `cd ${ directory } && ty check ${ file } ` . quiet ( )
40+ console . log ( `[python-linter] ty check: OK` )
41+ } catch ( e ) {
42+ // ty may not be installed - continue
43+ console . log ( `[python-linter] ty check: skipped` )
44+ }
45+ }
46+ }
47+ }
Original file line number Diff line number Diff line change 99 " instructions/tool-preferences.md" ,
1010 " instructions/context7-library-documentation.md"
1111 ],
12+ "plugin" : [
13+ " file://.opencode/plugin/python-linter.ts"
14+ ],
1215 "agent" : {
1316 "project-manager" : {
1417 "description" : " Pure orchestrator that coordinates specialists but never executes code - read-only tools and delegation only" ,
Original file line number Diff line number Diff line change 1212 " instructions/postgres-mcp-databases.md" ,
1313 " instructions/rollbar-mcp-integration.md"
1414 ],
15+ "plugin" : [
16+ " file://.opencode/plugin/python-linter.ts"
17+ ],
1518 "permission" : {
1619 "bash" : {
1720 "pulumi up*" : " deny" ,
You can’t perform that action at this time.
0 commit comments