diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b90bd2..7790358 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,29 @@ ## [Unreleased] +### Changed - Nickel as primary form and config format + +All form definitions and backend configs migrated from TOML to Nickel (`.ncl`). + +**Examples** (`examples/01-basic/` through `examples/17-advanced-i18n/`): all `.toml` form files +replaced with type-checked `.ncl` equivalents using Nickel contracts and `| default` annotations. + +**Backend configs** (`config/cli/`, `config/tui/`, `config/web/`, `config/ai/`, `config/ag/`, +`config/prov-gen/`): `default.toml`, `dev.toml`, `production.toml` replaced with `config.ncl`, +`dev.ncl`, `production.ncl`. Each expresses schema constraints inline (`| default`, `| String`, +`| Bool`) rather than raw TOML values. + +**Config loader** (`crates/typedialog-core/src/config/cli_loader.rs`): search order updated to +prefer `.ncl` over `.toml`. NCL files are loaded via `nickel export --format json` and deserialised +with `serde_json`; TOML path retained as fallback. New order: + +1. `{backend}/{TYPEDIALOG_ENV}.ncl` +2. `{backend}/{TYPEDIALOG_ENV}.toml` +3. `{backend}/config.ncl` +4. `{backend}/config.toml` + +TOML form definitions remain supported — no breaking change to the parser or any backend. + ### Refactored - Eliminate duplicated field execution logic **Single source of truth for CLI field dispatch** diff --git a/README.md b/README.md index 3bffb8c..cf1c514 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ - **6 Backends**: CLI (inquire), TUI (ratatui), Web (axum), AI (RAG/embeddings), Agent (LLM execution), Prov-gen (IaC generation) - **8 Prompt Types**: text, confirm, select, multi-select, password, date, editor, custom -- **Declarative Forms**: TOML-based definitions with fragments & composition +- **Declarative Forms**: Nickel (`.ncl`) definitions with type contracts, fragments & composition (TOML also supported) - **4 Output Formats**: JSON, YAML, TOML, Nickel with roundtrip conversion - **Zero Runtime Dependencies**: Core library works standalone @@ -68,7 +68,7 @@ just test::all cargo run --example form # Run with defaults pre-loaded -typedialog form config.toml --defaults defaults.json +typedialog form config.ncl --defaults defaults.json ```text ## Unified Command Interface @@ -77,15 +77,15 @@ All backends are accessible through the **single `typedialog` command** with aut ```bash # Each backend can be invoked directly via typedialog -typedialog web form config.toml --port 8080 # Web backend (browser forms) -typedialog tui config.toml # TUI backend (terminal UI) +typedialog web form config.ncl --port 8080 # Web backend (browser forms) +typedialog tui config.ncl # TUI backend (terminal UI) typedialog ai serve --port 8765 # AI backend (RAG assistant) typedialog ag run agent.mdx # Agent backend (LLM agents) typedialog prov-gen generate --spec project.ncl # Provisioning generator # Or use specific binaries if you prefer -typedialog-web form config.toml --port 8080 -typedialog-tui config.toml +typedialog-web form config.ncl --port 8080 +typedialog-tui config.ncl typedialog-ai serve --port 8765 typedialog-ag run agent.mdx typedialog-prov-gen generate --spec project.ncl @@ -98,7 +98,7 @@ typedialog ag -h typedialog prov-gen -h ```text -All backends produce identical JSON output from the same TOML form definition, making it easy to switch between interfaces without changing your data. +All backends produce identical JSON output from the same form definition (Nickel or TOML), making it easy to switch between interfaces without changing your data. ## Backends at a Glance @@ -117,7 +117,7 @@ typedialog select "Choose role" Admin User Guest typedialog text "Email" --format json # Pre-populate form with defaults -typedialog form schema.toml --defaults config.json --format json +typedialog form schema.ncl --defaults config.json --format json ```text **Use for:** Scripts, CI/CD pipelines, server tools, piping between tools @@ -129,10 +129,10 @@ Full terminal UI with keyboard navigation and mouse support. ```bash # Via dispatcher -typedialog tui config.toml +typedialog tui config.ncl # Or run directly -typedialog-tui config.toml +typedialog-tui config.ncl cargo run -p typedialog-tui --example form_with_autocompletion ```text @@ -145,11 +145,11 @@ HTTP server with browser-based forms. ```bash # Via dispatcher -typedialog web form config.toml --port 8080 +typedialog web form config.ncl --port 8080 # Or run directly -typedialog-web form config.toml --port 8080 -cargo run -p typedialog-web -- --config config/web/dev.toml +typedialog-web form config.ncl --port 8080 +cargo run -p typedialog-web -- --config config/web/dev.ncl # Open http://localhost:8080 ```text @@ -168,10 +168,10 @@ typedialog ai serve --port 8765 typedialog-ai serve --port 8765 # Query knowledge base -typedialog-ai --config config/ai/dev.toml --query "How do I configure encryption?" +typedialog-ai --config config/ai/dev.ncl --query "How do I configure encryption?" # Build knowledge graph -typedialog-ai --config config/ai/production.toml --build-graph ./docs +typedialog-ai --config config/ai/production.ncl --build-graph ./docs ```text **Use for:** Documentation search, context-aware assistance, knowledge retrieval, semantic search @@ -319,13 +319,10 @@ typedialog-prov-gen --name myproject --dry-run Generate interactive forms from Nickel schemas, collect user input, and produce validated configuration output: ```bash -# 1. Define schema in Nickel -nickel eval config.ncl > schema.toml +# 1. Define form directly in Nickel +typedialog form config.ncl --backend tui -# 2. Run interactive form -typedialog form schema.toml --backend tui - -# 3. Get validated output in any format +# 2. Get validated output in any format # JSON, YAML, TOML, or back to Nickel with type preservation ```text diff --git a/assets/web/README.md b/assets/web/README.md new file mode 100644 index 0000000..321575b --- /dev/null +++ b/assets/web/README.md @@ -0,0 +1,86 @@ +# TypeDialog Web Assets + +Web-based landing page, architecture diagram, and static content for TypeDialog. + +## Directory Structure + +```text +assets/web/ +├── src/ +│ ├── index.html # Source HTML (readable) +│ └── architecture-diagram.html # Source architecture viewer +├── index.html # Minified/Production HTML +├── architecture-diagram.html # Minified architecture viewer +├── typedialog_architecture.svg # Architecture diagram (dark mode) +├── typedialog_architecture_white.svg # Architecture diagram (light mode) +├── minify.sh # Build script +└── README.md +``` + +## Files + +### `src/index.html` - Source Landing Page + +- Inline CSS and JavaScript (no external dependencies beyond Inter font) +- Bilingual content (English/Spanish) with localStorage persistence +- Dark/light theme toggle with logo swap +- Responsive design (mobile-first) +- Link to architecture diagram viewer + +### `src/architecture-diagram.html` - Architecture Viewer + +- Full-page SVG architecture diagram +- Dark/light theme toggle (swaps between two SVG variants) +- Back-link to landing page +- Shares theme preference with landing page via localStorage + +### Architecture SVGs + +Two variants of the architecture diagram: + +- `typedialog_architecture.svg` - Dark background (#0f0f1a) +- `typedialog_architecture_white.svg` - Light background (#ffffff) + +Both show the complete TypeDialog architecture: + +- Form Definitions layer (Nickel + TOML + load_form) +- typedialog-core (three-phase execution, core modules, BackendFactory) +- 6 Backends (CLI, TUI, Web, AI, Agent, Prov-Gen) +- Output formats (JSON, YAML, TOML, Nickel Roundtrip) +- LLM Providers (Claude, OpenAI, Gemini, Ollama) +- Integrations (Nushell, Nickel Contracts, Tera, Multi-Cloud, CI/CD) + +## Development + +Edit source files in `src/`, then regenerate minified versions: + +```bash +chmod +x assets/web/minify.sh +./assets/web/minify.sh +``` + +## Deployment + +Serve from any static web server: + +```bash +# Rust +cargo install static-web-server +static-web-server -d assets/web/ + +# Python +python3 -m http.server --directory assets/web + +# Node.js +npx http-server assets/web +``` + +Logo SVGs are referenced from the parent `assets/` directory via relative paths (`../typedialog_logo_h.svg`). + +## Features + +- **Responsive**: Mobile-first with media queries +- **Performance**: Inline CSS/JS, no frameworks, minified production +- **Bilingual**: EN/ES with dynamic switching +- **Theming**: Dark/light with localStorage persistence and logo swap +- **Architecture**: SVG diagram with dark/light variants showing full system diff --git a/assets/web/architecture-diagram.html b/assets/web/architecture-diagram.html new file mode 100644 index 0000000..35bc679 --- /dev/null +++ b/assets/web/architecture-diagram.html @@ -0,0 +1 @@ +
Typed dialogs for inputs, forms and schemas you can trust
Declarative forms with Nickel/TOML definitions, 6 backends (CLI, TUI, Web, AI, Agent, Prov-Gen), and type-safe validation. From interactive prompts to infrastructure generation.
One schema. Every surface.
One Nickel or TOML definition drives CLI, TUI, Web, and AI. No per-backend form code. The schema is the single source of truth.
Nickel contracts validate every predicate at load time. Unknown predicates cause hard failures, not silent passes. No parallel Rust reimplementation.
Fragment loading happens once at load_form(). The three-phase executor is pure — no filesystem access, no side effects during user interaction.
Interactive forms generate validated infrastructure configurations for 6 cloud providers. 7-layer validation pipeline from forms to final JSON.
Define forms in Nickel (.ncl) or TOML (.toml). Nickel provides contracts, imports, and type-safe composition. TOML provides zero-dependency simplicity. Both produce identical FormDefinition structs.
Phase 1: Execute selector fields that control conditionals. Phase 2: Build element list (pure, no I/O). Phase 3: Dispatch to backend with when/when_false evaluation. Complete or field-by-field rendering modes.
Compile-time feature gates (#[cfg(feature)]) eliminate dead backend code. Runtime BackendType match dispatches to Box<dyn FormBackend>. Auto-detection via TYPEDIALOG_BACKEND env var with CLI fallback.
AI backend with RAG, embeddings, and semantic search. Agent backend executes .agent.mdx files with multi-LLM support (Claude, OpenAI, Gemini, Ollama). Template variables, file imports, streaming output.
Prov-Gen transforms form answers into IaC configurations. 6 cloud providers (AWS, GCP, Azure, Hetzner, UpCloud, LXD). 7-layer validation: Forms → Constraints → Values → Validators → Schemas → Defaults → JSON.
Read .ncl schemas, collect user input via any backend, generate validated .ncl output preserving contracts. ContractParser extracts validators. TemplateRenderer preserves formatting. when_false ensures all schema fields have values.