chore: hardened editor specs

This commit is contained in:
2026-04-05 13:44:45 +02:00
parent 3d89e8ea22
commit 6e34f5de1c
8 changed files with 1294 additions and 510 deletions

View File

@@ -6,37 +6,83 @@
-- Describes the layout and behaviour of the script editor.
-- See script.allium for entity model.
-- ─── External surfaces ──────────────────────────────────────
surface User {
provides: ScriptSaveRequested(script_id)
provides: ScriptRunRequested(script_id)
provides: ScriptDeleteRequested(script_id)
}
use "./script.allium" as script
use "./i18n.allium" as i18n
-- ─── Script editor view ──────────────────────────────────────
-- Code editor for Lua scripts (macros, utilities, transforms).
value ScriptEditorView {
script_id: String
title: String -- editable text input
slug: String -- editable text input, auto-generated from title
kind: String -- select: utility | macro | transform
entrypoint: String -- select: dynamically discovered functions, "main" always first
enabled: Boolean -- checkbox
content: String -- code editor content
created_at: String -- locale-formatted date
updated_at: String -- locale-formatted date
}
-- Layout: header bar, code editor, no preview.
-- Header: script title (editable), kind badge, enabled toggle.
-- Editor: code editor with Lua syntax highlighting.
-- Toolbar: Run button, Save button, Delete button, entrypoint selector.
surface ScriptEditorSurface {
context editor: ScriptEditorView
exposes:
editor.title
editor.slug
editor.kind
editor.entrypoint
editor.enabled
editor.created_at
editor.updated_at
provides:
ScriptSaveRequested(editor.script_id)
ScriptRunRequested(editor.script_id)
ScriptCheckSyntaxRequested(editor.script_id)
ScriptDeleteRequested(editor.script_id)
@guarantee HeaderLayout
-- Header bar with script title tab.
-- Actions (right side): Save button, Run button,
-- Check Syntax button, Delete button (danger style).
@guarantee MetadataRow
-- Two rows of metadata fields above the editor.
-- Row 1: Title (text input), Slug (text input, auto-generated from title).
-- Row 2: Kind (select: utility/macro/transform),
-- Entrypoint (select: dynamically discovered functions with "main" always first),
-- Enabled (checkbox).
@guarantee EditorBody
-- Code editor with Python syntax highlighting.
-- Toolbar: "Content" label.
-- Syntax errors shown as inline markers in editor gutter.
@guarantee FooterLayout
-- Created date and Updated date, locale-formatted.
}
-- ─── Script editor actions ──────────────────────────────────
rule ScriptSave {
when: ScriptSaveRequested(script_id)
-- Lua syntax check first (parse validation)
-- Python syntax check first (parse validation via Python runtime)
-- If syntax error: blocks save, shows error inline in editor gutter
-- If valid: bumps version, saves to DB + rewrites .lua file
-- See engine_side_effects.allium UpdateTemplateSideEffects (same pattern)
-- If valid: bumps version, saves to DB + rewrites .py file
-- Entrypoint list re-discovered from AST after save
}
rule ScriptCheckSyntax {
when: ScriptCheckSyntaxRequested(script_id)
-- Validates Python syntax without saving
-- Shows errors inline in editor gutter
-- Success shown as toast or status indicator
}
rule ScriptRun {
when: ScriptRunRequested(script_id)
-- Executes script in Lua runtime
-- Calls configured entrypoint function (default: render)
-- Executes script in Python runtime
-- Calls configured entrypoint function (default: main)
-- stdout/stderr directed to Output panel tab
-- Output panel auto-opens if not already visible
-- Errors shown in Output panel with line numbers
@@ -45,6 +91,6 @@ rule ScriptRun {
rule ScriptDelete {
when: ScriptDeleteRequested(script_id)
-- No confirmation dialog
-- Deletes DB record + .lua file on disk
-- Deletes DB record + .py file on disk
-- Closes script tab, sidebar removes item
}