...
This commit is contained in:
@@ -37,7 +37,7 @@ import json
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// // Execute the MCP server with the request
|
// // Execute the MCP server with the request
|
||||||
// cmd := 'cat /tmp/mcp_request.txt | v run /Users/despiegk/code/github/freeflowuniverse/herolib/lib/mcp/v_do/main.v'
|
// cmd := 'cat /tmp/mcp_request.txt | v run /Users/despiegk/code/github/incubaid/herolib/lib/mcp/v_do/main.v'
|
||||||
// result := os.execute(cmd)
|
// result := os.execute(cmd)
|
||||||
|
|
||||||
// if result.exit_code != 0 {
|
// if result.exit_code != 0 {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import log
|
|||||||
|
|
||||||
fn get_module_dir(mod string) string {
|
fn get_module_dir(mod string) string {
|
||||||
module_parts := mod.trim_string_left('freeflowuniverse.herolib').split('.')
|
module_parts := mod.trim_string_left('freeflowuniverse.herolib').split('.')
|
||||||
return '${os.home_dir()}/code/github/freeflowuniverse/herolib/lib/${module_parts.join('/')}'
|
return '${os.home_dir()}/code/github/incubaid/herolib/lib/${module_parts.join('/')}'
|
||||||
}
|
}
|
||||||
|
|
||||||
// given a module path and a type name, returns the type definition of that type within that module
|
// given a module path and a type name, returns the type definition of that type within that module
|
||||||
|
|||||||
@@ -92,10 +92,10 @@ pub fn (mut node Node) hero_update(args_ HeroUpdateArgs) ! {
|
|||||||
|
|
||||||
if args.sync_from_local {
|
if args.sync_from_local {
|
||||||
if args.sync_full {
|
if args.sync_full {
|
||||||
node.sync_code('hero', heropath_ + '/..', '~/code/github/freeflowuniverse/herolib',
|
node.sync_code('hero', heropath_ + '/..', '~/code/github/incubaid/herolib',
|
||||||
args.sync_fast)!
|
args.sync_fast)!
|
||||||
} else {
|
} else {
|
||||||
node.sync_code('hero_lib', heropath_, '~/code/github/freeflowuniverse/herolib/herolib',
|
node.sync_code('hero_lib', heropath_, '~/code/github/incubaid/herolib/herolib',
|
||||||
args.sync_fast)!
|
args.sync_fast)!
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -108,7 +108,7 @@ pub fn (mut node Node) hero_update(args_ HeroUpdateArgs) ! {
|
|||||||
args.git_pull = false
|
args.git_pull = false
|
||||||
node.exec_cmd(
|
node.exec_cmd(
|
||||||
cmd: '
|
cmd: '
|
||||||
cd ~/code/github/freeflowuniverse/herolib
|
cd ~/code/github/incubaid/herolib
|
||||||
rm -f .git/index
|
rm -f .git/index
|
||||||
git fetch --all
|
git fetch --all
|
||||||
git reset HEAD --hard
|
git reset HEAD --hard
|
||||||
@@ -121,7 +121,7 @@ pub fn (mut node Node) hero_update(args_ HeroUpdateArgs) ! {
|
|||||||
if args.git_pull {
|
if args.git_pull {
|
||||||
node.exec_cmd(
|
node.exec_cmd(
|
||||||
cmd: '
|
cmd: '
|
||||||
cd ~/code/github/freeflowuniverse/herolib
|
cd ~/code/github/incubaid/herolib
|
||||||
git pull
|
git pull
|
||||||
${branchstr}
|
${branchstr}
|
||||||
'
|
'
|
||||||
@@ -147,25 +147,25 @@ pub fn (mut node Node) sync_code(name string, src_ string, dest string, fast_rsy
|
|||||||
|
|
||||||
// sync local hero code to rmote and then compile hero
|
// sync local hero code to rmote and then compile hero
|
||||||
pub fn (mut node Node) hero_compile_sync() ! {
|
pub fn (mut node Node) hero_compile_sync() ! {
|
||||||
if !node.file_exists('~/code/github/freeflowuniverse/herolib/cli/readme.md') {
|
if !node.file_exists('~/code/github/incubaid/herolib/cli/readme.md') {
|
||||||
node.hero_install()!
|
node.hero_install()!
|
||||||
}
|
}
|
||||||
node.hero_update()!
|
node.hero_update()!
|
||||||
node.exec_cmd(
|
node.exec_cmd(
|
||||||
cmd: '
|
cmd: '
|
||||||
~/code/github/freeflowuniverse/herolib/install.sh
|
~/code/github/incubaid/herolib/install.sh
|
||||||
~/code/github/freeflowuniverse/herolib/cli/hero/compile_debug.sh
|
~/code/github/incubaid/herolib/cli/hero/compile_debug.sh
|
||||||
'
|
'
|
||||||
)!
|
)!
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut node Node) hero_compile() ! {
|
pub fn (mut node Node) hero_compile() ! {
|
||||||
if !node.file_exists('~/code/github/freeflowuniverse/herolib/cli/readme.md') {
|
if !node.file_exists('~/code/github/incubaid/herolib/cli/readme.md') {
|
||||||
node.hero_install()!
|
node.hero_install()!
|
||||||
}
|
}
|
||||||
node.exec_cmd(
|
node.exec_cmd(
|
||||||
cmd: '
|
cmd: '
|
||||||
~/code/github/freeflowuniverse/herolib/cli/hero/compile_debug.sh
|
~/code/github/incubaid/herolib/cli/hero/compile_debug.sh
|
||||||
'
|
'
|
||||||
)!
|
)!
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module utils
|
module codetools
|
||||||
|
|
||||||
// Helper function to extract code blocks from the response
|
// Helper function to extract code blocks from the response
|
||||||
pub fn extract_code_block(response string, identifier string, language string) string {
|
pub fn extract_code_block(response string, identifier string, language string) string {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module code
|
module codetools
|
||||||
|
|
||||||
import freeflowuniverse.herolib.ui.console
|
import freeflowuniverse.herolib.ui.console
|
||||||
import os
|
import os
|
||||||
@@ -31,7 +31,7 @@ pub fn list_v_files(dir string) ![]string {
|
|||||||
// string - absolute path to the module directory
|
// string - absolute path to the module directory
|
||||||
pub fn get_module_dir(mod string) string {
|
pub fn get_module_dir(mod string) string {
|
||||||
module_parts := mod.trim_string_left('freeflowuniverse.herolib').split('.')
|
module_parts := mod.trim_string_left('freeflowuniverse.herolib').split('.')
|
||||||
return '${os.home_dir()}/code/github/freeflowuniverse/herolib/lib/${module_parts.join('/')}'
|
return '${os.home_dir()}/code/github/incubaid/herolib/lib/${module_parts.join('/')}'
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== CODE PARSING UTILITIES =====
|
// ===== CODE PARSING UTILITIES =====
|
||||||
@@ -191,79 +191,3 @@ pub fn get_type_from_module(module_path string, type_name string) !string {
|
|||||||
|
|
||||||
return error('type ${type_name} not found in module ${module_path}')
|
return error('type ${type_name} not found in module ${module_path}')
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== V LANGUAGE TOOLS =====
|
|
||||||
|
|
||||||
// vtest runs v test on the specified file or directory
|
|
||||||
// ARGS:
|
|
||||||
// fullpath string - path to the file or directory to test
|
|
||||||
// RETURNS:
|
|
||||||
// string - test results output, or error if test fails
|
|
||||||
pub fn vtest(fullpath string) !string {
|
|
||||||
console.print_item('test ${fullpath}')
|
|
||||||
if !os.exists(fullpath) {
|
|
||||||
return error('File or directory does not exist: ${fullpath}')
|
|
||||||
}
|
|
||||||
if os.is_dir(fullpath) {
|
|
||||||
mut results := ''
|
|
||||||
for item in list_v_files(fullpath)! {
|
|
||||||
results += vtest(item)!
|
|
||||||
results += '\n-----------------------\n'
|
|
||||||
}
|
|
||||||
return results
|
|
||||||
} else {
|
|
||||||
cmd := 'v -gc none -stats -enable-globals -show-c-output -keepc -n -w -cg -o /tmp/tester.c -g -cc tcc test ${fullpath}'
|
|
||||||
console.print_debug('Executing command: ${cmd}')
|
|
||||||
result := os.execute(cmd)
|
|
||||||
if result.exit_code != 0 {
|
|
||||||
return error('Test failed for ${fullpath} with exit code ${result.exit_code}\n${result.output}')
|
|
||||||
} else {
|
|
||||||
console.print_item('Test completed for ${fullpath}')
|
|
||||||
}
|
|
||||||
return 'Command: ${cmd}\nExit code: ${result.exit_code}\nOutput:\n${result.output}'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// vet_file runs v vet on a single file
|
|
||||||
// ARGS:
|
|
||||||
// file string - path to the file to vet
|
|
||||||
// RETURNS:
|
|
||||||
// string - vet results output, or error if vet fails
|
|
||||||
fn vet_file(file string) !string {
|
|
||||||
cmd := 'v vet -v -w ${file}'
|
|
||||||
console.print_debug('Executing command: ${cmd}')
|
|
||||||
result := os.execute(cmd)
|
|
||||||
if result.exit_code != 0 {
|
|
||||||
return error('Vet failed for ${file} with exit code ${result.exit_code}\n${result.output}')
|
|
||||||
} else {
|
|
||||||
console.print_item('Vet completed for ${file}')
|
|
||||||
}
|
|
||||||
return 'Command: ${cmd}\nExit code: ${result.exit_code}\nOutput:\n${result.output}'
|
|
||||||
}
|
|
||||||
|
|
||||||
// vvet runs v vet on the specified file or directory
|
|
||||||
// ARGS:
|
|
||||||
// fullpath string - path to the file or directory to vet
|
|
||||||
// RETURNS:
|
|
||||||
// string - vet results output, or error if vet fails
|
|
||||||
pub fn vvet(fullpath string) !string {
|
|
||||||
console.print_item('vet ${fullpath}')
|
|
||||||
if !os.exists(fullpath) {
|
|
||||||
return error('File or directory does not exist: ${fullpath}')
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.is_dir(fullpath) {
|
|
||||||
mut results := ''
|
|
||||||
files := list_v_files(fullpath) or { return error('Error listing V files: ${err}') }
|
|
||||||
for file in files {
|
|
||||||
results += vet_file(file) or {
|
|
||||||
console.print_stderr('Failed to vet ${file}: ${err}')
|
|
||||||
return error('Failed to vet ${file}: ${err}')
|
|
||||||
}
|
|
||||||
results += '\n-----------------------\n'
|
|
||||||
}
|
|
||||||
return results
|
|
||||||
} else {
|
|
||||||
return vet_file(fullpath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user