From 5d1e3d416ea5a48521a0a5c8c70552ad78766eb4 Mon Sep 17 00:00:00 2001 From: openhands Date: Sat, 9 Aug 2025 19:57:37 +0000 Subject: [PATCH 1/3] Fix issue #104: Add notworking.md documenting biztools examples test results --- examples/biztools/notworking.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/biztools/notworking.md diff --git a/examples/biztools/notworking.md b/examples/biztools/notworking.md new file mode 100644 index 00000000..b5a7666d --- /dev/null +++ b/examples/biztools/notworking.md @@ -0,0 +1,28 @@ +# BizTools Examples Test Results + +## Working Examples +- `bizmodel.vsh` - This example works correctly and displays a spreadsheet with business model data. + +## Non-Working Examples +All other examples have issues with the `bizmodel.play()` function: + +1. `bizmodel1.vsh` - Error: Unknown field `heroscript` in struct literal of type `PlayBook`. +2. `bizmodel2.vsh` - Error: Unknown field `heroscript` in struct literal of type `PlayBook`. +3. `bizmodel_complete.vsh` - Error: Unknown field `heroscript_path` in struct literal of type `PlayBook`. +4. `bizmodel_export.vsh` - Error: Unknown field `heroscript_path` in struct literal of type `PlayBook`. +5. `bizmodel_full.vsh` - Error: Unknown field `heroscript_path` in struct literal of type `PlayBook`. +6. `costs.vsh` - Error: Unknown field `heroscript` in struct literal of type `PlayBook`. +7. `funding.vsh` - Error: Unknown field `heroscript` in struct literal of type `PlayBook`. +8. `hr.vsh` - Error: Unknown field `heroscript` in struct literal of type `PlayBook`. + +## Common Error Pattern +All non-working examples have the same pattern of errors: + +1. Unknown field (`heroscript` or `heroscript_path`) in struct literal of type `PlayBook`. +2. Reference field `PlayBook.session` must be initialized. +3. Function `bizmodel.play` parameter `plbook` is `mut`, so it requires `mut PlayBook{...}` instead. + +## Environment Setup +- Tests were performed with V language version 0.4.11 a11de72 +- Redis server was running during tests +- All tests were executed from the `/workspace/project/herolib/examples/biztools` directory \ No newline at end of file From af63e266d87c316f55d11fee22e2bbacd02010e9 Mon Sep 17 00:00:00 2001 From: openhands Date: Sat, 9 Aug 2025 20:01:37 +0000 Subject: [PATCH 2/3] Fix issue #104: Add fixed examples and solution documentation --- examples/biztools/bizmodel1_fixed.vsh | 34 +++++++++++++++++++++++++++ examples/biztools/bizmodel2_fixed.vsh | 32 +++++++++++++++++++++++++ examples/biztools/notworking.md | 28 ++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100755 examples/biztools/bizmodel1_fixed.vsh create mode 100755 examples/biztools/bizmodel2_fixed.vsh diff --git a/examples/biztools/bizmodel1_fixed.vsh b/examples/biztools/bizmodel1_fixed.vsh new file mode 100755 index 00000000..48f3327c --- /dev/null +++ b/examples/biztools/bizmodel1_fixed.vsh @@ -0,0 +1,34 @@ +#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run + +import freeflowuniverse.herolib.biz.bizmodel +import freeflowuniverse.herolib.core.playbook +import os + +heroscript := " + +Next will define an OEM product in month 10, 1 Million EUR, ... cogs is a percent which is 20% at start but goes to 10% after 20 months. + +!!bizmodel.revenue_define bizname:'test' name:'oem1' + descr:'OEM Deals' + revenue:'10:1000000EUR,15:3333,20:1200000' + cogs_percent: '1:20%,20:15%' cogs_delay:1 + + +This time we have the cogs defined in fixed manner, the default currency is USD doesn't have to be mentioned. + +!!bizmodel.revenue_define bizname:'test' name:'oem2' + descr:'OEM Deals' + revenue:'10:1000000EUR,15:3333,20:1200000' + cogs: '10:100000,15:1000,20:120000' +" + +// Create a new playbook with the heroscript text +mut pb := playbook.new(text: heroscript)! + +// Play the bizmodel actions +bizmodel.play(mut pb)! + +// Get the bizmodel and print it +mut bm := bizmodel.get('test')! + +bm.sheet.pprint(nr_columns: 30)! \ No newline at end of file diff --git a/examples/biztools/bizmodel2_fixed.vsh b/examples/biztools/bizmodel2_fixed.vsh new file mode 100755 index 00000000..963c962d --- /dev/null +++ b/examples/biztools/bizmodel2_fixed.vsh @@ -0,0 +1,32 @@ +#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run + +import freeflowuniverse.herolib.biz.bizmodel +import freeflowuniverse.herolib.core.playbook +import os + +heroscript := " + +!!bizmodel.revenue_define bizname:'test' name:'oem1' + descr:'OEM Deals' + revenue:'10:1000000EUR,15:3333,20:1200000' + cogs_percent: '1:20%,20:15%' cogs_delay:1 + +!!bizmodel.cost_define bizname:'test' name:'rent' + descr:'Rent for office' + cost:'1:10000EUR,15:15000EUR' + +!!bizmodel.cost_define bizname:'test' name:'marketing' + descr:'Marketing Costs' + cost:'1:5000EUR,15:10000EUR' +" + +// Create a new playbook with the heroscript text +mut pb := playbook.new(text: heroscript)! + +// Play the bizmodel actions +bizmodel.play(mut pb)! + +// Get the bizmodel and print it +mut bm := bizmodel.get('test')! + +bm.sheet.pprint(nr_columns: 30)! \ No newline at end of file diff --git a/examples/biztools/notworking.md b/examples/biztools/notworking.md index b5a7666d..fa56c4bf 100644 --- a/examples/biztools/notworking.md +++ b/examples/biztools/notworking.md @@ -2,6 +2,8 @@ ## Working Examples - `bizmodel.vsh` - This example works correctly and displays a spreadsheet with business model data. +- `bizmodel1_fixed.vsh` - Fixed version of bizmodel1.vsh +- `bizmodel2_fixed.vsh` - Fixed version of bizmodel2.vsh ## Non-Working Examples All other examples have issues with the `bizmodel.play()` function: @@ -22,6 +24,32 @@ All non-working examples have the same pattern of errors: 2. Reference field `PlayBook.session` must be initialized. 3. Function `bizmodel.play` parameter `plbook` is `mut`, so it requires `mut PlayBook{...}` instead. +## Solution +The examples can be fixed by using the `playbook.new()` function to create a properly initialized PlayBook: + +```v +// Create a new playbook with the heroscript text +mut pb := playbook.new(text: heroscript)! + +// Play the bizmodel actions +bizmodel.play(mut pb)! + +// Get the bizmodel and print it +mut bm := bizmodel.get('test')! +``` + +For examples using a heroscript path, use: + +```v +// Create a new playbook with the heroscript path +mut pb := playbook.new(path: heroscript_path)! + +// Play the bizmodel actions +bizmodel.play(mut pb)! +``` + +Fixed examples have been provided for `bizmodel1.vsh` and `bizmodel2.vsh` as a reference. + ## Environment Setup - Tests were performed with V language version 0.4.11 a11de72 - Redis server was running during tests From 2968e4dddccd1cf4e9e27b340ceefa3e746db3e0 Mon Sep 17 00:00:00 2001 From: openhands Date: Sat, 9 Aug 2025 20:08:51 +0000 Subject: [PATCH 3/3] Fix issue #104: Fix all biztools examples to use playbook.new() --- examples/biztools/bizmodel1.vsh | 8 +++++- examples/biztools/bizmodel1_fixed.vsh | 34 ---------------------- examples/biztools/bizmodel2.vsh | 8 +++++- examples/biztools/bizmodel2_fixed.vsh | 32 --------------------- examples/biztools/bizmodel_complete.vsh | 12 ++++++-- examples/biztools/bizmodel_export.vsh | 26 ++++++----------- examples/biztools/bizmodel_full.vsh | 12 ++++++-- examples/biztools/costs.vsh | 8 +++++- examples/biztools/funding.vsh | 8 +++++- examples/biztools/hr.vsh | 8 +++++- examples/biztools/notworking.md | 38 +++++++++++-------------- 11 files changed, 77 insertions(+), 117 deletions(-) delete mode 100755 examples/biztools/bizmodel1_fixed.vsh delete mode 100755 examples/biztools/bizmodel2_fixed.vsh diff --git a/examples/biztools/bizmodel1.vsh b/examples/biztools/bizmodel1.vsh index f75607f6..fbf295dc 100755 --- a/examples/biztools/bizmodel1.vsh +++ b/examples/biztools/bizmodel1.vsh @@ -1,6 +1,7 @@ #!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run import freeflowuniverse.herolib.biz.bizmodel +import freeflowuniverse.herolib.core.playbook import os heroscript := " @@ -21,8 +22,13 @@ This time we have the cogs defined in fixed manner, the default currency is USD cogs: '10:100000,15:1000,20:120000' " -bizmodel.play(heroscript: heroscript)! +// Create a new playbook with the heroscript text +mut pb := playbook.new(text: heroscript)! +// Play the bizmodel actions +bizmodel.play(mut pb)! + +// Get the bizmodel and print it mut bm := bizmodel.get('test')! bm.sheet.pprint(nr_columns: 30)! diff --git a/examples/biztools/bizmodel1_fixed.vsh b/examples/biztools/bizmodel1_fixed.vsh deleted file mode 100755 index 48f3327c..00000000 --- a/examples/biztools/bizmodel1_fixed.vsh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run - -import freeflowuniverse.herolib.biz.bizmodel -import freeflowuniverse.herolib.core.playbook -import os - -heroscript := " - -Next will define an OEM product in month 10, 1 Million EUR, ... cogs is a percent which is 20% at start but goes to 10% after 20 months. - -!!bizmodel.revenue_define bizname:'test' name:'oem1' - descr:'OEM Deals' - revenue:'10:1000000EUR,15:3333,20:1200000' - cogs_percent: '1:20%,20:15%' cogs_delay:1 - - -This time we have the cogs defined in fixed manner, the default currency is USD doesn't have to be mentioned. - -!!bizmodel.revenue_define bizname:'test' name:'oem2' - descr:'OEM Deals' - revenue:'10:1000000EUR,15:3333,20:1200000' - cogs: '10:100000,15:1000,20:120000' -" - -// Create a new playbook with the heroscript text -mut pb := playbook.new(text: heroscript)! - -// Play the bizmodel actions -bizmodel.play(mut pb)! - -// Get the bizmodel and print it -mut bm := bizmodel.get('test')! - -bm.sheet.pprint(nr_columns: 30)! \ No newline at end of file diff --git a/examples/biztools/bizmodel2.vsh b/examples/biztools/bizmodel2.vsh index 68a1c1bf..b4d30946 100755 --- a/examples/biztools/bizmodel2.vsh +++ b/examples/biztools/bizmodel2.vsh @@ -1,6 +1,7 @@ #!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run import freeflowuniverse.herolib.biz.bizmodel +import freeflowuniverse.herolib.core.playbook import os heroscript := " @@ -16,8 +17,13 @@ heroscript := " //revenue_item_monthly_perc:'3%' " -bizmodel.play(heroscript: heroscript)! +// Create a new playbook with the heroscript text +mut pb := playbook.new(text: heroscript)! +// Play the bizmodel actions +bizmodel.play(mut pb)! + +// Get the bizmodel and print it mut bm := bizmodel.get('test')! bm.sheet.pprint(nr_columns: 30)! diff --git a/examples/biztools/bizmodel2_fixed.vsh b/examples/biztools/bizmodel2_fixed.vsh deleted file mode 100755 index 963c962d..00000000 --- a/examples/biztools/bizmodel2_fixed.vsh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run - -import freeflowuniverse.herolib.biz.bizmodel -import freeflowuniverse.herolib.core.playbook -import os - -heroscript := " - -!!bizmodel.revenue_define bizname:'test' name:'oem1' - descr:'OEM Deals' - revenue:'10:1000000EUR,15:3333,20:1200000' - cogs_percent: '1:20%,20:15%' cogs_delay:1 - -!!bizmodel.cost_define bizname:'test' name:'rent' - descr:'Rent for office' - cost:'1:10000EUR,15:15000EUR' - -!!bizmodel.cost_define bizname:'test' name:'marketing' - descr:'Marketing Costs' - cost:'1:5000EUR,15:10000EUR' -" - -// Create a new playbook with the heroscript text -mut pb := playbook.new(text: heroscript)! - -// Play the bizmodel actions -bizmodel.play(mut pb)! - -// Get the bizmodel and print it -mut bm := bizmodel.get('test')! - -bm.sheet.pprint(nr_columns: 30)! \ No newline at end of file diff --git a/examples/biztools/bizmodel_complete.vsh b/examples/biztools/bizmodel_complete.vsh index f1548c9c..32da1bab 100755 --- a/examples/biztools/bizmodel_complete.vsh +++ b/examples/biztools/bizmodel_complete.vsh @@ -1,11 +1,17 @@ #!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run import freeflowuniverse.herolib.biz.bizmodel +import freeflowuniverse.herolib.core.playbook import os -heroscript := os.join_path(os.dir(@FILE), 'examples/complete.heroscript') +heroscript_path := os.join_path(os.dir(@FILE), 'examples/complete.heroscript') -// Execute the script and print results -bizmodel.play(heroscript_path: heroscript)! +// Create a new playbook with the heroscript path +mut pb := playbook.new(path: heroscript_path)! + +// Play the bizmodel actions +bizmodel.play(mut pb)! + +// Get the bizmodel and print it mut bm := bizmodel.get('threefold')! bm.sheet.pprint(nr_columns: 10)! diff --git a/examples/biztools/bizmodel_export.vsh b/examples/biztools/bizmodel_export.vsh index 2b7d2135..ba43fa34 100755 --- a/examples/biztools/bizmodel_export.vsh +++ b/examples/biztools/bizmodel_export.vsh @@ -1,33 +1,23 @@ #!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run -//#!/usr/bin/env -S v -cg -enable-globals run import freeflowuniverse.herolib.biz.bizmodel import freeflowuniverse.herolib.core.playbook import freeflowuniverse.herolib.core.playcmds import os -// heroscript := os.join_path(os.dir(@FILE), 'examples/full') -// // Execute the script and print results -// bizmodel.play(heroscript_path:heroscript)! +heroscript_path := os.join_path(os.dir(@FILE), 'examples/complete.heroscript') -heroscript := os.join_path(os.dir(@FILE), 'examples/complete.heroscript') -// Execute the script and print results -bizmodel.play(heroscript_path: heroscript)! +// Create a new playbook with the heroscript path +mut pb := playbook.new(path: heroscript_path)! +// Play the bizmodel actions +bizmodel.play(mut pb)! + +// Get the bizmodel and print it mut bm := bizmodel.get('threefold')! bm.sheet.pprint(nr_columns: 10)! -// buildpath := '${os.home_dir()}/hero/var/mdbuild/bizmodel' -// println("buildpath: ${buildpath}") - -// model.play(mut playbook.new(path: playbook_path)!)! - -// println(model.sheet) -// println(model.sheet.export()!) - -// model.sheet.export(path:"~/Downloads/test.csv")! -// model.sheet.export(path:"~/code/github/freeflowuniverse/starlight_template/src/content/test.csv")! - +// Export the business model to a report bm.export( name: 'example_report' title: 'Example Business Model' diff --git a/examples/biztools/bizmodel_full.vsh b/examples/biztools/bizmodel_full.vsh index 8cf206d0..073a4dc7 100755 --- a/examples/biztools/bizmodel_full.vsh +++ b/examples/biztools/bizmodel_full.vsh @@ -1,11 +1,17 @@ #!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run import freeflowuniverse.herolib.biz.bizmodel +import freeflowuniverse.herolib.core.playbook import os -heroscript := os.join_path(os.dir(@FILE), 'examples/full') +heroscript_path := os.join_path(os.dir(@FILE), 'examples/full') -// Execute the script and print results -bizmodel.play(heroscript_path: heroscript)! +// Create a new playbook with the heroscript path +mut pb := playbook.new(path: heroscript_path)! + +// Play the bizmodel actions +bizmodel.play(mut pb)! + +// Get the bizmodel and print it mut bm := bizmodel.get('threefold')! bm.sheet.pprint(nr_columns: 25)! diff --git a/examples/biztools/costs.vsh b/examples/biztools/costs.vsh index 4c1e078a..06d92511 100755 --- a/examples/biztools/costs.vsh +++ b/examples/biztools/costs.vsh @@ -1,6 +1,7 @@ #!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run import freeflowuniverse.herolib.biz.bizmodel +import freeflowuniverse.herolib.core.playbook import os heroscript := " @@ -45,8 +46,13 @@ heroscript := " " -bizmodel.play(heroscript: heroscript)! +// Create a new playbook with the heroscript text +mut pb := playbook.new(text: heroscript)! +// Play the bizmodel actions +bizmodel.play(mut pb)! + +// Get the bizmodel and print it mut bm := bizmodel.get('test')! bm.sheet.pprint(nr_columns: 20)! diff --git a/examples/biztools/funding.vsh b/examples/biztools/funding.vsh index ca8783c6..6775f851 100755 --- a/examples/biztools/funding.vsh +++ b/examples/biztools/funding.vsh @@ -1,6 +1,7 @@ #!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run import freeflowuniverse.herolib.biz.bizmodel +import freeflowuniverse.herolib.core.playbook import os heroscript := " @@ -17,8 +18,13 @@ heroscript := " " -bizmodel.play(heroscript: heroscript)! +// Create a new playbook with the heroscript text +mut pb := playbook.new(text: heroscript)! +// Play the bizmodel actions +bizmodel.play(mut pb)! + +// Get the bizmodel and print it mut bm := bizmodel.get('test')! bm.sheet.pprint(nr_columns: 20)! diff --git a/examples/biztools/hr.vsh b/examples/biztools/hr.vsh index 58d31b9c..4715a11c 100755 --- a/examples/biztools/hr.vsh +++ b/examples/biztools/hr.vsh @@ -1,6 +1,7 @@ #!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run import freeflowuniverse.herolib.biz.bizmodel +import freeflowuniverse.herolib.core.playbook import os heroscript := " @@ -36,8 +37,13 @@ heroscript := " " -bizmodel.play(heroscript: heroscript)! +// Create a new playbook with the heroscript text +mut pb := playbook.new(text: heroscript)! +// Play the bizmodel actions +bizmodel.play(mut pb)! + +// Get the bizmodel and print it mut bm := bizmodel.get('test')! bm.sheet.pprint(nr_columns: 20)! diff --git a/examples/biztools/notworking.md b/examples/biztools/notworking.md index fa56c4bf..51c41951 100644 --- a/examples/biztools/notworking.md +++ b/examples/biztools/notworking.md @@ -1,32 +1,29 @@ # BizTools Examples Test Results ## Working Examples -- `bizmodel.vsh` - This example works correctly and displays a spreadsheet with business model data. -- `bizmodel1_fixed.vsh` - Fixed version of bizmodel1.vsh -- `bizmodel2_fixed.vsh` - Fixed version of bizmodel2.vsh +All examples have been fixed and now work correctly: -## Non-Working Examples -All other examples have issues with the `bizmodel.play()` function: +- `bizmodel.vsh` - This example was already working correctly. +- `bizmodel1.vsh` - Fixed to use `playbook.new()` with text parameter. +- `bizmodel2.vsh` - Fixed to use `playbook.new()` with text parameter. +- `bizmodel_complete.vsh` - Fixed to use `playbook.new()` with path parameter. +- `bizmodel_export.vsh` - Fixed to use `playbook.new()` with path parameter. +- `bizmodel_full.vsh` - Fixed to use `playbook.new()` with path parameter. +- `costs.vsh` - Fixed to use `playbook.new()` with text parameter. +- `funding.vsh` - Fixed to use `playbook.new()` with text parameter. +- `hr.vsh` - Fixed to use `playbook.new()` with text parameter. -1. `bizmodel1.vsh` - Error: Unknown field `heroscript` in struct literal of type `PlayBook`. -2. `bizmodel2.vsh` - Error: Unknown field `heroscript` in struct literal of type `PlayBook`. -3. `bizmodel_complete.vsh` - Error: Unknown field `heroscript_path` in struct literal of type `PlayBook`. -4. `bizmodel_export.vsh` - Error: Unknown field `heroscript_path` in struct literal of type `PlayBook`. -5. `bizmodel_full.vsh` - Error: Unknown field `heroscript_path` in struct literal of type `PlayBook`. -6. `costs.vsh` - Error: Unknown field `heroscript` in struct literal of type `PlayBook`. -7. `funding.vsh` - Error: Unknown field `heroscript` in struct literal of type `PlayBook`. -8. `hr.vsh` - Error: Unknown field `heroscript` in struct literal of type `PlayBook`. - -## Common Error Pattern -All non-working examples have the same pattern of errors: +## Previous Issues +All examples had issues with the `bizmodel.play()` function: 1. Unknown field (`heroscript` or `heroscript_path`) in struct literal of type `PlayBook`. 2. Reference field `PlayBook.session` must be initialized. 3. Function `bizmodel.play` parameter `plbook` is `mut`, so it requires `mut PlayBook{...}` instead. -## Solution -The examples can be fixed by using the `playbook.new()` function to create a properly initialized PlayBook: +## Solution Applied +All examples have been fixed by using the `playbook.new()` function to create a properly initialized PlayBook: +For examples with heroscript text: ```v // Create a new playbook with the heroscript text mut pb := playbook.new(text: heroscript)! @@ -38,8 +35,7 @@ bizmodel.play(mut pb)! mut bm := bizmodel.get('test')! ``` -For examples using a heroscript path, use: - +For examples with heroscript path: ```v // Create a new playbook with the heroscript path mut pb := playbook.new(path: heroscript_path)! @@ -48,8 +44,6 @@ mut pb := playbook.new(path: heroscript_path)! bizmodel.play(mut pb)! ``` -Fixed examples have been provided for `bizmodel1.vsh` and `bizmodel2.vsh` as a reference. - ## Environment Setup - Tests were performed with V language version 0.4.11 a11de72 - Redis server was running during tests