zrb 1.8.10__py3-none-any.whl → 1.21.29__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of zrb might be problematic. Click here for more details.

Files changed (147) hide show
  1. zrb/__init__.py +126 -113
  2. zrb/__main__.py +1 -1
  3. zrb/attr/type.py +10 -7
  4. zrb/builtin/__init__.py +2 -50
  5. zrb/builtin/git.py +12 -1
  6. zrb/builtin/group.py +31 -15
  7. zrb/builtin/http.py +7 -8
  8. zrb/builtin/llm/attachment.py +40 -0
  9. zrb/builtin/llm/chat_completion.py +274 -0
  10. zrb/builtin/llm/chat_session.py +152 -85
  11. zrb/builtin/llm/chat_session_cmd.py +288 -0
  12. zrb/builtin/llm/chat_trigger.py +79 -0
  13. zrb/builtin/llm/history.py +7 -9
  14. zrb/builtin/llm/llm_ask.py +221 -98
  15. zrb/builtin/llm/tool/api.py +74 -52
  16. zrb/builtin/llm/tool/cli.py +46 -17
  17. zrb/builtin/llm/tool/code.py +71 -90
  18. zrb/builtin/llm/tool/file.py +301 -241
  19. zrb/builtin/llm/tool/note.py +84 -0
  20. zrb/builtin/llm/tool/rag.py +38 -8
  21. zrb/builtin/llm/tool/sub_agent.py +67 -50
  22. zrb/builtin/llm/tool/web.py +146 -122
  23. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/add_entity_util.py +7 -7
  24. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/add_module_util.py +5 -5
  25. zrb/builtin/project/add/fastapp/fastapp_util.py +1 -1
  26. zrb/builtin/searxng/config/settings.yml +5671 -0
  27. zrb/builtin/searxng/start.py +21 -0
  28. zrb/builtin/setup/latex/ubuntu.py +1 -0
  29. zrb/builtin/setup/ubuntu.py +1 -1
  30. zrb/builtin/shell/autocomplete/bash.py +4 -3
  31. zrb/builtin/shell/autocomplete/zsh.py +4 -3
  32. zrb/builtin/todo.py +13 -2
  33. zrb/config/config.py +614 -0
  34. zrb/config/default_prompt/file_extractor_system_prompt.md +112 -0
  35. zrb/config/default_prompt/interactive_system_prompt.md +29 -0
  36. zrb/config/default_prompt/persona.md +1 -0
  37. zrb/config/default_prompt/repo_extractor_system_prompt.md +112 -0
  38. zrb/config/default_prompt/repo_summarizer_system_prompt.md +29 -0
  39. zrb/config/default_prompt/summarization_prompt.md +57 -0
  40. zrb/config/default_prompt/system_prompt.md +38 -0
  41. zrb/config/llm_config.py +339 -0
  42. zrb/config/llm_context/config.py +166 -0
  43. zrb/config/llm_context/config_parser.py +40 -0
  44. zrb/config/llm_context/workflow.py +81 -0
  45. zrb/config/llm_rate_limitter.py +190 -0
  46. zrb/{runner → config}/web_auth_config.py +17 -22
  47. zrb/context/any_shared_context.py +17 -1
  48. zrb/context/context.py +16 -2
  49. zrb/context/shared_context.py +18 -8
  50. zrb/group/any_group.py +12 -5
  51. zrb/group/group.py +67 -3
  52. zrb/input/any_input.py +5 -1
  53. zrb/input/base_input.py +18 -6
  54. zrb/input/option_input.py +13 -1
  55. zrb/input/text_input.py +8 -25
  56. zrb/runner/cli.py +25 -23
  57. zrb/runner/common_util.py +24 -19
  58. zrb/runner/web_app.py +3 -3
  59. zrb/runner/web_route/docs_route.py +1 -1
  60. zrb/runner/web_route/error_page/serve_default_404.py +1 -1
  61. zrb/runner/web_route/error_page/show_error_page.py +1 -1
  62. zrb/runner/web_route/home_page/home_page_route.py +2 -2
  63. zrb/runner/web_route/login_api_route.py +1 -1
  64. zrb/runner/web_route/login_page/login_page_route.py +2 -2
  65. zrb/runner/web_route/logout_api_route.py +1 -1
  66. zrb/runner/web_route/logout_page/logout_page_route.py +2 -2
  67. zrb/runner/web_route/node_page/group/show_group_page.py +1 -1
  68. zrb/runner/web_route/node_page/node_page_route.py +1 -1
  69. zrb/runner/web_route/node_page/task/show_task_page.py +1 -1
  70. zrb/runner/web_route/refresh_token_api_route.py +1 -1
  71. zrb/runner/web_route/static/static_route.py +1 -1
  72. zrb/runner/web_route/task_input_api_route.py +6 -6
  73. zrb/runner/web_route/task_session_api_route.py +20 -12
  74. zrb/runner/web_util/cookie.py +1 -1
  75. zrb/runner/web_util/token.py +1 -1
  76. zrb/runner/web_util/user.py +8 -4
  77. zrb/session/any_session.py +24 -17
  78. zrb/session/session.py +50 -25
  79. zrb/session_state_logger/any_session_state_logger.py +9 -4
  80. zrb/session_state_logger/file_session_state_logger.py +16 -6
  81. zrb/session_state_logger/session_state_logger_factory.py +1 -1
  82. zrb/task/any_task.py +30 -9
  83. zrb/task/base/context.py +17 -9
  84. zrb/task/base/execution.py +15 -8
  85. zrb/task/base/lifecycle.py +8 -4
  86. zrb/task/base/monitoring.py +12 -7
  87. zrb/task/base_task.py +69 -5
  88. zrb/task/base_trigger.py +12 -5
  89. zrb/task/cmd_task.py +1 -1
  90. zrb/task/llm/agent.py +154 -161
  91. zrb/task/llm/agent_runner.py +152 -0
  92. zrb/task/llm/config.py +47 -18
  93. zrb/task/llm/conversation_history.py +209 -0
  94. zrb/task/llm/conversation_history_model.py +67 -0
  95. zrb/task/llm/default_workflow/coding/workflow.md +41 -0
  96. zrb/task/llm/default_workflow/copywriting/workflow.md +68 -0
  97. zrb/task/llm/default_workflow/git/workflow.md +118 -0
  98. zrb/task/llm/default_workflow/golang/workflow.md +128 -0
  99. zrb/task/llm/default_workflow/html-css/workflow.md +135 -0
  100. zrb/task/llm/default_workflow/java/workflow.md +146 -0
  101. zrb/task/llm/default_workflow/javascript/workflow.md +158 -0
  102. zrb/task/llm/default_workflow/python/workflow.md +160 -0
  103. zrb/task/llm/default_workflow/researching/workflow.md +153 -0
  104. zrb/task/llm/default_workflow/rust/workflow.md +162 -0
  105. zrb/task/llm/default_workflow/shell/workflow.md +299 -0
  106. zrb/task/llm/error.py +24 -10
  107. zrb/task/llm/file_replacement.py +206 -0
  108. zrb/task/llm/file_tool_model.py +57 -0
  109. zrb/task/llm/history_processor.py +206 -0
  110. zrb/task/llm/history_summarization.py +11 -166
  111. zrb/task/llm/print_node.py +193 -69
  112. zrb/task/llm/prompt.py +242 -45
  113. zrb/task/llm/subagent_conversation_history.py +41 -0
  114. zrb/task/llm/tool_wrapper.py +260 -57
  115. zrb/task/llm/workflow.py +76 -0
  116. zrb/task/llm_task.py +182 -171
  117. zrb/task/make_task.py +2 -3
  118. zrb/task/rsync_task.py +26 -11
  119. zrb/task/scheduler.py +4 -4
  120. zrb/util/attr.py +54 -39
  121. zrb/util/callable.py +23 -0
  122. zrb/util/cli/markdown.py +12 -0
  123. zrb/util/cli/text.py +30 -0
  124. zrb/util/file.py +29 -11
  125. zrb/util/git.py +8 -11
  126. zrb/util/git_diff_model.py +10 -0
  127. zrb/util/git_subtree.py +9 -14
  128. zrb/util/git_subtree_model.py +32 -0
  129. zrb/util/init_path.py +1 -1
  130. zrb/util/markdown.py +62 -0
  131. zrb/util/string/conversion.py +2 -2
  132. zrb/util/todo.py +17 -50
  133. zrb/util/todo_model.py +46 -0
  134. zrb/util/truncate.py +23 -0
  135. zrb/util/yaml.py +204 -0
  136. zrb/xcom/xcom.py +10 -0
  137. zrb-1.21.29.dist-info/METADATA +270 -0
  138. {zrb-1.8.10.dist-info → zrb-1.21.29.dist-info}/RECORD +140 -98
  139. {zrb-1.8.10.dist-info → zrb-1.21.29.dist-info}/WHEEL +1 -1
  140. zrb/config.py +0 -335
  141. zrb/llm_config.py +0 -411
  142. zrb/llm_rate_limitter.py +0 -125
  143. zrb/task/llm/context.py +0 -102
  144. zrb/task/llm/context_enrichment.py +0 -199
  145. zrb/task/llm/history.py +0 -211
  146. zrb-1.8.10.dist-info/METADATA +0 -264
  147. {zrb-1.8.10.dist-info → zrb-1.21.29.dist-info}/entry_points.txt +0 -0
