feat: add string utility functions and decision condition tests

- Add cut_to_file() and cut_space() utility functions for file processing and field extraction
- Add comprehensive E2E tests for decision condition routing with function/command execution
- Add test workflows for decision conditions and inline decision execution
- Add short-mode skip guards to all cloud E2E tests to allow quick test runs
- Register new functions in constants and goja runtime
This commit is contained in:
j3ssie
2026-02-17 17:00:43 +07:00
parent 8d413aecb9
commit fba43ba3b5
15 changed files with 1639 additions and 34 deletions
+22
View File
@@ -267,6 +267,28 @@ func (vf *vmFunc) cutWithDelim(call goja.FunctionCall) goja.Value {
return vf.vm.ToValue(parts[idx])
}
// cutSpace extracts a field from input split by whitespace (1-indexed)
// Uses strings.Fields() which handles multiple spaces, tabs, and mixed whitespace
// Usage: cut_space(input, field) -> string
func (vf *vmFunc) cutSpace(call goja.FunctionCall) goja.Value {
input := call.Argument(0).String()
field := call.Argument(1).ToInteger()
if input == "undefined" {
return vf.vm.ToValue("")
}
parts := strings.Fields(input)
// Field is 1-indexed (like cut command)
idx := int(field) - 1
if idx < 0 || idx >= len(parts) {
return vf.vm.ToValue("")
}
return vf.vm.ToValue(parts[idx])
}
// normalizePath replaces special characters with underscore for clean directory/file names
// Replaces: / | : \ * ? " < > with _
// Usage: normalize_path(input) -> string