refactor: simplify heroprompt workspace selection model
- Introduce HeropromptChild to unify file and dir items - Replace nested Dir/File structs with a flat `children` list - Generate prompt content by traversing the filesystem on-demand - Add `workspace.add_file` for direct file selection - Simplify `workspace.add_dir` to only add the directory path
This commit is contained in:
@@ -1,49 +1,38 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.develop.heroprompt
|
||||
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import os
|
||||
|
||||
|
||||
heroscript_config := '
|
||||
!!heropromptworkspace.configure name:"test workspace" path:"${os.home_dir()}/code/github/freeflowuniverse/herolib"
|
||||
'
|
||||
mut plbook := playbook.new(
|
||||
text: heroscript_config
|
||||
)!
|
||||
|
||||
heroprompt.play(mut plbook)!
|
||||
|
||||
mut workspace1 := heroprompt.new_workspace(
|
||||
path: '${os.home_dir()}/code/github/freeflowuniverse/herolib'
|
||||
)!
|
||||
|
||||
// mut workspace2 := heroprompt.get(
|
||||
// name: 'test workspace'
|
||||
// heroscript_config := '
|
||||
// !!heropromptworkspace.configure name:"test workspace" path:"${os.home_dir()}/code/github/freeflowuniverse/herolib"
|
||||
// '
|
||||
// mut plbook := playbook.new(
|
||||
// text: heroscript_config
|
||||
// )!
|
||||
|
||||
mut dir1 := workspace1.add_dir(path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker')!
|
||||
dir1.select_file(name: 'docker_ubuntu_install.sh')!
|
||||
// heroprompt.play(mut plbook)!
|
||||
|
||||
mut dir2 := workspace1.add_dir(
|
||||
path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker/herolib'
|
||||
// mut workspace1 := heroprompt.new_workspace(
|
||||
// path: '${os.home_dir()}/code/github/freeflowuniverse/herolib'
|
||||
// )!
|
||||
|
||||
mut workspace2 := heroprompt.get(
|
||||
name: 'test workspace'
|
||||
)!
|
||||
|
||||
dir2.select_file(name: '.gitignore')!
|
||||
dir2.select_file(name: 'build.sh')!
|
||||
file := dir2.select_file(name: 'debug.sh')!
|
||||
// println(file.read()!)
|
||||
// workspace1.add_dir(path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker')!
|
||||
// workspace1.add_file(path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker/docker_ubuntu_install.sh')!
|
||||
|
||||
mut dir3 := workspace1.add_dir(
|
||||
path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker/postgresql'
|
||||
select_all: true
|
||||
)!
|
||||
// workspace1.add_dir(path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker/herolib')!
|
||||
// workspace1.add_file(path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker/herolib/.gitignore')!
|
||||
// workspace1.add_file(path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker/herolib/build.sh')!
|
||||
// workspace1.add_file(path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker/herolib/debug.sh')!
|
||||
|
||||
selected := workspace1.get_selected()
|
||||
// workspace1.add_dir(path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker/postgresql')!
|
||||
|
||||
prompt := workspace1.prompt(
|
||||
text: 'Using the selected files, i want you to get all print statments'
|
||||
)
|
||||
// prompt := workspace1.prompt(
|
||||
// text: 'Using the selected files, i want you to get all print statments'
|
||||
// )
|
||||
|
||||
println(prompt)
|
||||
// println(prompt)
|
||||
|
||||
Reference in New Issue
Block a user