zrb/__init__.py CHANGED
@@ -1,117 +1,130 @@
1
- from zrb.attr.type import (
2
- AnyAttr,
3
- BoolAttr,
4
- FloatAttr,
5
- IntAttr,
6
- StrAttr,
7
- StrDictAttr,
8
- fstring,
9
- )
10
- from zrb.callback.any_callback import AnyCallback
11
- from zrb.callback.callback import Callback
12
- from zrb.cmd.cmd_result import CmdResult
13
- from zrb.cmd.cmd_val import Cmd, CmdPath
14
- from zrb.config import CFG
15
- from zrb.content_transformer.any_content_transformer import AnyContentTransformer
16
- from zrb.content_transformer.content_transformer import ContentTransformer
17
- from zrb.context.any_context import AnyContext
18
- from zrb.context.any_shared_context import AnySharedContext
19
- from zrb.context.context import Context
20
- from zrb.context.shared_context import SharedContext
21
- from zrb.env.any_env import AnyEnv
22
- from zrb.env.env import Env
23
- from zrb.env.env_file import EnvFile
24
- from zrb.env.env_map import EnvMap
25
- from zrb.group.any_group import AnyGroup
26
- from zrb.group.group import Group
27
- from zrb.input.any_input import AnyInput
28
- from zrb.input.base_input import BaseInput
29
- from zrb.input.bool_input import BoolInput
30
- from zrb.input.float_input import FloatInput
31
- from zrb.input.int_input import IntInput
32
- from zrb.input.option_input import OptionInput
33
- from zrb.input.password_input import PasswordInput
34
- from zrb.input.str_input import StrInput
35
- from zrb.input.text_input import TextInput
36
- from zrb.llm_config import llm_config
37
- from zrb.llm_rate_limitter import llm_rate_limitter
38
- from zrb.runner.cli import cli
39
- from zrb.runner.web_auth_config import web_auth_config
40
- from zrb.runner.web_schema.user import User
41
- from zrb.session.session import Session
42
- from zrb.task.any_task import AnyTask
43
- from zrb.task.base_task import BaseTask
44
- from zrb.task.base_trigger import BaseTrigger
45
- from zrb.task.cmd_task import CmdTask
46
- from zrb.task.http_check import HttpCheck
47
- from zrb.task.llm.history import ConversationHistoryData
48
- from zrb.task.llm_task import LLMTask
49
- from zrb.task.make_task import make_task
50
- from zrb.task.rsync_task import RsyncTask
51
- from zrb.task.scaffolder import Scaffolder
52
- from zrb.task.scheduler import Scheduler
53
- from zrb.task.task import Task
54
- from zrb.task.tcp_check import TcpCheck
55
- from zrb.util.load import load_file, load_module
56
- from zrb.xcom.xcom import Xcom
1
+ import importlib
2
+ from typing import TYPE_CHECKING, Any
57
3
 
