name: ai-context-python-service
description: Guides the ai-context-writer subagent in generating and maintaining AI_CONTEXT_PYTHON_SERVICE.md, documenting the python_service package architecture, data models, parsing behavior, JSON protocol, error handling, and extension points for the python-vis project. Use when creating or updating the Python service AI context file.
AI Context Python Service Skill
Purpose
Help the ai-context-writer subagent create and maintain docs/AI_CONTEXT/AI_CONTEXT_PYTHON_SERVICE.md as the authoritative reference for the python_service/ package:
- Models and data contracts
- AST parsing and graph conversion
- JSON protocol exposed over stdio
- Error handling and lifecycle behavior
- Extension points for new node types or features
Sources to Read
Before updating the Python service context, read:
@python_service/schema.py
@python_service/parser.py
@python_service/server.py
@python_service/__main__.py
- Relevant tests under
@tests/python_service/ (if present)
- Existing
@docs/AI_CONTEXT/AI_CONTEXT_REPOSITORY.md for overall context
Use these files as ground truth; do not speculate about behavior that is not implemented.
Required Sections in AI_CONTEXT_PYTHON_SERVICE.md
Include at least:
Metadata
- Version
- Last Updated (ISO date)
- Tags including
python-service, parser, protocol
- Cross-References to
AI_CONTEXT_REPOSITORY.md and AI_CONTEXT_QUICK_REFERENCE.md
Module Overview
- Brief description of each core module:
schema.py
parser.py
server.py
__main__.py
Data Models (schema.py)
- Describe Pydantic models:
NodeData
ReteNode
ReteConnection
ReteGraph
- Any helper types (e.g. Socket)
- Explain key fields and how extra data is handled (e.g.
extra="allow").
Parsing & Conversion (parser.py)
- Describe
ReteConverter:
- Its role as an
ast.NodeVisitor
- How it assigns node IDs and accumulates nodes/connections
- The main
visit_* methods that are implemented (e.g. Module, FunctionDef, ClassDef, Call, If, For, While, Assign, Constant, etc.).
- Document the main public API method:
parse_to_rete(source_code: str) -> ReteGraph
JSON Protocol & Server (server.py)
- Request format expected over stdin (JSON line).
- Response format on success (
result: ReteGraph JSON) and on error (error object).
- Error codes and their meanings (parse vs internal errors).
- Lifecycle of
ASTParseServer (start_server, stop_server).
Process Entry Point (main.py)
- How
python -m python_service is wired:
- Construction of
ReteConverter and ASTParseServer
- Signal handling (
SIGTERM, SIGINT)
- Loop behavior and graceful shutdown.
Extension Points
- How to add support for a new AST node type:
- Implement
visit_<NodeType> with creation of ReteNode and ReteConnections.
- Any conventions for node labels and data fields.
- How to change or extend the protocol (if needed).
Examples
- Include at least one example request/response pair for:
- A successful parse.
- A syntax error.
Style & Constraints
- Use developer-level detail but keep explanations concise.
- Always show JSON protocol shapes and Pydantic model fields using code blocks.
- Clearly separate current behavior from any future ideas (prefer omitting speculative content).
- Keep under the content length limit; split into sub-documents if the Python service grows significantly.
Update Strategy
When the Python service changes:
- Update model descriptions and public API signatures.
- Revise protocol examples and error codes as needed.
- Add or remove documented
visit_* behaviors to match the implementation.
- Bump metadata version and last-updated date.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: benweatherall-vscode-python-ast-extension-ai-context-python-3description: ---4---5---6name: ai-context-python-service7description: Guides the ai-context-writer subagent in generating and maintaining AI_CONTEXT_PYTHON_SERVICE.md, documenting the python_service package architecture, data models, parsing behavior, JSON protocol, error handling, and extension points for the python-vis project. Use when creating or updating the Python service AI context file.8---910# AI Context Python Service Skill1112## Purpose1314Help the `ai-context-writer` subagent create and maintain `docs/AI_CONTEXT/AI_CONTEXT_PYTHON_SERVICE.md` as the **authoritative reference** for the `python_service/` package:1516- Models and data contracts17- AST parsing and graph conversion18- JSON protocol exposed over stdio19- Error handling and lifecycle behavior20- Extension points for new node types or features2122## Sources to Read2324Before updating the Python service context, read:2526- `@python_service/schema.py`27- `@python_service/parser.py`28- `@python_service/server.py`29- `@python_service/__main__.py`30- Relevant tests under `@tests/python_service/` (if present)31- Existing `@docs/AI_CONTEXT/AI_CONTEXT_REPOSITORY.md` for overall context3233Use these files as **ground truth**; do not speculate about behavior that is not implemented.3435## Required Sections in AI_CONTEXT_PYTHON_SERVICE.md3637Include at least:38391. **Metadata**40 - Version41 - Last Updated (ISO date)42 - Tags including `python-service`, `parser`, `protocol`43 - Cross-References to `AI_CONTEXT_REPOSITORY.md` and `AI_CONTEXT_QUICK_REFERENCE.md`44452. **Module Overview**46 - Brief description of each core module:47 - `schema.py`48 - `parser.py`49 - `server.py`50 - `__main__.py`51523. **Data Models (schema.py)**53 - Describe Pydantic models:54 - `NodeData`55 - `ReteNode`56 - `ReteConnection`57 - `ReteGraph`58 - Any helper types (e.g. Socket)59 - Explain key fields and how extra data is handled (e.g. `extra="allow"`).60614. **Parsing & Conversion (parser.py)**62 - Describe `ReteConverter`:63 - Its role as an `ast.NodeVisitor`64 - How it assigns node IDs and accumulates nodes/connections65 - The main `visit_*` methods that are implemented (e.g. Module, FunctionDef, ClassDef, Call, If, For, While, Assign, Constant, etc.).66 - Document the main public API method:67 - `parse_to_rete(source_code: str) -> ReteGraph`68695. **JSON Protocol & Server (server.py)**70 - Request format expected over stdin (JSON line).71 - Response format on success (`result: ReteGraph JSON`) and on error (`error` object).72 - Error codes and their meanings (parse vs internal errors).73 - Lifecycle of `ASTParseServer` (`start_server`, `stop_server`).74756. **Process Entry Point (__main__.py)**76 - How `python -m python_service` is wired:77 - Construction of `ReteConverter` and `ASTParseServer`78 - Signal handling (`SIGTERM`, `SIGINT`)79 - Loop behavior and graceful shutdown.80817. **Extension Points**82 - How to add support for a new AST node type:83 - Implement `visit_<NodeType>` with creation of `ReteNode` and `ReteConnection`s.84 - Any conventions for node labels and data fields.85 - How to change or extend the protocol (if needed).86878. **Examples**88 - Include at least one example request/response pair for:89 - A successful parse.90 - A syntax error.9192## Style & Constraints9394- Use **developer-level detail** but keep explanations concise.95- Always show JSON protocol shapes and Pydantic model fields using code blocks.96- Clearly separate **current behavior** from any future ideas (prefer omitting speculative content).97- Keep under the content length limit; split into sub-documents if the Python service grows significantly.9899## Update Strategy100101When the Python service changes:1021031. Update model descriptions and public API signatures.1042. Revise protocol examples and error codes as needed.1053. Add or remove documented `visit_*` behaviors to match the implementation.1064. Bump metadata version and last-updated date.107108109---110> Converted and distributed by [TomeVault](https://tomevault.io/claim/benweatherall) — claim your Tome and manage your conversions.111<!-- tomevault:4.0:skill_md:2026-04-14 -->