Skip to content

Releases: Xilleet/senpy

v0.4.0 Migrate to unified object-oriented symbol model (v0.4.0)

Choose a tag to compare

@Xilleet Xilleet released this 24 Oct 20:34

Refactor core & migrate to unified object-oriented symbol model

BREAKING CHANGE: Completely redesigned internal symbol storage from flat dictionaries
to typed object registries (VariableSymbol, LabelSymbol, ScreenSymbol, ImageSymbol).
Cache structure updated; bump engine version to 0.4.0.

Summary of changes:

  • Architecture:

    • Created senpy/symbols.py featuring dedicated dataclasses:
      VariableSymbol, LabelSymbol, ScreenSymbol, and ImageSymbol.
    • Refactored FileScope (models.py) and SenpyAnalyzer (analyzer.py),
      eliminating 13+ fragmented flat dictionaries and sets (declared_labels,
      declared_screens, symbol_declarations, symbol_types, defined_constants, etc.)
      in favor of 4 unified registries: variables, labels, screens, and images.
    • Streamlined _rebuild_aggregates() boilerplate by ~60%, drastically improving
      maintainability and reducing cache desynchronization risks.
  • Consumers & Integrations:

    • Refactored LSP Server (server.py) methods: completions, definition,
      hover, and document_symbols to directly consume the new symbol registries.
    • Updated Story Flow Analyzer (flow.py) and Mermaid graph export to inspect
      LabelSymbol properties directly.
    • Modernized checkers.py, python_ast.py, wiki.py, stubs.py, and cache.py
      to work natively with object models.
  • Reliability & PEP 8:

    • Replaced broad contextlib.suppress(Exception) with specific, narrowed
      exception tuples (SyntaxError, ValueError, TypeError, OSError, pickle.PickleError, zlib.error)
      in signature.py and cli.py.
  • Tests:

    • Updated test assertions across tests/test_analyzer.py and tests/test_lsp.py.
    • All 54 test suites passing cleanly (0.90s).

Senpy v0.3.0 — Flow-Sensitive Dataflow, Native VS Code Outline, 40 Semantic Rules & Full F12 Navigation

Choose a tag to compare

@Xilleet Xilleet released this 24 Oct 18:02

This major milestone release elevates Senpy to 40 semantic rules (up from 29), introduces flow-sensitive branching analysis across if/elif/else blocks, brings native VS Code Document Symbols & Outline support, bundles instant hover documentation for 220+ Ren'Py Engine APIs, and supercharges Go-to-Definition (F12) across variables, sprites, and media files.


What's New in v0.3.0

1. Native VS Code Outline & Breadcrumbs (Ctrl+Shift+O)

  • Document Symbols Provider: Your .rpy scripts now feature a rich, interactive outline tree in the Outline (Структура) panel and editor Breadcrumbs.
  • Instantly navigate between label, screen, layeredimage, image, and global define/default declarations.
  • Use Ctrl+Shift+O (or Cmd+Shift+O on macOS) for fuzzy quick-jump navigation across scenes in files with thousands of lines.

2. Flow-Sensitive Branching Analysis (if / elif / else & menu)

  • Tracks variable definedness across branching control-flow paths without requiring whole-program execution.
  • Catches variables in MAYBE_SET state (RPY404) that are defined in an if branch but omitted in else or alternative paths, preventing runtime NameError and save-game corruptions.
  • Accurately recognizes terminal branches (jump / return) and guaranteed definitions without false positives.

3. Instant Hover Documentation for 220+ Ren'Py Engine APIs

  • Hovering over any built-in Ren'Py function (renpy.pause, renpy.jump, renpy.music.*, renpy.random.*) or Screen Action (SetVariable, Function, Return, ShowMenu, ToggleField, etc.) now shows a rich Markdown card with parameters, signatures, gotchas, examples, and documentation links.
  • 100% Offline & Instant (~0.1ms): Does not query external APIs at runtime or lag your editor.
  • Includes scripts/update_renpy_api.py to automatically sync definitions from upstream Ren'Py releases without installing the Ren'Py SDK.

4. Full-Spectrum Go-to-Definition (F12)

Pressing F12 / Ctrl+Click now resolves:

  • Story labels & Screens: Jump straight to label or screen declarations.
  • Variables & Characters: Jump to default and define statements (e.g. define e = Character(...)).
  • Sprites & Backgrounds: Jump to image or layeredimage code definitions.
  • Media Assets on Disk: Jump directly to physical .png, .webp, .ogg, and .mp3 files in your workspace!

11 New Semantic Rules (29 ➔ 40 Rules Total)