58
- assert load_file
59
- assert load_module
60
- assert fstring
61
- assert AnyAttr
62
- assert BoolAttr
63
- assert IntAttr
64
- assert FloatAttr
65
- assert StrAttr
66
- assert StrDictAttr
67
- assert AnyCallback
68
- assert Callback
69
- assert AnyEnv
70
- assert Env
71
- assert EnvFile
72
- assert EnvMap
73
- assert AnyInput
74
- assert BaseInput
75
- assert BoolInput
76
- assert Cmd
77
- assert CmdPath
78
- assert CmdResult
79
- assert CmdTask
80
- assert HttpCheck
81
- assert TcpCheck
82
- assert FloatInput
83
- assert IntInput
84
- assert OptionInput
85
- assert PasswordInput
86
- assert StrInput
87
- assert TextInput
88
- assert AnyGroup
89
- assert Group
90
- assert AnyTask
91
- assert BaseTask
92
- assert BaseTrigger
93
- assert RsyncTask
94
- assert Task
95
- assert LLMTask
96
- assert ConversationHistoryData
97
- assert Session
98
- assert AnyContext
99
- assert Context
100
- assert AnySharedContext
101
- assert SharedContext
102
- assert make_task
103
- assert AnyContentTransformer
104
- assert ContentTransformer
105
- assert Scaffolder
106
- assert Scheduler
107
- assert cli
108
- assert llm_config
109
- assert llm_rate_limitter
110
- assert Xcom
111
- assert web_auth_config
112
- assert User
4
+ _LAZY_LOAD = {
5
+ "AnyAttr": "zrb.attr.type",
6
+ "BoolAttr": "zrb.attr.type",
7
+ "FloatAttr": "zrb.attr.type",
8
+ "IntAttr": "zrb.attr.type",
9
+ "StrAttr": "zrb.attr.type",
10
+ "StrDictAttr": "zrb.attr.type",
11
+ "fstring": "zrb.attr.type",
12
+ "AnyCallback": "zrb.callback.any_callback",
13
+ "Callback": "zrb.callback.callback",
14
+ "CmdResult": "zrb.cmd.cmd_result",
15
+ "Cmd": "zrb.cmd.cmd_val",
16
+ "CmdPath": "zrb.cmd.cmd_val",
17
+ "CFG": "zrb.config.config",
18
+ "AnyContentTransformer": "zrb.content_transformer.any_content_transformer",
19
+ "ContentTransformer": "zrb.content_transformer.content_transformer",
20
+ "AnyContext": "zrb.context.any_context",
21
+ "AnySharedContext": "zrb.context.any_shared_context",
22
+ "Context": "zrb.context.context",
23
+ "SharedContext": "zrb.context.shared_context",
24
+ "AnyEnv": "zrb.env.any_env",
25
+ "Env": "zrb.env.env",
26
+ "EnvFile": "zrb.env.env_file",
27
+ "EnvMap": "zrb.env.env_map",
28
+ "AnyGroup": "zrb.group.any_group",
29
+ "Group": "zrb.group.group",
30
+ "AnyInput": "zrb.input.any_input",
31
+ "BaseInput": "zrb.input.base_input",
32
+ "BoolInput": "zrb.input.bool_input",
33
+ "FloatInput": "zrb.input.float_input",
34
+ "IntInput": "zrb.input.int_input",
35
+ "OptionInput": "zrb.input.option_input",
36
+ "PasswordInput": "zrb.input.password_input",
37
+ "StrInput": "zrb.input.str_input",
38
+ "TextInput": "zrb.input.text_input",
39
+ "llm_config": "zrb.config.llm_config",
40
+ "llm_rate_limitter": "zrb.config.llm_rate_limitter",
41
+ "cli": "zrb.runner.cli",
42
+ "web_auth_config": "zrb.config.web_auth_config",
43
+ "User": "zrb.runner.web_schema.user",
44
+ "Session": "zrb.session.session",
45
+ "AnyTask": "zrb.task.any_task",
46
+ "BaseTask": "zrb.task.base_task",
47
+ "BaseTrigger": "zrb.task.base_trigger",
48
+ "CmdTask": "zrb.task.cmd_task",
49
+ "HttpCheck": "zrb.task.http_check",
50
+ "ConversationHistory": "zrb.task.llm.conversation_history",
51
+ "LLMTask": "zrb.task.llm_task",
52
+ "make_task": "zrb.task.make_task",
53
+ "RsyncTask": "zrb.task.rsync_task",
54
+ "Scaffolder": "zrb.task.scaffolder",
55
+ "Scheduler": "zrb.task.scheduler",
56
+ "Task": "zrb.task.task",
57
+ "TcpCheck": "zrb.task.tcp_check",
58
+ "load_file": "zrb.util.load",
59
+ "load_module": "zrb.util.load",
60
+ "Xcom": "zrb.xcom.xcom",
61
+ }
113
62
 
