Skip to content

Latest commit

 

History

History
607 lines (498 loc) · 25.3 KB

README.md

File metadata and controls

607 lines (498 loc) · 25.3 KB

MiniIDE

License: Apache-2.0 Language: MiniLang

MiniIDE is a small native Windows IDE for MiniLang, written in MiniLang. It is intentionally lightweight: no Electron shell, no web runtime, and no large framework. The application uses Win32 controls directly and focuses on the core edit/build/run loop for MiniLang projects.

API documentation

The committed MiniDoc API reference documents the editor, project and build services, native debugger and Git integration, MiniPixels catalog, Markdown renderer, and assistant provider. A searchable offline copy is available at docs/api/html/index.html.

pwsh .\tools\generate_minidoc.ps1
pwsh .\tools\generate_minidoc.ps1 -Check

Regenerating the committed reference requires MiniDoc 0.4.9 or newer. The script uses MINIDOC_EXE or a sibling MiniDoc\build\minidoc.exe; pass -MiniDoc to select another executable.

MiniIDE uses //! file comments and /// declaration comments with structured contracts. Its strict minidoc.toml configuration fails on missing or malformed documentation.

The MiniLang compiler is not part of this repository. MiniIDE can invoke the self-hosted mlc_win64.exe or the Python mlc_win64.py compiler. Python must be on PATH when a Python tool or compiler is selected.

Current Status

MiniIDE is an MVP-level IDE with a working native Windows UI. It can open and create MiniLang projects, edit source files, compile and run programs, run test entries, display compiler diagnostics, navigate symbols, render local Markdown help, and switch between dark and light themes.

The repository currently targets Windows because the UI is built directly on Win32 APIs and RichEdit.

Features

  • Native Win32 application written in MiniLang.
  • Project tree using SysTreeView32.
  • Editor tabs using SysTabControl32.
  • RichEdit-based source editor with dirty-file tracking.
  • MiniLang syntax highlighting.
  • Build, rebuild, clean, stop, run, and run-tests commands.
  • Native GDB debugging with compiler-emitted source symbols, breakpoints, stepping, and navigable call stacks; the probe debugger retains scalar runtime variable previews.
  • Individual zero-argument test functions with a running result list and a command to rerun all cases still failing.
  • Background compiler and process execution without cmd.exe.
  • Live compiler, run, and test output in the bottom Console panel.
  • Automatic compile-before-run when the target executable is missing or stale.
  • Captured stdout/stderr in Console, with a separate persistent diagnostic Log.
  • Compiler diagnostics, project diagnostics, and code inspections parsed into a clickable Problems/results panel.
  • Lightweight active-file live diagnostics summary in the status bar after editor idle.
  • Bottom Assistant panel with project-aware read-only tool context and OpenAI/OpenAI-compatible provider settings.
  • Project-wide symbol outline and search, including classes, interfaces, methods, fields, and top-level variables. Open source buffers are indexed before they are saved; typed receivers and this support member completion and go-to-definition for indexed project types.
  • Active-file Variables & Attributes view for fields, parameters, and assignment expressions. These are source previews, not runtime values.
  • Go to line and go to definition.
  • Find, find-next, and completion. Project member chains and member navigation use the MiniLang Python compiler parser; rename previews exclude comments and strings and reject ambiguous declarations.
  • Standard project wizard with console/library project type selection.
  • Tree context actions for creating test files, renaming, and deleting items.
  • Debug/release build profiles.
  • Project-local compiler and build settings.
  • Dark and light theme support.
  • Rendered Markdown tabs for local help and language-reference content.
  • MiniPixels manifest projects with validation, asset packing, build and run through the MiniPixels project driver.
  • MiniPixels asset catalog in an IDE tab and native image, sprite-frame, text, audio, and video preview window. The catalog decodes unprotected MPX1 pack payloads and shows packed image frames. Sprite frames can play in the gallery. Protected-pack build metadata is shown without decrypting its contents.
  • MiniDoc generation and project documentation in a Markdown tab, refreshed when project sources or configuration change.
  • Native MiniLang Git menu for changes, stage/unstage, local commits, diffs, and first-parent history. It reads loose and packed Git objects without invoking Git or Python at runtime.

Bottom panels and diagnostics

The bottom area has Console, Log, Problems, Git, Results, and Assistant tabs. Console shows compiler, program, and test output. Log shows timestamped IDE events and caught errors. Problems, Git, and Results retain their latest list when you switch tabs; background build output does not take focus from the selected tab. All six tabs are available in the command palette.

