42 lines
1.6 KiB
Markdown
42 lines
1.6 KiB
Markdown
---
|
|
epic: 12
|
|
story: 12.2
|
|
title: "Scripting Layer (Rhai or mlua)"
|
|
status: draft
|
|
---
|
|
|
|
## Epic 12 — Plugin & Extension System
|
|
**Goal:** Let power users extend CalcPad.
|
|
|
|
### Story 12.2: Scripting Layer (Rhai or mlua)
|
|
|
|
As a power user without Rust experience,
|
|
I want to write lightweight scripts to add custom functions to CalcPad,
|
|
So that I can extend functionality without compiling native code.
|
|
|
|
**Acceptance Criteria:**
|
|
|
|
**Given** a user creates a script file in the `.calcpad-plugins/` directory
|
|
**When** CalcPad starts or reloads plugins
|
|
**Then** all `.rhai` (or `.lua`) files in the directory are loaded and executed
|
|
**And** functions registered by the scripts become available in expressions
|
|
|
|
**Given** a script uses the API `calcpad.add_function("double", |x| x * 2)`
|
|
**When** a user types `double(21)` in a sheet
|
|
**Then** the answer column displays `42`
|
|
|
|
**Given** a script attempts to access the filesystem, network, or system commands
|
|
**When** the script is executed
|
|
**Then** the sandboxed runtime blocks the operation
|
|
**And** an error is reported without crashing the application
|
|
|
|
**Given** a script contains a syntax error or runtime error
|
|
**When** CalcPad attempts to load it
|
|
**Then** an error message identifies the problematic script file and line number
|
|
**And** all other valid plugins continue to load and function normally
|
|
|
|
**Given** a script registers a function with the same name as a built-in
|
|
**When** the user evaluates an expression using that name
|
|
**Then** the built-in takes precedence (or a configurable priority is respected)
|
|
**And** a warning is logged about the naming conflict
|