How novfensec/codekivy works
Purpose and Runtime
CodeKivy is a Visual Studio Code extension for Kivy’s KvLang (.kv) UI files. It provides language registration, TextMate syntax highlighting, snippets, and completion informed by Python classes/properties in the active workspace. The host runtime is VS Code’s Node.js extension API; Python is invoked for source analysis and Kivy is the target framework.
Extension Entry and Activation
The extension’s JavaScript controller is the VS Code-facing entry point, responsible for activation, language features, workspace integration, and invoking analysis:
• src/extension.js
• package.json
VS Code loads the extension according to manifest contributions/activation metadata in package.json. The controller operates on editor documents and workspace files rather than serving a web application.
KvLang Language Surface
KvLang editor behavior is defined through three declarative assets:
• language-configuration.json
• syntaxes/kvlang.tmLanguage.json
• snippets/kvlang.json
The language configuration establishes editing behavior; the TextMate grammar tokenizes .kv syntax for highlighting; snippets supply reusable KvLang constructs. These are independent VS Code contribution layers consumed directly by the editor.
Python Workspace Analysis
Python source inspection is isolated in:
• src/parser.py
This forms the boundary between the Node-based extension host and Python/Kivy-oriented project code. The extension scans or refreshes workspace Python files, delegates parsing to Python, and uses extracted custom widget classes and property definitions to augment completions in KvLang documents. Python availability on PATH is therefore a material runtime dependency; analysis quality depends on current workspace source.
Completion and Live Refresh Flow
Primary control flow is:
1. VS Code activates the JavaScript extension for KvLang work.
2. src/extension.js registers completion behavior and file/workspace listeners.
3. Python-file changes trigger workspace re-analysis through src/parser.py.
4. Parsed widget/property metadata is retained or refreshed in the extension host.
5. While editing .kv files, completion merges Kivy-oriented suggestions with discovered project-defined classes/properties.
The critical boundary is asynchronous process/data exchange between src/extension.js and src/parser.py; failures in Python discovery or parsing should degrade custom suggestions without breaking syntax highlighting or snippets.
Packaging and Distribution
The extension is packaged as an npm/VS Code extension project:
• package.json
• package-lock.json
• assets
assets contains marketplace-facing extension resources, including the icon referenced by project documentation. The external distribution surface is the VS Code Marketplace; Kivy itself is not bundled and must exist in the user’s Python environment.
Main entry points: package.json Extension Manifest · extension.js Extension Controller · parser.py Python Parser · language-configuration.json Language Configuration
Components 14
VS Code Extension
Node.js extension-host runtime.
- VS Code · Loads contributions and runs the extension host.
- Extension Manifest · Declares activation and language contributions.
package.json - Extension Controller · Registers language features, listeners, and analysis calls.
src/extension.js - KvLang Documents · Active .kv files receive completion and editor behavior.
KvLang Contributions
Editor-consumed language assets.
- Language Configuration · Defines KvLang editing behavior.
language-configuration.json - TextMate Grammar · Tokenizes KvLang for highlighting.
syntaxes/kvlang.tmLanguage.json - KvLang Snippets · Provides reusable KvLang constructs.
snippets/kvlang.json
Workspace Analysis
Python-backed project metadata discovery.
- Workspace Python Files · Current source used to discover custom widgets and properties.
- Python Parser · Extracts widget classes and property definitions.
src/parser.py - Widget Metadata · Discovered classes and properties retained by the extension host.
- Python on PATH · Runs workspace source analysis.
Packaging
Marketplace distribution resources.
- Dependency Lockfile
package-lock.json - Marketplace Assets · Includes marketplace-facing resources such as the icon.
assets - VS Code Marketplace
Connections 19
- VS Code → Extension Manifest: loads
- Extension Manifest → Extension Controller: activates
- Extension Manifest → Language Configuration: contributes
- Extension Manifest → TextMate Grammar: contributes
- Extension Manifest → KvLang Snippets: contributes
- Language Configuration → KvLang Documents: editing behavior
- TextMate Grammar → KvLang Documents: syntax highlighting
- KvLang Snippets → KvLang Documents: snippet suggestions
- Extension Controller → KvLang Documents: registers completion
- Workspace Python Files → Extension Controller: change events
- Extension Controller → Python Parser: invokes asynchronously · Re-analysis crosses the Node-to-Python process boundary.
- Python on PATH → Python Parser: executes
- Workspace Python Files → Python Parser: analyzes
- Python Parser → Widget Metadata: extracts
- Widget Metadata → Extension Controller: refreshes cache
- Extension Controller → KvLang Documents: merges project suggestions
- Extension Manifest → Dependency Lockfile: resolved dependencies
- Marketplace Assets → VS Code Marketplace: published with
- Extension Manifest → VS Code Marketplace: packaged and published