The diagnostic log is stored at <project>/build/miniide.log, with one rotated backup at miniide.log.1 after the active file exceeds 2 MiB. The Log tab shows its newest 100,000 characters. Errors include the MiniLang error code, message, source file, line, and function when available. Startup and main-loop operations are caught and recorded; a repeatedly failing background phase is disabled after three identical errors so the other panels remain usable. A fatal startup error reports the log location in its dialog. The IDE records operation names and error messages without deliberately logging editor text or assistant keys.

Native Git

Open a project inside a Git worktree and use Git > Changes to inspect staged, working, and untracked files. Select a row to stage or unstage that file, view its working or staged line diff, or open it in the editor. Git > Commit Staged Changes commits the current index using the repository's user.name and user.email. Git > Commit History shows recent local first-parent commits. These commands are also in the command palette.

The engine in src/git/ is written in MiniLang. It understands SHA-1 and SHA-256 object IDs, loose objects, version-two pack indexes with Git deltas, Git index versions 2 and 3, local refs, and basic .gitignore rules. It writes blobs, trees, commits, the index, and branch refs. Git and Python are not used by these IDE commands. Remote fetch/push, merge, rebase, hooks, reflogs, submodules, and Git index version 4 are not implemented. Git attributes and advanced ignore/configuration rules are not fully supported; use Git itself for repositories that depend on them.

MiniPixels and MiniDoc

Open a folder containing minipixels.json, or select that manifest with File > Open Project. MiniIDE reads the project name and main source from the manifest and shows source, manifest, and asset files in the tree. Build, Rebuild, and Run use MiniPixels' Python driver for these projects. File > MiniPixels also offers Validate, Pack Assets, Asset Catalog, and Visual Preview. The catalog is generated in build/miniide-assets/; its Markdown view and native visual gallery open in MiniIDE. The gallery shows source images, generated procedural sprites, individual sprite-sheet frames, text or JSON snippets, and native audio/video controls. Double-clicking an image, audio, or video file in the project tree opens the same native preview. The Open Externally button is available when Windows' embedded media control cannot decode a format. Sprite-frame extraction uses Pillow from MiniPixels' requirements.txt. Play Frames cycles source or packed sprite frames. For MPX1 packs, the catalog validates the index and decodes raw, Deflate, RLE, and LZ4 payloads into previews. Protected MPX3 index contents remain encrypted, so the catalog shows the build report and pack status instead.

Debugging and individual tests

The Debug build profile passes MiniLang 1.3.17's --debug-info flag to normal program and test builds. This embeds DWARF function, source-line, and stack-frame records in the executable. Release builds omit the flag. Set debug.pdb=true in .miniide.cfg to also request a matching Windows PDB; this requires the MSVC x64 link.exe. Keep the PDB with its EXE. Symbol builds are larger and slower to compile, and the compiler disables selected inlining. The flag requires an unpacked build.

File > Start Native Debugging (Ctrl+Shift+F6) compiles the original project sources with --debug-info and starts GDB. F9 toggles source breakpoints, Ctrl+F5 continues, and F10 steps into the next source line. The call stack shows native function names and navigable source locations. GDB must be on PATH; Python runs the IDE's GDB controller. Native MiniLang 1.3.17 symbols do not yet describe local-variable values.

File > Start Debugging (Ctrl+F6) remains the probe-based mode for scalar parameter and local-variable previews. It compiles an instrumented project copy using the MiniLang Python frontend. Both modes use the same breakpoint, Continue, Step Into, Call Stack, and Stop controls. Their binaries and control files are in <project>/build/miniide-debug/.

File > Run Selected Test Case runs the selected test* function or a test function containing the caret in an isolated project copy. It expects no parameters and treats a false result, nonzero integer result, or process error as a failure. Results accumulate in a clickable list for the current project session. Rerun Failed Test Cases repeats all cases still failing. The individual runner requires Python; the selected ML or Python compiler performs the build.

The MiniPixels driver is discovered in a sibling MiniPixels checkout. It handles minipixels.json, assets.mpx, generated modules, protected packs, and native runtime artifacts. For MiniPixels builds with no compiler override, MiniIDE selects the newest release_*_py compiler found in the workspace for MiniPixels builds, then falls back to the sibling Python checkout. Ordinary projects prefer the newest release_*_ml compiler. Select either compiler in Configuration > Use MiniLang ML Compiler or Use MiniLang Python Compiler; the choice is stored in .miniide.cfg and overrides automatic selection.

Help > Generate Project MiniDoc generates Markdown and HTML documentation under build/minidoc/; View Project MiniDoc opens its Markdown index in MiniIDE. Links between generated Markdown pages and anchors open inside the IDE. MiniPixels projects first generate missing generated.assets modules so MiniDoc can resolve their imports. A sibling MiniDoc/build/minidoc.exe is required. View Project MiniDoc regenerates documentation when source files, the project manifest, or MiniDoc configuration are newer than the generated Markdown; already open Markdown tabs reload changed output. MiniDoc uses the selected compiler's standard library when the project config does not specify one. If strict documentation warnings produce output with a nonzero exit code, the generated pages still open and the warnings remain in the build log.

Repository Layout

src/
  ai/             Assistant configuration and read-only MiniIDE context helpers.
  build/          Background build, run, clean, and process-control services.
  editor/         Editor buffer helpers.
  help/           Language-reference lookup and search helpers.
  lang/           MiniLang syntax and symbol helpers.
  platform/       Win32 declarations and native UI wrappers.
  project/        Project files, .miniide.cfg parsing, and project templates.
  ui/             Theme, Markdown rendering, and command palette helpers.
  main.ml         Win32 application shell, layout, command dispatch, and startup.

tests/
  run_tests.ps1   Windows test runner and UI smoke test.
  *_test.ml       Focused MiniLang regression tests.

examples/
  hello/          Small sample project.

projects/
  MiniLangProject/
  MiniLangProject2/
                  Generated-project examples.

MiniIDE.mlproj    MiniIDE project file.

Generated output belongs in build/ folders and is ignored by Git.

External Compiler Dependency

MiniIDE builds projects with either the self-hosted mlc_win64.exe or the Python mlc_win64.py compiler. The AST based editor queries and source instrumentation need the Python compiler frontend even when the ML compiler performs the final build.

The repository deliberately does not vendor the compiler sources or compiler build output. For local development, use one of these layouts:

MiniIDE/
  MiniLangCompilerML/
    build/
      mlc_win64.exe

or keep the compiler elsewhere and point .miniide.cfg at it:

compiler=C:\path\to\mlc_win64.exe

The checked-in .miniide.cfg.example can be copied to .miniide.cfg for local configuration. .miniide.cfg itself is ignored because it usually contains machine-specific paths.

Requirements

  • Windows x64.
  • PowerShell.
  • Git, for repository development and the native Git integration test oracle.
  • A local MiniLang 1.3.17 ML or Python compiler.
  • Python for MiniPixels integration, AST editor queries, the debugger, and individual test cases. Pillow is needed for image and sprite previews.
  • GDB on PATH for native source-level debugging; MSVC x64 link.exe only when Windows PDB generation is enabled.
  • RichEdit/MSFTEDIT support, available on normal Windows installations.

Build

From the repository root, with the 1.3.17 Python compiler release in the parent workspace:

python ..\release_1_3_17_py\mlc_win64.py .\src\main.ml .\build\MiniIDE.exe -I .\src -I ..\release_1_3_17_py --keep-going --max-errors 160 --subsystem windows

This writes:

build\MiniIDE.exe

The IDE project file uses build\MiniIDE_dev.exe as its normal development output so that a running build\MiniIDE.exe is not overwritten from inside the IDE.

Run

Start MiniIDE:

.\build\MiniIDE.exe

Open a specific project root:

.\build\MiniIDE.exe .\examples\hello

Inside MiniIDE, use File > Run or the Run ribbon button to run the active project executable. MiniIDE checks whether the executable is missing or older than the project sources/configuration; if needed, it compiles first and starts the program after a successful build.

Program output is captured in the bottom log view and written to:

build\last_run.log

Tests

Run the full test suite:

.\tests\run_tests.ps1

The full test runner:

  • performs static source wiring checks;
  • compiles and runs focused command palette metadata/search tests;
  • compiles and runs focused Markdown renderer tests;
  • exercises packed MiniPixels decoding, compiler AST queries, individual test execution, and the debugger control protocol when Python is available;
  • compiles and runs project-loader tests;
  • compiles MiniIDE to an isolated temporary executable;
  • starts MiniIDE and runs a Win32 message-based UI smoke test;
  • verifies background compilation;
  • verifies auto-compile-before-run;
  • verifies test build/run behavior;
  • exercises build profiles, clean/rebuild/stop, theme switching, and language help commands.

For a faster non-UI check:

.\tests\run_tests.ps1 -SkipUi

Use -KeepArtifacts when investigating temporary test outputs:

.\tests\run_tests.ps1 -KeepArtifacts

Project Files

MiniIDE reads simple .mlproj files:

name=MiniIDE
type=console
entry=src\main.ml
output=build\MiniIDE_dev.exe
testEntry=tests\main_test.ml
runArgs=
workingDir=.
importPath=src
importPath=MiniLangCompilerML

Common keys:

  • name: project display/build name.
  • type: usually console or library.
  • entry: main source file.
  • output: executable or library output path.
  • testEntry: optional test entry file used by File > Run Tests.
  • runArgs: arguments passed when running the project.
  • workingDir: process working directory for run/test commands.
  • importPath: additional MiniLang import roots.

Standard Project Structure

New projects created by MiniIDE use this layout:

src\main.ml
src\app\
src\lib\
lib\
tests\main_test.ml
assets\data\
assets\icons\
build\
.miniide.cfg
<name>.mlproj
README.md

Configuration

Use Configuration > Compile Settings... to choose:

  • main file;
  • output file;
  • compiler executable;
  • maximum compiler errors;
  • subsystem;
  • keep-going mode;
  • extra compiler arguments.

Configuration: Toggle Keep-going, Configuration: Toggle Max Errors, and Configuration: Toggle Subsystem are available from the command palette for quickly switching compiler behavior while working.

Use Configuration > Select Compiler... to choose a project-specific compiler executable. MiniIDE stores local build settings in .miniide.cfg:

compiler=C:\path\to\mlc_win64.exe
profile=debug
keepGoing=true
maxErrors=20
subsystem=windows
extraArgs=

Configuration > Reset Compiler to Default resets builds to the default compiler path. Configuration > Build Profile: Debug/Release switches the active build profile. Optional profile overrides use keys such as:

debug.maxErrors=160
release.keepGoing=false
release.extraArgs=--trace-calls

Configuration > Show Configuration displays the effective compiler, entry file, output file, import paths, and build options. extraArgs is appended to the compiler command for advanced flags such as heap or tracing options.

Use Configuration > AI Assistant Settings... to configure the optional coding assistant. When enabled, MiniIDE sends the user prompt plus local tool context to an OpenAI-compatible chat-completions endpoint through native WinHTTP networking. The context can include the active file excerpt, open tab excerpts, indexed project files, the latest build log, and a MiniLang language-reference excerpt. MiniIDE exposes OpenAI-compatible tools for the active file, open tabs, project file list, bounded project-file reads, current selection, latest build log, MiniLang help, diagnostics, symbol search, and references. In ai.toolMode=write, the assistant can also overwrite/create project files and perform exact text replacements, guarded so paths must stay inside the current project. The assistant may request tools over up to twelve local rounds; MiniIDE executes them locally, streams tool results into the Assistant panel, and then forces a final response without additional tools if the round limit is reached.

API keys are referenced through an environment variable name such as OPENAI_API_KEY by default. If needed, the assistant settings can be switched to direct-key mode; in that mode MiniIDE stores ai.apiKey in .miniide.cfg, so environment-variable mode remains the safer default for shared projects. For private OpenAI-compatible clusters with self-signed certificates, ai.allowInsecureTls=true relaxes certificate validation for assistant requests only.

ai.enabled=false
ai.provider=openai
ai.baseUrl=https://api.openai.com/v1
ai.apiKeyMode=env
ai.apiKeyEnv=OPENAI_API_KEY
ai.apiKey=
ai.model=gpt-5.1
ai.toolMode=read-only
ai.allowInsecureTls=false
ai.includeOpenTabs=true
ai.includeProjectFiles=true
ai.includeMiniLangHelp=true

Main Commands

The command palette filters results as you type and supports label, alias, shortcut, acronym, and fuzzy subsequence searches such as qof or qopen for Quick Open File. Filtered results are ordered by match strength, so direct label and alias hits stay ahead of acronym and fuzzy matches. Use the arrow keys, Page Up/Down, Home, and End to move through filtered results.

File menu:

  • New Project...: create a standard MiniLang project.
  • Open Project...: open a .mlproj file or project directory.
  • Quick Open File... / Ctrl+P: find project files with ranked matches; a single filtered match opens directly, while multiple matches stay selectable in the results panel.
  • Recent Files / Ctrl+E: list open editor tabs with open-file count and the active file in the panel title.
  • Close Tab: close the active editor tab.
  • Save: save the active editor tab.
  • Save All / Ctrl+Shift+S: save all dirty editable tabs.
  • Build: compile the current project.
  • Run: compile if needed, then run the project executable.
  • Run Tests: build and run the configured testEntry.
  • Clean: remove known build outputs and logs.
  • Rebuild: clean and force a fresh build.
  • Stop: terminate the active background build/run process.

