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.
- zrb/__init__.py +126 -113
- zrb/__main__.py +1 -1
- zrb/attr/type.py +10 -7
- zrb/builtin/__init__.py +2 -50
- zrb/builtin/git.py +12 -1
- zrb/builtin/group.py +31 -15
- zrb/builtin/http.py +7 -8
- zrb/builtin/llm/attachment.py +40 -0
- zrb/builtin/llm/chat_completion.py +274 -0
- zrb/builtin/llm/chat_session.py +152 -85
- zrb/builtin/llm/chat_session_cmd.py +288 -0
- zrb/builtin/llm/chat_trigger.py +79 -0
- zrb/builtin/llm/history.py +7 -9
- zrb/builtin/llm/llm_ask.py +221 -98
- zrb/builtin/llm/tool/api.py +74 -52
- zrb/builtin/llm/tool/cli.py +46 -17
- zrb/builtin/llm/tool/code.py +71 -90
- zrb/builtin/llm/tool/file.py +301 -241
- zrb/builtin/llm/tool/note.py +84 -0
- zrb/builtin/llm/tool/rag.py +38 -8
- zrb/builtin/llm/tool/sub_agent.py +67 -50
- zrb/builtin/llm/tool/web.py +146 -122
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/add_entity_util.py +7 -7
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/add_module_util.py +5 -5
- zrb/builtin/project/add/fastapp/fastapp_util.py +1 -1
- zrb/builtin/searxng/config/settings.yml +5671 -0
- zrb/builtin/searxng/start.py +21 -0
- zrb/builtin/setup/latex/ubuntu.py +1 -0
- zrb/builtin/setup/ubuntu.py +1 -1
- zrb/builtin/shell/autocomplete/bash.py +4 -3
- zrb/builtin/shell/autocomplete/zsh.py +4 -3
- zrb/builtin/todo.py +13 -2
- zrb/config/config.py +614 -0
- zrb/config/default_prompt/file_extractor_system_prompt.md +112 -0
- zrb/config/default_prompt/interactive_system_prompt.md +29 -0
- zrb/config/default_prompt/persona.md +1 -0
- zrb/config/default_prompt/repo_extractor_system_prompt.md +112 -0
- zrb/config/default_prompt/repo_summarizer_system_prompt.md +29 -0
- zrb/config/default_prompt/summarization_prompt.md +57 -0
- zrb/config/default_prompt/system_prompt.md +38 -0
- zrb/config/llm_config.py +339 -0
- zrb/config/llm_context/config.py +166 -0
- zrb/config/llm_context/config_parser.py +40 -0
- zrb/config/llm_context/workflow.py +81 -0
- zrb/config/llm_rate_limitter.py +190 -0
- zrb/{runner → config}/web_auth_config.py +17 -22
- zrb/context/any_shared_context.py +17 -1
- zrb/context/context.py +16 -2
- zrb/context/shared_context.py +18 -8
- zrb/group/any_group.py +12 -5
- zrb/group/group.py +67 -3
- zrb/input/any_input.py +5 -1
- zrb/input/base_input.py +18 -6
- zrb/input/option_input.py +13 -1
- zrb/input/text_input.py +8 -25
- zrb/runner/cli.py +25 -23
- zrb/runner/common_util.py +24 -19
- zrb/runner/web_app.py +3 -3
- zrb/runner/web_route/docs_route.py +1 -1
- zrb/runner/web_route/error_page/serve_default_404.py +1 -1
- zrb/runner/web_route/error_page/show_error_page.py +1 -1
- zrb/runner/web_route/home_page/home_page_route.py +2 -2
- zrb/runner/web_route/login_api_route.py +1 -1
- zrb/runner/web_route/login_page/login_page_route.py +2 -2
- zrb/runner/web_route/logout_api_route.py +1 -1
- zrb/runner/web_route/logout_page/logout_page_route.py +2 -2
- zrb/runner/web_route/node_page/group/show_group_page.py +1 -1
- zrb/runner/web_route/node_page/node_page_route.py +1 -1
- zrb/runner/web_route/node_page/task/show_task_page.py +1 -1
- zrb/runner/web_route/refresh_token_api_route.py +1 -1
- zrb/runner/web_route/static/static_route.py +1 -1
- zrb/runner/web_route/task_input_api_route.py +6 -6
- zrb/runner/web_route/task_session_api_route.py +20 -12
- zrb/runner/web_util/cookie.py +1 -1
- zrb/runner/web_util/token.py +1 -1
- zrb/runner/web_util/user.py +8 -4
- zrb/session/any_session.py +24 -17
- zrb/session/session.py +50 -25
- zrb/session_state_logger/any_session_state_logger.py +9 -4
- zrb/session_state_logger/file_session_state_logger.py +16 -6
- zrb/session_state_logger/session_state_logger_factory.py +1 -1
- zrb/task/any_task.py +30 -9
- zrb/task/base/context.py +17 -9
- zrb/task/base/execution.py +15 -8
- zrb/task/base/lifecycle.py +8 -4
- zrb/task/base/monitoring.py +12 -7
- zrb/task/base_task.py +69 -5
- zrb/task/base_trigger.py +12 -5
- zrb/task/cmd_task.py +1 -1
- zrb/task/llm/agent.py +154 -161
- zrb/task/llm/agent_runner.py +152 -0
- zrb/task/llm/config.py +47 -18
- zrb/task/llm/conversation_history.py +209 -0
- zrb/task/llm/conversation_history_model.py +67 -0
- zrb/task/llm/default_workflow/coding/workflow.md +41 -0
- zrb/task/llm/default_workflow/copywriting/workflow.md +68 -0
- zrb/task/llm/default_workflow/git/workflow.md +118 -0
- zrb/task/llm/default_workflow/golang/workflow.md +128 -0
- zrb/task/llm/default_workflow/html-css/workflow.md +135 -0
- zrb/task/llm/default_workflow/java/workflow.md +146 -0
- zrb/task/llm/default_workflow/javascript/workflow.md +158 -0
- zrb/task/llm/default_workflow/python/workflow.md +160 -0
- zrb/task/llm/default_workflow/researching/workflow.md +153 -0
- zrb/task/llm/default_workflow/rust/workflow.md +162 -0
- zrb/task/llm/default_workflow/shell/workflow.md +299 -0
- zrb/task/llm/error.py +24 -10
- zrb/task/llm/file_replacement.py +206 -0
- zrb/task/llm/file_tool_model.py +57 -0
- zrb/task/llm/history_processor.py +206 -0
- zrb/task/llm/history_summarization.py +11 -166
- zrb/task/llm/print_node.py +193 -69
- zrb/task/llm/prompt.py +242 -45
- zrb/task/llm/subagent_conversation_history.py +41 -0
- zrb/task/llm/tool_wrapper.py +260 -57
- zrb/task/llm/workflow.py +76 -0
- zrb/task/llm_task.py +182 -171
- zrb/task/make_task.py +2 -3
- zrb/task/rsync_task.py +26 -11
- zrb/task/scheduler.py +4 -4
- zrb/util/attr.py +54 -39
- zrb/util/callable.py +23 -0
- zrb/util/cli/markdown.py +12 -0
- zrb/util/cli/text.py +30 -0
- zrb/util/file.py +29 -11
- zrb/util/git.py +8 -11
- zrb/util/git_diff_model.py +10 -0
- zrb/util/git_subtree.py +9 -14
- zrb/util/git_subtree_model.py +32 -0
- zrb/util/init_path.py +1 -1
- zrb/util/markdown.py +62 -0
- zrb/util/string/conversion.py +2 -2
- zrb/util/todo.py +17 -50
- zrb/util/todo_model.py +46 -0
- zrb/util/truncate.py +23 -0
- zrb/util/yaml.py +204 -0
- zrb/xcom/xcom.py +10 -0
- zrb-1.21.29.dist-info/METADATA +270 -0
- {zrb-1.8.10.dist-info → zrb-1.21.29.dist-info}/RECORD +140 -98
- {zrb-1.8.10.dist-info → zrb-1.21.29.dist-info}/WHEEL +1 -1
- zrb/config.py +0 -335
- zrb/llm_config.py +0 -411
- zrb/llm_rate_limitter.py +0 -125
- zrb/task/llm/context.py +0 -102
- zrb/task/llm/context_enrichment.py +0 -199
- zrb/task/llm/history.py +0 -211
- zrb-1.8.10.dist-info/METADATA +0 -264
- {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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
|
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
|
-
|
|
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
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 =
|
|
12
|
-
|
|
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
|
|
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
|
-
|
|
5
|
-
|
|
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 =
|
|
11
|
-
jwt_group =
|
|
12
|
-
http_group =
|
|
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 =
|
|
15
|
-
git_group =
|
|
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 =
|
|
23
|
-
md5_group =
|
|
24
|
-
python_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 =
|
|
39
|
+
todo_group = _maybe_add_group(Group(name="todo", description="✅ Todo management"))
|
|
28
40
|
|
|
29
|
-
shell_group =
|
|
41
|
+
shell_group = _maybe_add_group(
|
|
30
42
|
Group(name="shell", description="💬 Shell related commands")
|
|
31
43
|
)
|
|
32
|
-
shell_autocomplete_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 =
|
|
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 =
|
|
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
|
-
|
|
36
|
+
BoolInput(
|
|
36
37
|
name="verify_ssl",
|
|
37
|
-
default=
|
|
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
|
|
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
|
-
|
|
110
|
+
BoolInput(
|
|
111
111
|
name="verify_ssl",
|
|
112
|
-
default=
|
|
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
|
|
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)
|