feat: implement full heroprompt workspace management
- Add create, save, get, list, and delete for workspaces - Enable adding and removing files/dirs by path or name - Integrate codewalker for recursive file discovery - Make workspaces stateful with created/updated timestamps - Update example to demonstrate new lifecycle methods
This commit is contained in:
@@ -1,38 +1,46 @@
|
||||
#!/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(
|
||||
// mut workspace := heroprompt.new(
|
||||
// path: '${os.home_dir()}/code/github/freeflowuniverse/herolib'
|
||||
// name: 'workspace'
|
||||
// )!
|
||||
|
||||
mut workspace2 := heroprompt.get(
|
||||
name: 'test workspace'
|
||||
mut workspace := heroprompt.get(
|
||||
name: 'example_ws'
|
||||
path: '${os.home_dir()}/code/github/freeflowuniverse/herolib'
|
||||
create: true
|
||||
)!
|
||||
|
||||
// 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')!
|
||||
println('workspace (initial): ${workspace}')
|
||||
println('selected (initial): ${workspace.selected_children()}')
|
||||
|
||||
// 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')!
|
||||
// Add a directory and a file
|
||||
workspace.add_dir(path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker')!
|
||||
workspace.add_file(path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker/docker_ubuntu_install.sh')!
|
||||
println('selected (after add): ${workspace.selected_children()}')
|
||||
|
||||
// workspace1.add_dir(path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker/postgresql')!
|
||||
// Build a prompt from current selection (should be empty now)
|
||||
mut prompt := workspace.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 START ---')
|
||||
println(prompt)
|
||||
println('--- PROMPT END ---')
|
||||
|
||||
// println(prompt)
|
||||
// Remove the file by name, then the directory by name
|
||||
workspace.remove_file(name: 'docker_ubuntu_install.sh') or { println('remove_file: ${err}') }
|
||||
workspace.remove_dir(name: 'docker') or { println('remove_dir: ${err}') }
|
||||
println('selected (after remove): ${workspace.selected_children()}')
|
||||
|
||||
// List workspaces (names only)
|
||||
mut all := heroprompt.list_workspaces() or { []&heroprompt.Workspace{} }
|
||||
mut names := []string{}
|
||||
for w in all { names << w.name }
|
||||
println('workspaces: ${names}')
|
||||
|
||||
// Optionally delete the example workspace
|
||||
workspace.delete_workspace() or { println('delete_workspace: ${err}') }
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
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)!
|
||||
Reference in New Issue
Block a user