Code Category Severity Description
RPY107 State & APIs HINT Deprecated Ren'Py API: Detects obsolete functions (LiveComposite, DynamicCharacter, im.*, ui.*) with 1-click QuickFix replacement.
RPY108 Variables & State ERROR / WARNING Type Taint Conflict: Flags fatal runtime TypeError on illegal augmented operations (str += int) and conflicting type reassignments.
RPY109 Init Graph ERROR Init Phase Dependency Violation: Detects functions evaluated in init python: before their declaring file loads in alphabetical order.
RPY207 Screens & UI ERROR Screen Parameter Mismatch: Validates argument counts and keyword parameters on use screen(...) and call screen(...).
RPY309 Story Flow WARNING Story Island / Subgraph Loop: Detects isolated groups of scenes referencing each other in loops but unreachable from start or system entry points.
RPY310 Story Flow ERROR Call Arity Violation: Catches missing required positional arguments or unexpected keyword parameters on call label(...).
RPY404 Branching & Logic WARNING MAYBE_SET Variable Read: Flags condition checks (if var:) or text interpolations ([var]) evaluated on variables only defined in certain branches.
RPY505 Assets & Media WARNING / ERROR Unregistered Audio Channel: Flags playback on unregistered audio channels and prevents audio overlap glitches from loop on voice.
RPY601 Translations ERROR Variable Mismatch in Translations: Catches altered or misspelled [var] tags in game/tl/ before they crash with KeyError.
RPY602 Translations WARNING Formatting Tag Mismatch: Detects lost or altered {b}, {color}, {i} tags between original and translated strings.
RPY603 Translations WARNING Empty Translation String: Detects blank new "" strings in localization files that leave player dialogue windows empty.

Additional CLI & Tooling Upgrades

  • Translation Coverage (senpy --coverage): Audits game/tl/ and calculates localization progress percentages per language.
  • GDD Wiki Generator (senpy --export-wiki): Automatically extracts cast lists, typed variables, and story endings into a Markdown game design document.
  • Type Stubs (senpy --stubs): Generates .pyi type stubs for the Ren'Py store, giving Pylance / MyPy in VS Code native autocompletion.
  • Crash Inspector (senpy --traceback): Parses post-mortem traceback.txt crash logs and maps errors to actionable Senpy rules.
  • One-Click GitHub Actions (senpy --init-ci): Generates automated pull-request scanning workflows with native GitHub CodeQL SARIF alerts.
  • Cache Integrity: Hardened Tier 2 .senpy_cache invalidation by hashing variable types, asset tags, and registered channels.
  • Bugfixes: Fixed CLI argument parsing for --defaults and --stubs, isolated local label parameters from global namespace leakage, and prevented call screen from registering phantom jump targets.

Installation & Updating

Core Python Analyzer (CLI & LSP):

pip install --upgrade senpy-linter

VS Code Extension:

Download senpy-vscode-0.3.0.vsix from the Assets below and install via Install from VSIX... in VS Code.

Senpy v0.2.11

Choose a tag to compare

@Xilleet Xilleet released this 21 Oct 10:00

This update introduces Mermaid.js story flow visualization, expands the semantic ruleset from 23 to 29 rules, upgrades audio resolution, and completely refactors the core engine architecture for lightning-fast LSP performance.


New Feature: Visual Story Flow Graphs

You can now export your visual novel’s branching narrative into clean, interactive Mermaid.js diagrams!

  • Preview your story transitions, branches, and endings directly inside VS Code's Markdown preview.
  • Highlight dead-ends and missing jump targets automatically.
  • Run via CLI: senpy --graph or save directly with senpy --graph-file story.md.

6 New Semantic Rules (Now 29 Rules Total)

  • RPY001 (Indentation Tabs): Detects accidental \t tab characters in indentation and provides an instant 4-space QuickFix auto-replacement.
  • RPY002 (Smart Quotes): Catches typographical curly quotes (“ ” ‘ ’ « ») pasted from Google Docs/Word that break Python syntax, with one-click ASCII conversion.
  • RPY206 (Premature Action Call): Warns when functions are invoked directly with parentheses inside screen actions (action my_func()), preventing side-effects during screen prediction.
  • RPY307 (Duplicate Labels): Catches duplicate label declarations across files before runtime crashes with ScriptError: Name defined twice.
  • RPY308 (Label Fallthrough): Warns when scenes terminate without an explicit return or jump, preventing story flow from bleeding into the next label.
  • RPY503 (Unused Assets): Detects dead/unreferenced images and audio files sitting on disk to help trim your game distribution size.

Upgraded Audio Engine (RPY501)

  • Full support for Ren'Py's native unquoted audio syntax: play sound click, play music audio.ambient.
  • Automatic discovery of files in the game/audio/ directory (.ogg, .mp3, .opus, .wav, .flac).
  • Support for define audio.* alias declarations.

Architecture & Performance

  • Modular Engine: Decomposed the monolithic core into specialized domain modules (assets, python_ast, flow, text_tags, models).
  • Ultra-low LSP Latency: Instantaneous (~15ms) diagnostics on every keystroke in VS Code without IDE stutters.
  • Streamlined CLI: Overhauled --help menu categorized into clean sections (Rules, Autofix, Visualization, Tools).
  • Expanded Russian and English Tsundere-mode dialogue lines.

Senpy v0.1.7

Choose a tag to compare

@Xilleet Xilleet released this 17 Oct 19:30

Includes the core analyzer, 29 diagnostic rules, and the VS Code extension