feat: Script Generator Phase 1+2 — backend, engine, API, frontend, template editor, parameter detector

Complete Script Generator feature including:

Backend:
- ScriptCategory, ScriptTemplate, ScriptGeneration models
- ScriptTemplateEngine with substitution, filters, sanitization
- CRUD + share API endpoints with permission checks
- Integration tests for permissions and sharing
- Migration 057 with AD User Management seed templates

Frontend — Script Library:
- Browse templates with category tabs and search
- Configure pane with parameter form and script generation
- Script preview with live substitution and copy/download
- scriptGeneratorStore Zustand store

Frontend — Template Editor:
- Full CRUD form with metadata, script body (Monaco Editor), parameters
- ParameterSchemaBuilder with visual builder + JSON toggle
- ScriptManagePage with routing and nav link

Frontend — Parameter Detector:
- Client-side PowerShell parameter detection engine
- Detects script-level param() blocks and variable assignments
- Type inference from PS type annotations and value patterns
- ParameterDetectorStepper one-by-one review UI with accept/skip

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit was merged in pull request #105.
This commit is contained in:
chihlasm
2026-03-14 20:18:59 -04:00
committed by GitHub
parent 83b13fcd26
commit d4dbf44781
50 changed files with 11916 additions and 11 deletions

View File

@@ -0,0 +1,70 @@
import { Terminal } from 'lucide-react'
import { useScriptGeneratorStore } from '@/store/scriptGeneratorStore'
import { ScriptParameterField } from './ScriptParameterField'
import type { ScriptParametersSchema, ScriptParameter } from '@/types'
interface Props {
canGenerate: boolean
}
export function ScriptParameterForm({ canGenerate }: Props) {
const selectedTemplate = useScriptGeneratorStore(s => s.selectedTemplate)
const paramValues = useScriptGeneratorStore(s => s.paramValues)
const formErrors = useScriptGeneratorStore(s => s.formErrors)
if (!selectedTemplate) return null
const schema = selectedTemplate.parameters_schema as ScriptParametersSchema
const parameters = (schema?.parameters ?? []).slice().sort((a, b) => a.order - b.order)
// Group parameters: null-group first, then named groups in order of first appearance
const ungrouped = parameters.filter(p => p.group === null)
const groupOrder: string[] = []
const grouped: Record<string, ScriptParameter[]> = {}
for (const p of parameters) {
if (p.group !== null) {
if (!grouped[p.group]) {
grouped[p.group] = []
groupOrder.push(p.group)
}
grouped[p.group].push(p)
}
}
const renderParam = (param: ScriptParameter) => (
<ScriptParameterField
key={param.key}
param={param}
value={paramValues[param.key] ?? ''}
error={formErrors[param.key] || undefined}
disabled={!canGenerate}
/>
)
if (parameters.length === 0) {
return (
<div className="flex items-center gap-2 rounded-lg border border-border bg-white/[0.02] px-3 py-3">
<Terminal size={14} className="text-muted-foreground shrink-0" />
<p className="text-xs text-muted-foreground">
This template has no parameters click <span className="text-foreground font-medium">Generate</span> to produce the script.
</p>
</div>
)
}
return (
<div className="flex flex-col gap-4">
{ungrouped.map(renderParam)}
{groupOrder.map(group => (
<div key={group}>
<p className="font-label text-[0.625rem] uppercase tracking-[0.1em] text-muted-foreground mb-3">
{group}
</p>
<div className="flex flex-col gap-4">
{grouped[group].map(renderParam)}
</div>
</div>
))}
</div>
)
}