feat: Improve Dify installer

- Update installer configuration to be more robust and flexible.
- Remove unnecessary installation steps in the installer script.
- Improve the installer's ability to check if Dify is running.
- Refactor Dify installer actions for better code organization.
- Add build functionality to Dify installer.
This commit is contained in:
Mahmoud-Emad
2025-05-27 12:33:21 +03:00
committed by timurgordon
parent 105611bbfb
commit f93db1d23c
8 changed files with 632 additions and 97 deletions

View File

@@ -4,6 +4,6 @@ import freeflowuniverse.herolib.installers.infra.dify as dify_installer
mut dify := dify_installer.get()!
dify.install()!
dify.start()!
dify.destroy()!
// dify.install()!
// dify.start()!
// dify.destroy()!

View File

@@ -1,13 +1,11 @@
!!hero_code.generate_installer
name:'dify'
classname:'dify'
singleton:1
templates:1
default:1
title:'dify'
supported_platforms:''
reset:0
startupmanager:1
hasconfig:1
build:0
name: "dify"
classname: "DifyInstaller"
hasconfig: true
singleton: true
default: false
title: ""
templates: true
build: true
startupmanager: true
supported_platforms: ""

View File

@@ -2,38 +2,51 @@ module dify
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.installers.virt.docker as docker_installer
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.osal.systemd
import freeflowuniverse.herolib.osal.zinit
import freeflowuniverse.herolib.installers.ulist
import freeflowuniverse.herolib.installers.lang.golang
import freeflowuniverse.herolib.installers.lang.rust
import freeflowuniverse.herolib.installers.lang.python
import os
fn startupcmd() ![]zinit.ZProcessNewArgs {
mut installer := get()!
mut cfg := get()!
mut res := []zinit.ZProcessNewArgs{}
mut path := cfg.path
cmd := "
git clone https://github.com/langgenius/dify.git -b 1.4.0 ${path}
cp ${path}/docker/.env.example ${path}/docker/.env
export COMPOSE_PROJECT_NAME=${cfg.project_name}
docker compose -f ${cfg.compose_file} --env-file ${cfg.path}/docker/.env up -d
"
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
// res << zinit.ZProcessNewArgs{
// name: 'dify'
// cmd: 'dify server'
// env: {
// 'HOME': '/root'
// }
// }
return res
}
fn running() !bool {
cfg := get()!
cmd := 'docker compose -f ${cfg.compose_file} ps | grep dify-web'
result := os.execute(cmd)
mut installer := get()!
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
// this checks health of dify
// curl http://localhost:3333/api/v1/s --oauth2-bearer 1234 works
// url:='http://127.0.0.1:${cfg.port}/api/v1'
// mut conn := httpconnection.new(name: 'dify', url: url)!
if result.exit_code != 0 {
return false
}
return true
// if cfg.secret.len > 0 {
// conn.default_header.add(.authorization, 'Bearer ${cfg.secret}')
// }
// conn.default_header.add(.content_type, 'application/json')
// console.print_debug("curl -X 'GET' '${url}'/tags --oauth2-bearer ${cfg.secret}")
// r := conn.get_json_dict(prefix: 'tags', debug: false) or {return false}
// println(r)
// if true{panic("ssss")}
// tags := r['Tags'] or { return false }
// console.print_debug(tags)
// console.print_debug('dify is answering.')
return false
}
fn start_pre() ! {
@@ -50,21 +63,23 @@ fn stop_post() ! {
//////////////////// following actions are not specific to instance of the object
// checks if a certain version or above is installed
fn installed() !bool {
mut cfg := get()!
mut docker := docker_installer.get()!
docker.install()!
cmd := 'docker compose -f ${cfg.compose_file} ps | grep dify-web'
result := os.execute(cmd)
if result.exit_code != 0 {
return false
}
return true
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
// res := os.execute('${osal.profile_path_source_and()!} dify version')
// if res.exit_code != 0 {
// return false
// }
// r := res.output.split_into_lines().filter(it.trim_space().len > 0)
// if r.len != 1 {
// return error("couldn't parse dify version.\n${res.output}")
// }
// if texttools.version(version) == texttools.version(r[0]) {
// return true
// }
return false
}
// get the Upload List of the files
fn ulist_get() !ulist.UList {
// optionally build a UList which is all paths which are result of building, is then used e.g. in upload
@@ -81,34 +96,92 @@ fn upload() ! {
fn install() ! {
console.print_header('install dify')
mut cfg := get()!
mut docker := docker_installer.get()!
docker.install()!
os.system('sed -i "s/^SECRET_KEY=.*/SECRET_KEY=${cfg.secret_key}/; s/^INIT_PASSWORD=.*/INIT_PASSWORD=${cfg.init_password}/" ${cfg.path}/docker/.env')
osal.execute_silent('docker compose pull -f ${cfg.compose_file} pull')!
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
// mut url := ''
// if core.is_linux_arm()! {
// url = 'https://github.com/dify-dev/dify/releases/download/v${version}/dify_${version}_linux_arm64.tar.gz'
// } else if core.is_linux_intel()! {
// url = 'https://github.com/dify-dev/dify/releases/download/v${version}/dify_${version}_linux_amd64.tar.gz'
// } else if core.is_osx_arm()! {
// url = 'https://github.com/dify-dev/dify/releases/download/v${version}/dify_${version}_darwin_arm64.tar.gz'
// } else if osal.is_osx_intel()! {
// url = 'https://github.com/dify-dev/dify/releases/download/v${version}/dify_${version}_darwin_amd64.tar.gz'
// } else {
// return error('unsported platform')
// }
// mut dest := osal.download(
// url: url
// minsize_kb: 9000
// expand_dir: '/tmp/dify'
// )!
// //dest.moveup_single_subdir()!
// mut binpath := dest.file_get('dify')!
// osal.cmd_add(
// cmdname: 'dify'
// source: binpath.path
// )!
}
fn build() ! {
// url := 'https://github.com/threefoldtech/dify'
// make sure we install base on the node
// if osal.platform() != .ubuntu {
// return error('only support ubuntu for now')
// }
// golang.install()!
// console.print_header('build dify')
// gitpath := gittools.get_repo(coderoot: '/tmp/builder', url: url, reset: true, pull: true)!
// cmd := '
// cd ${gitpath}
// source ~/.cargo/env
// exit 1 #todo
// '
// osal.execute_stdout(cmd)!
//
// //now copy to the default bin path
// mut binpath := dest.file_get('...')!
// adds it to path
// osal.cmd_add(
// cmdname: 'griddriver2'
// source: binpath.path
// )!
}
fn destroy() ! {
mut cfg := get()!
cmd := 'docker compose -f ${cfg.compose_file} down'
result := os.execute(cmd)
// mut systemdfactory := systemd.new()!
// systemdfactory.destroy("zinit")!
if result.exit_code != 0 {
return error("dify isn't running: ${result.output}")
}
// osal.process_kill_recursive(name:'zinit')!
// osal.cmd_delete('zinit')!
// Remove docker
mut docker := docker_installer.get()!
docker.destroy()!
// osal.package_remove('
// podman
// conmon
// buildah
// skopeo
// runc
// ')!
mut zinit_factory := zinit.new()!
if zinit_factory.exists('dify') {
zinit_factory.stop('dify') or {
return error('Could not stop dify service due to: ${err}')
}
zinit_factory.delete('dify') or {
return error('Could not delete dify service due to: ${err}')
}
}
console.print_header('Dify installation removed')
// //will remove all paths where go/bin is found
// osal.profile_path_add_remove(paths2delete:"go/bin")!
// osal.rm("
// podman
// conmon
// buildah
// skopeo
// runc
// /var/lib/containers
// /var/lib/podman
// /var/lib/buildah
// /tmp/podman
// /tmp/conmon
// ")!
}

View File

@@ -0,0 +1,113 @@
module dify
// import freeflowuniverse.herolib.osal
// import freeflowuniverse.herolib.ui.console
// import freeflowuniverse.herolib.installers.virt.docker as docker_installer
// import freeflowuniverse.herolib.core.texttools
// import freeflowuniverse.herolib.core.pathlib
// import freeflowuniverse.herolib.osal.systemd
// import freeflowuniverse.herolib.osal.zinit
// import freeflowuniverse.herolib.installers.ulist
// import os
// fn startupcmd() ![]zinit.ZProcessNewArgs {
// mut installer := get()!
// mut cfg := get()!
// println('Just a print statment')
// println(cfg)
// mut res := []zinit.ZProcessNewArgs{}
// // mut path := cfg.path
// // cmd := '
// // git clone https://github.com/langgenius/dify.git -b 1.4.0 ${path}
// // cp ${path}/docker/.env.example ${path}/docker/.env
// // export COMPOSE_PROJECT_NAME=${cfg.project_name}
// // docker compose -f ${cfg.compose_file} --env-file ${cfg.path}/docker/.env up -d
// // '
// return res
// }
// fn running() !bool {
// cfg := get()!
// // cmd := 'docker compose -f ${cfg.compose_file} ps | grep dify-web'
// // result := os.execute(cmd)
// // if result.exit_code != 0 {
// // return false
// // }
// return true
// }
// fn start_pre() ! {
// }
// fn start_post() ! {
// }
// fn stop_pre() ! {
// }
// fn stop_post() ! {
// }
// //////////////////// following actions are not specific to instance of the object
// fn installed() !bool {
// mut cfg := get()!
// mut docker := docker_installer.get()!
// docker.install()!
// // cmd := 'docker compose -f ${cfg.compose_file} ps | grep dify-web'
// // result := os.execute(cmd)
// // if result.exit_code != 0 {
// // return false
// // }
// return true
// }
// // get the Upload List of the files
// fn ulist_get() !ulist.UList {
// // optionally build a UList which is all paths which are result of building, is then used e.g. in upload
// return ulist.UList{}
// }
// // uploads to S3 server if configured
// fn upload() ! {
// // installers.upload(
// // cmdname: 'dify'
// // source: '${gitpath}/target/x86_64-unknown-linux-musl/release/dify'
// // )!
// }
// fn install() ! {
// console.print_header('install dify')
// mut cfg := get()!
// mut docker := docker_installer.get()!
// docker.install()!
// // os.system('sed -i "s/^SECRET_KEY=.*/SECRET_KEY=${cfg.secret_key}/; s/^INIT_PASSWORD=.*/INIT_PASSWORD=${cfg.init_password}/" ${cfg.path}/docker/.env')
// // osal.execute_silent('docker compose pull -f ${cfg.compose_file} pull')!
// }
// fn destroy() ! {
// mut cfg := get()!
// // cmd := 'docker compose -f ${cfg.compose_file} down'
// // result := os.execute(cmd)
// // if result.exit_code != 0 {
// // return error("dify isn't running: ${result.output}")
// // }
// // Remove docker
// // mut docker := docker_installer.get()!
// // docker.destroy()!
// // mut zinit_factory := zinit.new()!
// // if zinit_factory.exists('dify') {
// // zinit_factory.stop('dify') or { return error('Could not stop dify service due to: ${err}') }
// // zinit_factory.delete('dify') or {
// // return error('Could not delete dify service due to: ${err}')
// // }
// // }
// console.print_header('Dify installation removed')
// }

View File

@@ -8,7 +8,7 @@ import freeflowuniverse.herolib.osal.zinit
import time
__global (
dify_global map[string]&dify
dify_global map[string]&DifyInstaller
dify_default string
)
@@ -28,10 +28,10 @@ fn args_get(args_ ArgsGet) ArgsGet {
return args
}
pub fn get(args_ ArgsGet) !&dify {
pub fn get(args_ ArgsGet) !&DifyInstaller {
mut context := base.context()!
mut args := args_get(args_)
mut obj := dify{
mut obj := DifyInstaller{
name: args.name
}
if args.name !in dify_global {
@@ -51,7 +51,7 @@ pub fn get(args_ ArgsGet) !&dify {
}
// register the config for the future
pub fn set(o dify) ! {
pub fn set(o DifyInstaller) ! {
set_in_mem(o)!
mut context := base.context()!
heroscript := heroscript_dumps(o)!
@@ -75,7 +75,7 @@ pub fn delete(args_ ArgsGet) ! {
}
// only sets in mem, does not set as config
fn set_in_mem(o dify) ! {
fn set_in_mem(o DifyInstaller) ! {
mut o2 := obj_init(o)!
dify_global[o.name] = &o2
dify_default = o.name
@@ -166,12 +166,12 @@ fn startupmanager_get(cat zinit.StartupManagerType) !startupmanager.StartupManag
}
// load from disk and make sure is properly intialized
pub fn (mut self dify) reload() ! {
pub fn (mut self DifyInstaller) reload() ! {
switch(self.name)
self = obj_init(self)!
}
pub fn (mut self dify) start() ! {
pub fn (mut self DifyInstaller) start() ! {
switch(self.name)
if self.running()! {
return
@@ -208,13 +208,13 @@ pub fn (mut self dify) start() ! {
return error('dify did not install properly.')
}
pub fn (mut self dify) install_start(args InstallArgs) ! {
pub fn (mut self DifyInstaller) install_start(args InstallArgs) ! {
switch(self.name)
self.install(args)!
self.start()!
}
pub fn (mut self dify) stop() ! {
pub fn (mut self DifyInstaller) stop() ! {
switch(self.name)
stop_pre()!
for zprocess in startupcmd()! {
@@ -224,13 +224,13 @@ pub fn (mut self dify) stop() ! {
stop_post()!
}
pub fn (mut self dify) restart() ! {
pub fn (mut self DifyInstaller) restart() ! {
switch(self.name)
self.stop()!
self.start()!
}
pub fn (mut self dify) running() !bool {
pub fn (mut self DifyInstaller) running() !bool {
switch(self.name)
// walk over the generic processes, if not running return
@@ -250,14 +250,19 @@ pub mut:
reset bool
}
pub fn (mut self dify) install(args InstallArgs) ! {
pub fn (mut self DifyInstaller) install(args InstallArgs) ! {
switch(self.name)
if args.reset || (!installed()!) {
install()!
}
}
pub fn (mut self dify) destroy() ! {
pub fn (mut self DifyInstaller) build() ! {
switch(self.name)
build()!
}
pub fn (mut self DifyInstaller) destroy() ! {
switch(self.name)
self.stop() or {}
destroy()!

View File

@@ -0,0 +1,279 @@
module dify
// import freeflowuniverse.herolib.core.base
// import freeflowuniverse.herolib.core.playbook
// import freeflowuniverse.herolib.ui.console
// import freeflowuniverse.herolib.osal.startupmanager
// import freeflowuniverse.herolib.osal.zinit
// import time
// __global (
// dify_global map[string]&Dify
// dify_default string
// )
// /////////FACTORY
// @[params]
// pub struct ArgsGet {
// pub mut:
// name string
// }
// fn args_get(args_ ArgsGet) ArgsGet {
// mut args := args_
// if args.name == '' {
// args.name = 'default'
// }
// return args
// }
// pub fn get(args_ ArgsGet) !&Dify {
// mut context := base.context()!
// mut args := args_get(args_)
// mut obj := Dify{}
// if args.name !in dify_global {
// if !exists(args)! {
// set(obj)!
// } else {
// heroscript := context.hero_config_get('dify', args.name)!
// mut obj_ := heroscript_loads(heroscript)!
// set_in_mem(obj_)!
// }
// }
// return dify_global[args.name] or {
// println(dify_global)
// // bug if we get here because should be in globals
// panic('could not get config for dify with name, is bug:${args.name}')
// }
// }
// // register the config for the future
// pub fn set(o Dify) ! {
// set_in_mem(o)!
// mut context := base.context()!
// heroscript := heroscript_dumps(o)!
// context.hero_config_set('dify', o.name, heroscript)!
// }
// // does the config exists?
// pub fn exists(args_ ArgsGet) !bool {
// mut context := base.context()!
// mut args := args_get(args_)
// return context.hero_config_exists('dify', args.name)
// }
// pub fn delete(args_ ArgsGet) ! {
// mut args := args_get(args_)
// mut context := base.context()!
// context.hero_config_delete('dify', args.name)!
// if args.name in dify_global {
// // del dify_global[args.name]
// }
// }
// // only sets in mem, does not set as config
// fn set_in_mem(o Dify) ! {
// mut o2 := obj_init(o)!
// dify_global[o.name] = &o2
// dify_default = o.name
// }
// @[params]
// pub struct PlayArgs {
// pub mut:
// heroscript string // if filled in then plbook will be made out of it
// plbook ?playbook.PlayBook
// reset bool
// }
// pub fn play(args_ PlayArgs) ! {
// mut args := args_
// mut plbook := args.plbook or { playbook.new(text: args.heroscript)! }
// mut install_actions := plbook.find(filter: 'dify.configure')!
// if install_actions.len > 0 {
// for install_action in install_actions {
// heroscript := install_action.heroscript()
// mut obj2 := heroscript_loads(heroscript)!
// set(obj2)!
// }
// }
// mut other_actions := plbook.find(filter: 'dify.')!
// for other_action in other_actions {
// if other_action.name in ['destroy', 'install', 'build'] {
// mut p := other_action.params
// reset := p.get_default_false('reset')
// if other_action.name == 'destroy' || reset {
// console.print_debug('install action dify.destroy')
// destroy()!
// }
// if other_action.name == 'install' {
// console.print_debug('install action dify.install')
// install()!
// }
// }
// if other_action.name in ['start', 'stop', 'restart'] {
// mut p := other_action.params
// name := p.get('name')!
// mut dify_obj := get(name: name)!
// console.print_debug('action object:\n${dify_obj}')
// if other_action.name == 'start' {
// console.print_debug('install action dify.${other_action.name}')
// dify_obj.start()!
// }
// if other_action.name == 'stop' {
// console.print_debug('install action dify.${other_action.name}')
// dify_obj.stop()!
// }
// if other_action.name == 'restart' {
// console.print_debug('install action dify.${other_action.name}')
// dify_obj.restart()!
// }
// }
// }
// }
// ////////////////////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////# LIVE CYCLE MANAGEMENT FOR INSTALLERS ///////////////////////////////////
// ////////////////////////////////////////////////////////////////////////////////////////////////////
// fn startupmanager_get(cat zinit.StartupManagerType) !startupmanager.StartupManager {
// // unknown
// // screen
// // zinit
// // tmux
// // systemd
// match cat {
// .zinit {
// console.print_debug('startupmanager: zinit')
// return startupmanager.get(cat: .zinit)!
// }
// .systemd {
// console.print_debug('startupmanager: systemd')
// return startupmanager.get(cat: .systemd)!
// }
// else {
// console.print_debug('startupmanager: auto')
// return startupmanager.get()!
// }
// }
// }
// // load from disk and make sure is properly intialized
// pub fn (mut self Dify) reload() ! {
// switch(self.name)
// self = obj_init(self)!
// }
// pub fn (mut self Dify) start() ! {
// switch(self.name)
// if self.running()! {
// return
// }
// console.print_header('dify start')
// if !installed()! {
// install()!
// }
// configure()!
// start_pre()!
// for zprocess in startupcmd()! {
// mut sm := startupmanager_get(zprocess.startuptype)!
// console.print_debug('starting dify with ${zprocess.startuptype}...')
// sm.new(zprocess)!
// sm.start(zprocess.name)!
// }
// start_post()!
// for _ in 0 .. 50 {
// if self.running()! {
// return
// }
// time.sleep(100 * time.millisecond)
// }
// return error('dify did not install properly.')
// }
// pub fn (mut self Dify) install_start(args InstallArgs) ! {
// switch(self.name)
// self.install(args)!
// self.start()!
// }
// pub fn (mut self Dify) stop() ! {
// switch(self.name)
// stop_pre()!
// for zprocess in startupcmd()! {
// mut sm := startupmanager_get(zprocess.startuptype)!
// sm.stop(zprocess.name)!
// }
// stop_post()!
// }
// pub fn (mut self Dify) restart() ! {
// switch(self.name)
// self.stop()!
// self.start()!
// }
// pub fn (mut self Dify) running() !bool {
// switch(self.name)
// // walk over the generic processes, if not running return
// for zprocess in startupcmd()! {
// mut sm := startupmanager_get(zprocess.startuptype)!
// r := sm.running(zprocess.name)!
// if r == false {
// return false
// }
// }
// return running()!
// }
// @[params]
// pub struct InstallArgs {
// pub mut:
// reset bool
// }
// pub fn (mut self Dify) install(args InstallArgs) ! {
// switch(self.name)
// if args.reset || (!installed()!) {
// install()!
// }
// }
// pub fn (mut self Dify) build() ! {
// switch(self.name)
// build()!
// }
// pub fn (mut self Dify) destroy() ! {
// switch(self.name)
// self.stop() or {}
// destroy()!
// }
// // switch instance to be used for dify
// pub fn switch(name string) {
// dify_default = name
// }
// // helpers
// @[params]
// pub struct DefaultConfigArgs {
// instance string = 'default'
// }

View File

@@ -7,20 +7,22 @@ import rand
pub const version = '0.0.0'
const singleton = true
const default = true
const default = false
// THIS THE THE SOURCE OF THE INFORMATION OF THIS FILE, HERE WE HAVE THE CONFIG OBJECT CONFIGURED AND MODELLED
@[heap]
pub struct Dify {
pub struct DifyInstaller {
pub mut:
path string = '/opt/dify'
init_password string
secret_key string
project_name string = 'dify'
compose_file string = '/opt/dify/docker/docker-compose.yaml'
name string = 'default'
path string = '/opt/dify'
init_password string
secret_key string
project_name string = 'dify'
compose_file string = '/opt/dify/docker/docker-compose.yaml'
}
// your checking & initialization code if needed
fn obj_init(mycfg_ dify) !dify {
fn obj_init(mycfg_ DifyInstaller) !DifyInstaller {
mut mycfg := mycfg_
if mycfg.path == '' {
mycfg.path = '/opt/dify'
@@ -38,9 +40,9 @@ fn obj_init(mycfg_ dify) !dify {
mycfg.project_name = 'dify'
}
if mycfg.compose_file == '' {
mycfg.compose_file = '/opt/dify/docker/docker-compose.yaml'
}
if mycfg.compose_file == '' {
mycfg.compose_file = '/opt/dify/docker/docker-compose.yaml'
}
return mycfg
}
@@ -56,12 +58,11 @@ fn configure() ! {
/////////////NORMALLY NO NEED TO TOUCH
pub fn heroscript_dumps(obj dify) !string {
return encoderhero.encode[dify](obj)!
pub fn heroscript_dumps(obj DifyInstaller) !string {
return encoderhero.encode[DifyInstaller](obj)!
}
pub fn heroscript_loads(heroscript string) !dify {
mut obj := encoderhero.decode[dify](heroscript)!
pub fn heroscript_loads(heroscript string) !DifyInstaller {
mut obj := encoderhero.decode[DifyInstaller](heroscript)!
return obj
}

View File

@@ -0,0 +1,66 @@
module dify
// import freeflowuniverse.herolib.data.paramsparser
// import freeflowuniverse.herolib.data.encoderhero
// import os
// import rand
// pub const version = '0.0.0'
// const singleton = true
// const default = true
// @[heap]
// pub struct Dify {
// pub mut:
// path string = '/opt/dify'
// init_password string
// secret_key string
// project_name string = 'dify'
// compose_file string = '/opt/dify/docker/docker-compose.yaml'
// }
// // your checking & initialization code if needed
// fn obj_init(mycfg_ dify) !dify {
// mut mycfg := mycfg_
// if mycfg.path == '' {
// mycfg.path = '/opt/dify'
// }
// if mycfg.secret_key == '' {
// mycfg.secret_key = rand.hex(42)
// }
// if mycfg.init_password == '' {
// mycfg.init_password = 'slfjbv9NaflKsgjv'
// }
// if mycfg.project_name == '' {
// mycfg.project_name = 'dify'
// }
// if mycfg.compose_file == '' {
// mycfg.compose_file = '/opt/dify/docker/docker-compose.yaml'
// }
// return mycfg
// }
// // called before start if done
// fn configure() ! {
// // mut installer := get()!
// // mut mycode := $tmpl('templates/atemplate.yaml')
// // mut path := pathlib.get_file(path: cfg.configpath, create: true)!
// // path.write(mycode)!
// // console.print_debug(mycode)
// }
// /////////////NORMALLY NO NEED TO TOUCH
// pub fn heroscript_dumps(obj dify) !string {
// return freeflowuniverse.herolib.data.encoderhero.encode[dify](obj)!
// }
// pub fn heroscript_loads(heroscript string) !dify {
// mut obj := freeflowuniverse.herolib.data.encoderhero.decode[dify](heroscript)!
// return obj
// }