Skip to content

Add opt-in workbook macro projects to craft-python - #1

Open
derechopiano wants to merge 2 commits into
sirmmo:mainfrom
derechopiano:feat/workbook-python-macros
Open

derechopiano wants to merge 2 commits into
sirmmo:mainfrom
derechopiano:feat/workbook-python-macros

Conversation

@derechopiano

@derechopiano derechopiano commented Oct 17, 2026 •

Copy link
Copy Markdown

Adds an opt-in workbook-project role for the desktop portion of storytold/gridcraft#1566, building on craft-python 0.3.0.

The ordinary manifest and its Run Script, Console, Run File, PY.EVAL, helpers and WordCraft/DeckCraft behavior stay on their existing path. main.py --workbook-macros uses the existing App/Channel with a small adapter; no second plugin dispatcher or transport is introduced.

  • plugin-macros.json has a separate provider identity, no duplicate functions/ribbon commands, and opts out of VBA recording and ribbon callbacks.
  • Supports inert AST discovery and editing of workbook-owned modules through the shared macros/* methods. The host owns persistence, trust, editing UI and the workbook transaction.
  • Prepares PEP 723 environments with uv and reuses a worker for the same document/source; changes, failure or 60 idle seconds release it. Startup/execution have absolute deadlines and bounded messages/diagnostics.
  • Preparation is offline unless the host supplies explicit session/metadata-bound approval. Source builds remain disabled. Worker process-tree ownership is lifecycle management, not an OS sandbox.

Host dependency: sirmmo/gridcraft#4, which requires the proposed pythonProjects/engineCommands capabilities on top of storytold/gridcraft#1123. An unmodified host refuses the manifest. This is separate from Python-in-cells (#469); form controls, Pyodide and rich editor/output work remain later phases of #1566.

Validation:

  • Full python -m unittest discover -s tests -v: 68 tests passed, including upstream scripts/console/functions, GridCraft/WordCraft/DeckCraft behavior and the new runtime/adapter checks.
  • Compile, JSON/version consistency and the complete Linux Python 3.8/3.12 matrix passed: fork CI. Each platform ran 71 tests: 68 passed, with three lifetime checks applicable only to the other platform.
  • Real native GridCraft/uv integration passed: discovery, editing, warm reuse, literal writes, one-step undo, error/Stop rollback and ordinary PY.TWICE recalculation during a macro.
  • Native Windows and Linux descendant cleanup passed, including forced cancellation, normal worker exit with descendants holding pipes, and provider-crash cleanup. POSIX ownership uses an idle pipe-lifetime supervisor; Windows retains Job Objects. Native FreeBSD execution remains unverified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant