Skip to content

web.ui #

HeroPrompt Web UI

A clean web interface for creating and managing AI prompts with file and workspace management.

Overview

HeroPrompt provides a VS Code–style interface to browse files, organize workspaces, and generate AI prompts. It combines a modern UI with intelligent file handling and flexible prompt generation.

Features

  • 🎨 Modern UI: Light/dark themes, responsive layout, smooth animations
  • πŸ“ Workspaces: Create, update, delete, and persist workspaces
  • πŸ—‚οΈ File Explorer: Tree view, filtering, expand/collapse, multi-select
  • πŸ” Preview: Card-based file previews with metadata and syntax highlighting
  • πŸš€ Prompt Generation: Build structured AI prompts from selected files

Usage

./cli/compile.vsh   ##./hero web          ##
  • Create a workspace β†’ select files β†’ preview β†’ generate prompts
  • Manage workspaces (create, update, delete) via UI

fn detect_lang #

fn detect_lang(path string) string

Language detection utility for code files

fn get_default_menu #

fn get_default_menu() []MenuItem

Default menu for the Admin UI. Used when no custom menu is provided.

fn new #

fn new(args FactoryArgs) !&App

fn render_chat_alt #

fn render_chat_alt(app &App) !string

fn render_heroprompt_page #

fn render_heroprompt_page(app &App) !string

Render the Heroprompt admin page using feature template

fn render_heroscript_alt #

fn render_heroscript_alt(app &App) !string

Render HeroScript page

fn start #

fn start(args FactoryArgs) !

Start the webserver (blocking)

struct App #

struct App {
	veb.StaticHandler
pub mut:
	title string
	menu  []MenuItem
	port  int
}

The App holds server state and config

fn (App) admin_index #

fn (app &App) admin_index(mut ctx Context) veb.Result

Admin home page

fn (App) admin_section #

fn (app &App) admin_section(mut ctx Context, path string) veb.Result

Catch-all content under /admin/*

fn (App) api_heroprompt_add_dir #

fn (app &App) api_heroprompt_add_dir(mut ctx Context, name string) veb.Result

fn (App) api_heroprompt_add_file #

fn (app &App) api_heroprompt_add_file(mut ctx Context, name string) veb.Result

fn (App) api_heroprompt_delete #

fn (app &App) api_heroprompt_delete(mut ctx Context, name string) veb.Result

Delete endpoint using POST (VEB framework compatibility)

fn (App) api_heroprompt_directory #

fn (app &App) api_heroprompt_directory(mut ctx Context) veb.Result

fn (App) api_heroprompt_file #

fn (app &App) api_heroprompt_file(mut ctx Context) veb.Result

fn (App) api_heroprompt_generate_prompt #

fn (app &App) api_heroprompt_generate_prompt(mut ctx Context, name string) veb.Result

fn (App) api_heroprompt_get #

fn (app &App) api_heroprompt_get(mut ctx Context, name string) veb.Result

wsp := hp.get(name: name, create: true, path: base_path) or { return ctx.text(json_error('create failed')) } ctx.set_content_type('application/json') return ctx.text(json.encode({ 'name': wsp.name 'base_path': wsp.base_path })) }

fn (App) api_heroprompt_list #

fn (app &App) api_heroprompt_list(mut ctx Context) veb.Result

APIs

fn (App) api_heroprompt_sync_selection #

fn (app &App) api_heroprompt_sync_selection(mut ctx Context, name string) veb.Result

fn (App) api_heroprompt_update #

fn (app &App) api_heroprompt_update(mut ctx Context, name string) veb.Result

fn (App) api_test #

fn (app &App) api_test(mut ctx Context) veb.Result

Test API endpoint to verify routing works

fn (App) root #

fn (app &App) root(mut ctx Context) veb.Result

Redirect root to /admin

fn (App) serve_colors_css #

fn (app &App) serve_colors_css(mut ctx Context) veb.Result

Serve shared static assets (colors.css, main.css, theme.js)

fn (App) serve_main_css #

fn (app &App) serve_main_css(mut ctx Context) veb.Result

fn (App) serve_theme_js #

fn (app &App) serve_theme_js(mut ctx Context) veb.Result

struct Context #

struct Context {
	veb.Context
}

Public Context type for veb

struct FactoryArgs #

@[params]
struct FactoryArgs {
pub mut:
	name  string = 'default'
	host  string = 'localhost'
	port  int    = 9999
	title string = 'Admin'
	menu  []MenuItem
	open  bool
}

Factory args