feat: implement workspace file tree listing

- Add `list()` method to generate a full workspace file tree
- Introduce `WorkspaceItem` and `WorkspaceList` structs
- Remove `HeropromptSession` to simplify the public API
- Rename Heroscript action to `heropromptworkspace.configure`
- Enable full heroscript encoding/decoding for workspaces
This commit is contained in:
Mahmoud-Emad
2025-08-14 15:45:26 +03:00
parent a58d72615d
commit 2d00d6cf9f
14 changed files with 305 additions and 288 deletions

View File

@@ -2,25 +2,41 @@
import freeflowuniverse.herolib.develop.heroprompt
mut session := heroprompt.new_session()
import freeflowuniverse.herolib.core.playbook
import os
mut workspace1 := session.add_workspace()!
// TODO: Check the name bug
// mut workspace2 := session.add_workspace(name: 'withname')!
mut dir1 := workspace1.add_dir(path: '/Users/mahmoud/code/github/freeflowuniverse/herolib/docker')!
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'
// )!
mut dir1 := workspace1.add_dir(path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker')!
dir1.select_file(name: 'docker_ubuntu_install.sh')!
mut dir2 := workspace1.add_dir(
path: '/Users/mahmoud/code/github/freeflowuniverse/herolib/docker/herolib'
path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker/herolib'
)!
dir2.select_file(name: '.gitignore')!
dir2.select_file(name: 'build.sh')!
dir2.select_file(name: 'debug.sh')!
file := dir2.select_file(name: 'debug.sh')!
// println(file.read()!)
mut dir3 := workspace1.add_dir(
path: '/Users/mahmoud/code/github/freeflowuniverse/herolib/docker/postgresql'
path: '${os.home_dir()}/code/github/freeflowuniverse/herolib/docker/postgresql'
select_all: true
)!

View File

@@ -0,0 +1,15 @@
#!/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)!