114
- if CFG.LOAD_BUILTIN:
63
+ if TYPE_CHECKING:
115
64
  from zrb import builtin
65
+ from zrb.attr.type import (
66
+ AnyAttr,
67
+ BoolAttr,
68
+ FloatAttr,
69
+ IntAttr,
70
+ StrAttr,
71
+ StrDictAttr,
72
+ fstring,
73
+ )
74
+ from zrb.callback.any_callback import AnyCallback
75
+ from zrb.callback.callback import Callback
76
+ from zrb.cmd.cmd_result import CmdResult
77
+ from zrb.cmd.cmd_val import Cmd, CmdPath
78
+ from zrb.config.config import CFG
79
+ from zrb.config.llm_config import llm_config
80
+ from zrb.config.llm_rate_limitter import llm_rate_limitter
81
+ from zrb.config.web_auth_config import web_auth_config
82
+ from zrb.content_transformer.any_content_transformer import AnyContentTransformer
83
+ from zrb.content_transformer.content_transformer import ContentTransformer
84
+ from zrb.context.any_context import AnyContext
85
+ from zrb.context.any_shared_context import AnySharedContext
86
+ from zrb.context.context import Context
87
+ from zrb.context.shared_context import SharedContext
88
+ from zrb.env.any_env import AnyEnv
89
+ from zrb.env.env import Env
90
+ from zrb.env.env_file import EnvFile
91
+ from zrb.env.env_map import EnvMap
92
+ from zrb.group.any_group import AnyGroup
93
+ from zrb.group.group import Group
94
+ from zrb.input.any_input import AnyInput
95
+ from zrb.input.base_input import BaseInput
96
+ from zrb.input.bool_input import BoolInput
97
+ from zrb.input.float_input import FloatInput
98
+ from zrb.input.int_input import IntInput
99
+ from zrb.input.option_input import OptionInput
100
+ from zrb.input.password_input import PasswordInput
101
+ from zrb.input.str_input import StrInput
102
+ from zrb.input.text_input import TextInput
103
+ from zrb.runner.cli import cli
104
+ from zrb.runner.web_schema.user import User
105
+ from zrb.session.session import Session
106
+ from zrb.task.any_task import AnyTask
107
+ from zrb.task.base_task import BaseTask
108
+ from zrb.task.base_trigger import BaseTrigger
109
+ from zrb.task.cmd_task import CmdTask
110
+ from zrb.task.http_check import HttpCheck
111
+ from zrb.task.llm.conversation_history import ConversationHistory
112
+ from zrb.task.llm_task import LLMTask
113
+ from zrb.task.make_task import make_task
114
+ from zrb.task.rsync_task import RsyncTask
115
+ from zrb.task.scaffolder import Scaffolder
116
+ from zrb.task.scheduler import Scheduler
117
+ from zrb.task.task import Task
118
+ from zrb.task.tcp_check import TcpCheck
119
+ from zrb.util.load import load_file, load_module
120
+ from zrb.xcom.xcom import Xcom
116
121
 