Edit menu:

  • Find... / Ctrl+F: search within the active editor tab.
  • Find Next / F3: repeat the last search.
  • Select All / Ctrl+A: select all text in the active editor tab.
  • Undo, Redo, Cut, Copy, and Paste are available from the menu, editor context menu, and command palette.
  • Complete / Ctrl+Space: show MiniLang keyword and project-symbol completions with symbol-kind and source-location labels plus prefix, substring, and fuzzy matches.
  • Format Document: trim trailing whitespace and collapse excessive blank lines.
  • Window: Close Other Tabs and Window: Close All Tabs are available from the command palette and tab context menu.
  • Output: Copy, Output: Select All, and Output: Clear are available from the command palette and bottom log context menu.

Navigation menu:

  • Navigate Back / Alt+Left and Navigate Forward / Alt+Right: move through explicit jump history.
  • Toggle Bookmark / Ctrl+F2: add or remove a session bookmark on the current line.
  • Bookmarks / Shift+F2: show session bookmarks in the results panel.
  • Next Bookmark / Alt+Down and Previous Bookmark / Alt+Up: cycle through bookmarked locations.
  • Reveal Active File / Alt+F1: select the active editor file in the project tree.
  • Outline: show package/function/struct/const symbols for the active file, with function, type, constant, and scope totals in the panel title.
  • File Structure / Ctrl+F12: show symbols in the active file.
  • Workspace Health: summarize indexed files, symbols, imports, tests, inspections, diagnostics, severity totals, and an overall status.
  • TODOs: list TODO/FIXME comments across project source files, with TODO and FIXME totals in the panel title.
  • Test Explorer: list the configured test entry and discovered test-like functions, with configured, discovered, and missing totals in the panel title.
  • Project Symbols and Go to Symbol... / Ctrl+T: browse or ranked-filter symbols across the project with prefix, substring, and fuzzy matches.
  • Go to Line... / Ctrl+G: jump to a line in the active editor tab.
  • Go to Definition / F12: jump to a matching project symbol.
  • Find References / Shift+F12: list project references for the current symbol, with match totals in the panel title.
  • Related Tests: find tests that import the active source file or match the foo.ml to foo_test.ml / test_foo.ml naming convention, with related file and symbol totals in the panel title.
  • Import Graph: list project imports with resolved and unresolved totals in the panel title.
  • Call Hierarchy: list definitions and references for the current symbol, with definition and reference totals in the panel title.
  • Code Inspections: list lightweight project findings such as duplicate declarations, unused import aliases, and possibly unused symbols, with severity totals in the panel title.
  • Search Word in Project: search the current word across project .ml files.
  • Problems: show diagnostics from project analysis, code inspections, missing configured entry files, missing working directories, missing import paths, duplicate import aliases, and the last build log, with severity totals in the panel title.

Help menu:

  • Home: open local project layout and shortcuts.
  • MiniLang Language Reference: open the compiler README as rendered Markdown.
  • Search MiniLang Help...: search the language reference and open rendered search results.

Diagnostics And Results

Build diagnostics, symbol outline entries, project search results, and help search results are displayed in the bottom results panel.

Problems open on selection. Compiler-log diagnostics open on click. Other result lists open with a double-click.

The status bar refreshes lightweight active-file diagnostics after editor idle. It checks the current editor text for missing imports, duplicate import aliases, and TODO/FIXME hints. Open editor buffers are included in project navigation, inspections, and TODOs. Build and MiniDoc generation save edited source files before running their external tools.

Quick Open and project symbol search rank exact/prefix matches ahead of substring and compact fuzzy matches, so short queries such as mtest can find tests\main_test.ml without typing the full path.

Markdown Help

MiniIDE renders Markdown help files into read-only editor tabs. The renderer supports headings, inline emphasis, links, code spans, fenced MiniLang code blocks, nested inline formatting, and theme-aware styling.

The language reference follows the selected compiler checkout. With automatic selection it opens the newest available release in the workspace, for example:

release_1_3_16_ml\README.md

If the compiler checkout is not present in the expected location, configure the compiler path or place the compiler repository next to MiniIDE as described above.

License

MiniIDE is licensed under the Apache License, Version 2.0. See LICENSE.