develop.heroprompt #
heroprompt
To get started
import incubaid.herolib.develop.heroprompt
// Example Usage:
// 1. Create a new workspace
mut workspace := heroprompt.new(name: 'my_workspace', path: os.getwd())!
// 2. Add a directory to the workspace
workspace.add_dir(path: './my_project_dir')!
// 3. Add a file to the workspace
workspace.add_file(path: './my_project_dir/main.v')!
// 4. Generate a prompt
user_instructions := 'Explain the code in main.v'
prompt_output := workspace.prompt(text: user_instructions)
println(prompt_output)
Constants #
const version = '0.0.0'
fn delete #
fn delete(args ArgsGet) !
fn exists #
fn exists(args ArgsGet) !bool
does the config exists?
fn generate_random_workspace_name #
fn generate_random_workspace_name() string
Generate a random name for the workspace
fn get #
fn get(args ArgsGet) !&Workspace
fn get_file_extension #
fn get_file_extension(filename string) string
Utility function to get file extension with special handling for common files
fn heroscript_loads #
fn heroscript_loads(heroscript string) !Workspace
///////////NORMALLY NO NEED TO TOUCH
fn list #
fn list(args ArgsList) ![]&Workspace
if fromdb set: load from filesystem, and not from mem, will also reset what is in mem
fn list_workspaces #
fn list_workspaces() ![]&Workspace
List workspaces (wrapper over factory list)
fn list_workspaces_fromdb #
fn list_workspaces_fromdb() ![]&Workspace
fn new #
fn new(args ArgsGet) !&Workspace
fn play #
fn play(mut plbook PlayBook) !
fn set #
fn set(o Workspace) !
register the config for the future
fn switch #
fn switch(name string)
switch instance to be used for heroprompt
struct AddDirParams #
struct AddDirParams {
pub mut:
path string @[required]
}
Selection API
struct AddFileParams #
struct AddFileParams {
pub mut:
path string @[required]
}
struct ArgsGet #
struct ArgsGet {
pub mut:
name string = 'default'
fromdb bool // will load from filesystem
create bool // default will not create if not exist
}
///////FACTORY
struct ArgsList #
struct ArgsList {
pub mut:
fromdb bool // will load from filesystem
}
struct HeropromptChild #
struct HeropromptChild {
pub mut:
content string
path pathlib.Path
name string
include_tree bool // when true and this child is a dir, include full subtree in maps/contents
}
fn (HeropromptChild) read #
fn (chl HeropromptChild) read() !string
Read the file content
struct HeropromptTmpPrompt #
struct HeropromptTmpPrompt {
pub mut:
user_instructions string
file_map string
file_contents string
}
struct ListArgs #
struct ListArgs {
pub mut:
path string // if empty, will use workspace.base_path
}
List entries in a directory relative to this workspace base or absolute
struct ListItem #
struct ListItem {
pub:
name string
typ string @[json: 'type']
}
struct RemoveParams #
struct RemoveParams {
pub mut:
path string
name string
}
Removal API
struct UpdateParams #
struct UpdateParams {
pub mut:
name string
base_path string
}
Update this workspace (name and/or base_path)
struct Workspace #
struct Workspace {
pub mut:
name string = 'default' // Workspace name
base_path string // Base path of the workspace
children []HeropromptChild // List of directories and files in this workspace
created time.Time // Time of creation
updated time.Time // Time of last update
is_saved bool
}
Workspace represents a workspace containing multiple directories and their selected files for AI prompt generation
fn (Workspace) add_dir #
fn (mut wsp Workspace) add_dir(args AddDirParams) !HeropromptChild
add a directory to the selection (no recursion stored; recursion is done on-demand)
fn (Workspace) add_file #
fn (mut wsp Workspace) add_file(args AddFileParams) !HeropromptChild
add a file to the selection
fn (Workspace) delete_workspace #
fn (wsp &Workspace) delete_workspace() !
Delete this workspace from the store
fn (Workspace) list #
fn (wsp &Workspace) list() ![]ListItem
fn (Workspace) list_dir #
fn (wsp &Workspace) list_dir(rel_path string) ![]ListItem
fn (Workspace) prompt #
fn (wsp Workspace) prompt(args WorkspacePrompt) string
fn (Workspace) remove_dir #
fn (mut wsp Workspace) remove_dir(args RemoveParams) !
Remove a directory from the selection (by absolute path or name)
fn (Workspace) remove_file #
fn (mut wsp Workspace) remove_file(args RemoveParams) !
Remove a file from the selection (by absolute path or name)
fn (Workspace) selected_children #
fn (wsp Workspace) selected_children() []HeropromptChild
Get the currently selected children (copy)
fn (Workspace) update_workspace #
fn (wsp &Workspace) update_workspace(args UpdateParams) !&Workspace
struct WorkspacePrompt #
struct WorkspacePrompt {
pub mut:
text string
}
- README
- Constants
- fn delete
- fn exists
- fn generate_random_workspace_name
- fn get
- fn get_file_extension
- fn heroscript_loads
- fn list
- fn list_workspaces
- fn list_workspaces_fromdb
- fn new
- fn play
- fn set
- fn switch
- struct AddDirParams
- struct AddFileParams
- struct ArgsGet
- struct ArgsList
- struct HeropromptChild
- struct HeropromptTmpPrompt
- struct ListArgs
- struct ListItem
- struct RemoveParams
- struct UpdateParams
- struct Workspace
- struct WorkspacePrompt