117
- assert builtin
122
+
123
+ def __getattr__(name: str) -> Any:
124
+ if name in _LAZY_LOAD:
125
+ module = importlib.import_module(_LAZY_LOAD[name])
126
+ return getattr(module, name)
127
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
128
+
129
+
130
+ from zrb import builtin
zrb/__main__.py CHANGED
@@ -2,7 +2,7 @@ import logging
2
2
  import os
3
3
  import sys
4
4
 
5
- from zrb.config import CFG
5
+ from zrb.config.config import CFG
6
6
  from zrb.runner.cli import cli
7
7
  from zrb.util.cli.style import stylize_error, stylize_faint, stylize_warning
8
8
  from zrb.util.group import NodeNotFoundError
zrb/attr/type.py CHANGED
@@ -1,12 +1,15 @@
1
1
  from typing import Any, Callable
2
2
 
3
+ from zrb.context.any_context import AnyContext
3
4
  from zrb.context.any_shared_context import AnySharedContext
4
5
 
5
6
  fstring = str
6
- AnyAttr = Any | fstring | Callable[[AnySharedContext], Any]
7
- StrAttr = str | fstring | Callable[[AnySharedContext], str]
8
- BoolAttr = bool | fstring | Callable[[AnySharedContext], bool]
9
- IntAttr = int | fstring | Callable[[AnySharedContext], int]
10
- FloatAttr = float | fstring | Callable[[AnySharedContext], float]
11
- StrDictAttr = dict[str, StrAttr] | Callable[[AnySharedContext], dict[str, Any]]
12
- StrListAttr = list[StrAttr] | Callable[[AnySharedContext], list[str]]
7
+ AnyAttr = Any | fstring | Callable[[AnyContext | AnySharedContext], Any]
8
+ StrAttr = str | fstring | Callable[[AnyContext | AnySharedContext], str | None]
9
+ BoolAttr = bool | fstring | Callable[[AnyContext | AnySharedContext], bool | None]
10
+ IntAttr = int | fstring | Callable[[AnyContext | AnySharedContext], int | None]
11
+ FloatAttr = float | fstring | Callable[[AnyContext | AnySharedContext], float | None]
12
+ StrDictAttr = (
13
+ dict[str, StrAttr] | Callable[[AnyContext | AnySharedContext], dict[str, Any]]
14
+ )
15
+ StrListAttr = list[StrAttr] | Callable[[AnyContext | AnySharedContext], list[str]]
zrb/builtin/__init__.py CHANGED
@@ -9,12 +9,14 @@ from zrb.builtin.git import (
9
9
  from zrb.builtin.git_subtree import git_add_subtree, git_pull_subtree, git_push_subtree
10
10
  from zrb.builtin.http import generate_curl, http_request
11
11
  from zrb.builtin.jwt import decode_jwt, encode_jwt, validate_jwt
12
+ from zrb.builtin.llm.chat_trigger import llm_chat_trigger
12
13
  from zrb.builtin.llm.llm_ask import llm_ask
13
14
  from zrb.builtin.md5 import hash_md5, sum_md5, validate_md5
14
15
  from zrb.builtin.project.add.fastapp.fastapp_task import add_fastapp_to_project
15
16
  from zrb.builtin.project.create.project_task import create_project
16
17
  from zrb.builtin.python import format_python_code
17
18
  from zrb.builtin.random import shuffle_values, throw_dice
19
+ from zrb.builtin.searxng.start import start_searxng
18
20
  from zrb.builtin.setup.asdf.asdf import setup_asdf
19
21
  from zrb.builtin.setup.latex.ubuntu import setup_latex_on_ubuntu
20
22
  from zrb.builtin.setup.tmux.tmux import setup_tmux
@@ -43,53 +45,3 @@ from zrb.builtin.uuid import (
43
45
  validate_uuid_v4,
44
46
  validate_uuid_v5,
45
47
  )
46
-
47
- assert create_project
48
- assert add_fastapp_to_project
49
- assert get_shell_subcommands
50
- assert make_bash_autocomplete
51
- assert make_zsh_autocomplete
52
- assert encode_base64
53
- assert decode_base64
54
- assert validate_base64
55
- assert encode_jwt
56
- assert decode_jwt
57
- assert validate_jwt
58
- assert llm_ask
59
- assert hash_md5
60
- assert sum_md5
61
- assert validate_md5
62
- assert get_git_diff
63
- assert prune_local_branches
64
- assert format_python_code
65
- assert git_commit
66
- assert git_pull
67
- assert git_push
68
- assert git_add_subtree
69
- assert git_pull_subtree
70
- assert git_push_subtree
71
- assert list_todo
72
- assert add_todo
73
- assert archive_todo
74
- assert edit_todo
75
- assert complete_todo
76
- assert log_todo
77
- assert show_todo
78
- assert throw_dice
79
- assert shuffle_values
80
- assert setup_ubuntu
81
- assert setup_latex_on_ubuntu
82
- assert setup_asdf
83
- assert setup_tmux
84
- assert setup_zsh
85
- assert validate_uuid
86
- assert validate_uuid_v1
87
- assert validate_uuid_v3
88
- assert validate_uuid_v4
89
- assert validate_uuid_v5
90
- assert generate_uuid_v1
91
- assert generate_uuid_v3
92
- assert generate_uuid_v4
93
- assert generate_uuid_v5
94
- assert http_request
95
- assert generate_curl
zrb/builtin/git.py CHANGED
@@ -82,6 +82,12 @@ async def get_git_diff(ctx: AnyContext):
82
82
 
83
83
  @make_task(
84
84
  name="prune-local-git-branches",
85
+ input=StrInput(
86
+ name="preserved-branch",
87
+ description="Branches to be preserved",
88
+ prompt="Branches to be preserved, comma separated",
89
+ default="master,main,dev,develop",
90
+ ),
85
91
  description="🧹 Prune local branches",
86
92
  group=git_branch_group,
87
93
  alias="prune",
@@ -93,8 +99,13 @@ async def prune_local_branches(ctx: AnyContext):
93
99
  branches = await get_branches(repo_dir, print_method=ctx.print)
94
100
  ctx.print(stylize_faint("Get current branch"))
95
101
  current_branch = await get_current_branch(repo_dir, print_method=ctx.print)
102
+ preserved_branches = [
103
+ branch.strip()
104
+ for branch in ctx.input.preserved_branch.split(",")
105
+ if branch.strip() != ""
106
+ ]
96
107
  for branch in branches:
97
- if branch == current_branch or branch == "main" or branch == "master":
108
+ if branch == current_branch or branch in preserved_branches:
98
109
  continue
99
110
  ctx.print(stylize_faint(f"Removing local branch: {branch}"))
100
111
  try:
zrb/builtin/group.py CHANGED
@@ -1,39 +1,51 @@
1
+ from zrb.config.config import CFG
1
2
  from zrb.group.group import Group
2
3
  from zrb.runner.cli import cli
3
4
 
4
- base64_group = cli.add_group(Group(name="base64", description="📄 Base64 operations"))
5
- uuid_group = cli.add_group(Group(name="uuid", description="🆔 UUID operations"))
5
+
6
+ def _maybe_add_group(group: Group):
7
+ if CFG.LOAD_BUILTIN:
8
+ cli.add_group(group)
9
+ return group
10
+
11
+
12
+ base64_group = _maybe_add_group(
13
+ Group(name="base64", description="📄 Base64 operations")
14
+ )
15
+ uuid_group = _maybe_add_group(Group(name="uuid", description="🆔 UUID operations"))
6
16
  uuid_v1_group = uuid_group.add_group(Group(name="v1", description="UUID V1 operations"))
7
17
  uuid_v3_group = uuid_group.add_group(Group(name="v3", description="UUID V3 operations"))
8
18
  uuid_v4_group = uuid_group.add_group(Group(name="v4", description="UUID V4 operations"))
9
19
  uuid_v5_group = uuid_group.add_group(Group(name="v5", description="UUID V5 operations"))
10
- ulid_group = cli.add_group(Group(name="ulid", description="🔢 ULID operations"))
11
- jwt_group = cli.add_group(Group(name="jwt", description="🔒 JWT encode/decode"))
12
- http_group = cli.add_group(Group(name="http", description="🌐 HTTP request operations"))
20
+ ulid_group = _maybe_add_group(Group(name="ulid", description="🔢 ULID operations"))
21
+ jwt_group = _maybe_add_group(Group(name="jwt", description="🔒 JWT encode/decode"))
22
+ http_group = _maybe_add_group(
23
+ Group(name="http", description="🌐 HTTP request operations")
24
+ )
13
25
 
14
- random_group = cli.add_group(Group(name="random", description="🔀 Random operation"))
15
- git_group = cli.add_group(Group(name="git", description="🌱 Git related commands"))
26
+ random_group = _maybe_add_group(Group(name="random", description="🔀 Random operation"))
27
+ git_group = _maybe_add_group(Group(name="git", description="🌱 Git related commands"))
16
28
  git_branch_group = git_group.add_group(
17
29
  Group(name="branch", description="🌿 Git branch related commands")
18
30
  )
19
31
  git_subtree_group = git_group.add_group(
20
32
  Group(name="subtree", description="🌳 Git subtree related commands")
21
33
  )
22
- llm_group = cli.add_group(Group(name="llm", description="🤖 LLM operations"))
23
- md5_group = cli.add_group(Group(name="md5", description="🔢 Md5 operations"))
24
- python_group = cli.add_group(
34
+ llm_group = _maybe_add_group(Group(name="llm", description="🤖 LLM operations"))
35
+ md5_group = _maybe_add_group(Group(name="md5", description="🔢 Md5 operations"))
36
+ python_group = _maybe_add_group(
25
37
  Group(name="python", description="🐍 Python related commands")
26
38
  )
27
- todo_group = cli.add_group(Group(name="todo", description="✅ Todo management"))
39
+ todo_group = _maybe_add_group(Group(name="todo", description="✅ Todo management"))
28
40
 
29
- shell_group = cli.add_group(
41
+ shell_group = _maybe_add_group(
30
42
  Group(name="shell", description="💬 Shell related commands")
31
43
  )
32
- shell_autocomplete_group: Group = shell_group.add_group(
44
+ shell_autocomplete_group = shell_group.add_group(
33
45
  Group(name="autocomplete", description="⌨️ Shell autocomplete related commands")
34
46
  )
35
47
 
36
- project_group = cli.add_group(
48
+ project_group = _maybe_add_group(
37
49
  Group(name="project", description="📁 Project related commands")
38
50
  )
39
51
  add_to_project_group = project_group.add_group(
@@ -43,7 +55,11 @@ add_fastapp_to_project_group = add_to_project_group.add_group(
43
55
  Group(name="fastapp", description="🚀 Add Fastapp resources")
44
56
  )
45
57
 
46
- setup_group = cli.add_group(Group(name="setup", description="🔧 Setup"))
58
+ setup_group = _maybe_add_group(Group(name="setup", description="🔧 Setup"))
47
59
  setup_latex_group = setup_group.add_group(
48
60
  Group(name="latex", description="✍️ Setup LaTeX")
49
61
  )
62
+
63
+ searxng_group = _maybe_add_group(
64
+ Group(name="searxng", description="🔎 Searxng related command")
65
+ )
zrb/builtin/http.py CHANGED
@@ -2,6 +2,7 @@ from typing import Any
2
2
 
3
3
  from zrb.builtin.group import http_group
4
4
  from zrb.context.any_context import AnyContext
5
+ from zrb.input.bool_input import BoolInput
5
6
  from zrb.input.option_input import OptionInput
6
7
  from zrb.input.str_input import StrInput
7
8
  from zrb.task.make_task import make_task
@@ -32,10 +33,9 @@ from zrb.task.make_task import make_task
32
33
  prompt="Enter body as JSON",
33
34
  default="{}",
34
35
  ),
35
- OptionInput(
36
+ BoolInput(
36
37
  name="verify_ssl",
37
- default="true",
38
- options=["true", "false"],
38
+ default=True,
39
39
  description="Verify SSL certificate",
40
40
  ),
41
41
  ],
@@ -55,7 +55,7 @@ def http_request(ctx: AnyContext) -> Any:
55
55
  body = json.loads(ctx.input.body)
56
56
 
57
57
  # Make request
58
- verify = ctx.input.verify_ssl.lower() == "true"
58
+ verify = ctx.input.verify_ssl
59
59
  response = requests.request(
60
60
  method=ctx.input.method,
61
61
  url=ctx.input.url,
@@ -107,10 +107,9 @@ def http_request(ctx: AnyContext) -> Any:
107
107
  prompt="Enter body as JSON",
108
108
  default="{}",
109
109
  ),
110
- OptionInput(
110
+ BoolInput(
111
111
  name="verify_ssl",
112
- default="true",
113
- options=["true", "false"],
112
+ default=True,
114
113
  description="Verify SSL certificate",
115
114
  ),
116
115
  ],
@@ -137,7 +136,7 @@ def generate_curl(ctx: AnyContext) -> str:
137
136
  parts.extend(["--data-raw", shlex.quote(ctx.input.body)])
138
137
 
139
138
  # Add SSL verification
140
- if ctx.input.verify_ssl.lower() == "false":
139
+ if not ctx.input.verify_ssl:
141
140
  parts.append("--insecure")
142
141
 
143
142
  # Add URL
@@ -0,0 +1,40 @@
1
+ def get_media_type(filename: str) -> str | None:
2
+ """Guess media type string based on file extension."""
3
+ ext = filename.lower().rsplit(".", 1)[-1] if "." in filename else ""
4
+ mapping: dict[str, str] = {
5
+ # Audio
6
+ "wav": "audio/wav",
7
+ "mp3": "audio/mpeg",
8
+ "ogg": "audio/ogg",
9
+ "flac": "audio/flac",
10
+ "aiff": "audio/aiff",
11
+ "aac": "audio/aac",
12
+ # Image
13
+ "jpg": "image/jpeg",
14
+ "jpeg": "image/jpeg",
15
+ "png": "image/png",
16
+ "gif": "image/gif",
17
+ "webp": "image/webp",
18
+ # Document
19
+ "pdf": "application/pdf",
20
+ "txt": "text/plain",
21
+ "csv": "text/csv",
22
+ "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
23
+ "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
24
+ "html": "text/html",
25
+ "htm": "text/html",
26
+ "md": "text/markdown",
27
+ "doc": "application/msword",
28
+ "xls": "application/vnd.ms-excel",
29
+ # Video
30
+ "mkv": "video/x-matroska",
31
+ "mov": "video/quicktime",
32
+ "mp4": "video/mp4",
33
+ "webm": "video/webm",
34
+ "flv": "video/x-flv",
35
+ "mpeg": "video/mpeg",
36
+ "mpg": "video/mpeg",
37
+ "wmv": "video/x-ms-wmv",
38
+ "3gp": "video/3gpp",
39
+ }
40
+ return mapping.get(ext)