zrb 1.0.0a2__py3-none-any.whl → 1.0.0a4__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.
- zrb/__init__.py +49 -40
- zrb/__main__.py +5 -3
- zrb/attr/type.py +2 -1
- zrb/builtin/__init__.py +42 -2
- zrb/builtin/base64.py +34 -0
- zrb/builtin/git.py +156 -0
- zrb/builtin/git_subtree.py +88 -0
- zrb/builtin/group.py +34 -0
- zrb/builtin/llm/llm_chat.py +47 -0
- zrb/builtin/llm/tool/cli.py +9 -0
- zrb/builtin/llm/tool/rag.py +189 -0
- zrb/builtin/llm/tool/web.py +74 -0
- zrb/builtin/md5.py +36 -0
- zrb/builtin/project/add/fastapp.py +72 -0
- zrb/builtin/project/add/fastapp_template/.gitignore +4 -0
- zrb/builtin/project/add/fastapp_template/README.md +7 -0
- zrb/builtin/project/add/fastapp_template/_zrb/config.py +17 -0
- zrb/builtin/project/add/fastapp_template/_zrb/group.py +16 -0
- zrb/builtin/project/add/fastapp_template/_zrb/helper.py +97 -0
- zrb/builtin/project/add/fastapp_template/_zrb/main.py +132 -0
- zrb/builtin/project/add/fastapp_template/_zrb/venv_task.py +22 -0
- zrb/builtin/project/add/fastapp_template/common/app.py +18 -0
- zrb/builtin/project/add/fastapp_template/common/db_engine.py +5 -0
- zrb/builtin/project/add/fastapp_template/common/db_repository.py +134 -0
- zrb/builtin/project/add/fastapp_template/common/error.py +8 -0
- zrb/builtin/project/add/fastapp_template/common/schema.py +5 -0
- zrb/builtin/project/add/fastapp_template/common/usecase.py +232 -0
- zrb/builtin/project/add/fastapp_template/config.py +29 -0
- zrb/builtin/project/add/fastapp_template/main.py +7 -0
- zrb/builtin/project/add/fastapp_template/migrate.py +3 -0
- zrb/builtin/project/add/fastapp_template/module/__init__.py +0 -0
- zrb/builtin/project/add/fastapp_template/module/auth/alembic.ini +117 -0
- zrb/builtin/project/add/fastapp_template/module/auth/client/api_client.py +7 -0
- zrb/builtin/project/add/fastapp_template/module/auth/client/base_client.py +27 -0
- zrb/builtin/project/add/fastapp_template/module/auth/client/direct_client.py +6 -0
- zrb/builtin/project/add/fastapp_template/module/auth/client/factory.py +9 -0
- zrb/builtin/project/add/fastapp_template/module/auth/migration/README +1 -0
- zrb/builtin/project/add/fastapp_template/module/auth/migration/env.py +108 -0
- zrb/builtin/project/add/fastapp_template/module/auth/migration/script.py.mako +26 -0
- zrb/builtin/project/add/fastapp_template/module/auth/migration/versions/3093c7336477_add_user_table.py +37 -0
- zrb/builtin/project/add/fastapp_template/module/auth/migration_metadata.py +6 -0
- zrb/builtin/project/add/fastapp_template/module/auth/route.py +22 -0
- zrb/builtin/project/add/fastapp_template/module/auth/service/__init__.py +0 -0
- zrb/builtin/project/add/fastapp_template/module/auth/service/user/__init__.py +0 -0
- zrb/builtin/project/add/fastapp_template/module/auth/service/user/repository/__init__.py +0 -0
- zrb/builtin/project/add/fastapp_template/module/auth/service/user/repository/db_repository.py +39 -0
- zrb/builtin/project/add/fastapp_template/module/auth/service/user/repository/factory.py +13 -0
- zrb/builtin/project/add/fastapp_template/module/auth/service/user/repository/repository.py +34 -0
- zrb/builtin/project/add/fastapp_template/module/auth/service/user/usecase.py +45 -0
- zrb/builtin/project/add/fastapp_template/module/gateway/alembic.ini +117 -0
- zrb/builtin/project/add/fastapp_template/module/gateway/migration/README +1 -0
- zrb/builtin/project/add/fastapp_template/module/gateway/migration/env.py +108 -0
- zrb/builtin/project/add/fastapp_template/module/gateway/migration/script.py.mako +26 -0
- zrb/builtin/project/add/fastapp_template/module/gateway/migration/versions/.gitkeep +0 -0
- zrb/builtin/project/add/fastapp_template/module/gateway/migration_metadata.py +3 -0
- zrb/builtin/project/add/fastapp_template/module/gateway/route.py +27 -0
- zrb/builtin/project/add/fastapp_template/requirements.txt +6 -0
- zrb/builtin/project/add/fastapp_template/schema/__init__.py +0 -0
- zrb/builtin/project/add/fastapp_template/schema/role.py +31 -0
- zrb/builtin/project/add/fastapp_template/schema/user.py +31 -0
- zrb/builtin/project/add/fastapp_template/template.env +2 -0
- zrb/builtin/project/create/__init__.py +0 -0
- zrb/builtin/project/create/create.py +41 -0
- zrb/builtin/project/create/project-template/README.md +3 -0
- zrb/builtin/project/create/project-template/zrb_init.py +7 -0
- zrb/builtin/python.py +11 -0
- zrb/builtin/shell/__init__.py +0 -5
- zrb/builtin/shell/autocomplete/__init__.py +0 -9
- zrb/builtin/shell/autocomplete/bash.py +5 -6
- zrb/builtin/shell/autocomplete/subcmd.py +7 -8
- zrb/builtin/shell/autocomplete/zsh.py +5 -6
- zrb/builtin/todo.py +219 -0
- zrb/callback/any_callback.py +1 -1
- zrb/callback/callback.py +5 -5
- zrb/cmd/cmd_val.py +2 -2
- zrb/config.py +16 -3
- zrb/content_transformer/any_content_transformer.py +1 -1
- zrb/content_transformer/content_transformer.py +2 -2
- zrb/context/any_context.py +1 -1
- zrb/context/any_shared_context.py +3 -3
- zrb/context/context.py +10 -8
- zrb/context/shared_context.py +9 -8
- zrb/env/__init__.py +0 -3
- zrb/env/any_env.py +1 -1
- zrb/env/env.py +3 -4
- zrb/env/env_file.py +4 -4
- zrb/env/env_map.py +2 -2
- zrb/group/__init__.py +0 -3
- zrb/group/any_group.py +3 -3
- zrb/group/group.py +7 -6
- zrb/input/any_input.py +1 -1
- zrb/input/base_input.py +4 -4
- zrb/input/bool_input.py +5 -5
- zrb/input/float_input.py +3 -3
- zrb/input/int_input.py +3 -3
- zrb/input/option_input.py +51 -0
- zrb/input/password_input.py +2 -2
- zrb/input/str_input.py +1 -1
- zrb/input/text_input.py +12 -10
- zrb/runner/cli.py +80 -45
- zrb/runner/web_app.py +150 -0
- zrb/runner/web_controller/__init__.py +0 -0
- zrb/runner/web_controller/group_info_ui/__init__.py +0 -0
- zrb/runner/{web_app → web_controller}/group_info_ui/controller.py +7 -8
- zrb/runner/{web_app → web_controller}/group_info_ui/view.html +2 -2
- zrb/runner/web_controller/home_page/__init__.py +0 -0
- zrb/runner/{web_app → web_controller}/home_page/controller.py +7 -6
- zrb/runner/{web_app → web_controller}/home_page/view.html +2 -2
- zrb/runner/web_controller/task_ui/__init__.py +0 -0
- zrb/runner/{web_app → web_controller}/task_ui/controller.py +8 -12
- zrb/runner/{web_app → web_controller}/task_ui/view.html +2 -2
- zrb/runner/web_util.py +5 -35
- zrb/session/any_session.py +13 -7
- zrb/session/session.py +78 -40
- zrb/session_state_log/session_state_log.py +7 -5
- zrb/session_state_logger/any_session_state_logger.py +1 -1
- zrb/session_state_logger/default_session_state_logger.py +2 -2
- zrb/session_state_logger/file_session_state_logger.py +19 -27
- zrb/task/any_task.py +4 -4
- zrb/task/base_task.py +33 -23
- zrb/task/base_trigger.py +11 -12
- zrb/task/cmd_task.py +72 -65
- zrb/task/http_check.py +13 -13
- zrb/task/llm_task.py +215 -0
- zrb/task/make_task.py +9 -9
- zrb/task/rsync_task.py +25 -25
- zrb/task/scaffolder.py +18 -15
- zrb/task/scheduler.py +6 -7
- zrb/task/task.py +1 -1
- zrb/task/tcp_check.py +11 -13
- zrb/util/attr.py +19 -3
- zrb/util/cli/style.py +71 -2
- zrb/util/cli/subcommand.py +2 -2
- zrb/util/codemod/__init__.py +0 -0
- zrb/util/codemod/add_code_to_class.py +35 -0
- zrb/util/codemod/add_code_to_function.py +36 -0
- zrb/util/codemod/add_code_to_method.py +55 -0
- zrb/util/codemod/add_key_to_dict.py +51 -0
- zrb/util/codemod/add_param_to_function_call.py +39 -0
- zrb/util/codemod/add_property_to_class.py +55 -0
- zrb/util/git.py +156 -0
- zrb/util/git_subtree.py +94 -0
- zrb/util/group.py +2 -2
- zrb/util/llm/tool.py +63 -0
- zrb/util/string/conversion.py +7 -0
- zrb/util/todo.py +259 -0
- {zrb-1.0.0a2.dist-info → zrb-1.0.0a4.dist-info}/METADATA +13 -5
- zrb-1.0.0a4.dist-info/RECORD +197 -0
- zrb/builtin/shell/_group.py +0 -9
- zrb/builtin/shell/autocomplete/_group.py +0 -6
- zrb/runner/web_app/any_request_handler.py +0 -24
- zrb/runner/web_server.py +0 -224
- zrb-1.0.0a2.dist-info/RECORD +0 -120
- /zrb/{runner/web_app → builtin/project}/__init__.py +0 -0
- /zrb/{runner/web_app/group_info_ui → builtin/project/add}/__init__.py +0 -0
- /zrb/{runner/web_app/home_page → builtin/project/add/fastapp_template}/__init__.py +0 -0
- /zrb/{runner/web_app/task_ui → builtin/project/add/fastapp_template/common}/__init__.py +0 -0
- /zrb/runner/{web_app → web_controller}/group_info_ui/partial/group_info.html +0 -0
- /zrb/runner/{web_app → web_controller}/group_info_ui/partial/group_li.html +0 -0
- /zrb/runner/{web_app → web_controller}/group_info_ui/partial/task_info.html +0 -0
- /zrb/runner/{web_app → web_controller}/group_info_ui/partial/task_li.html +0 -0
- /zrb/runner/{web_app → web_controller}/home_page/partial/group_info.html +0 -0
- /zrb/runner/{web_app → web_controller}/home_page/partial/group_li.html +0 -0
- /zrb/runner/{web_app → web_controller}/home_page/partial/task_info.html +0 -0
- /zrb/runner/{web_app → web_controller}/home_page/partial/task_li.html +0 -0
- /zrb/runner/{web_app → web_controller}/static/favicon-32x32.png +0 -0
- /zrb/runner/{web_app → web_controller}/static/pico.min.css +0 -0
- /zrb/runner/{web_app → web_controller}/task_ui/partial/common-util.js +0 -0
- /zrb/runner/{web_app → web_controller}/task_ui/partial/input.html +0 -0
- /zrb/runner/{web_app → web_controller}/task_ui/partial/main.js +0 -0
- /zrb/runner/{web_app → web_controller}/task_ui/partial/show-existing-session.js +0 -0
- /zrb/runner/{web_app → web_controller}/task_ui/partial/visualize-history.js +0 -0
- {zrb-1.0.0a2.dist-info → zrb-1.0.0a4.dist-info}/WHEEL +0 -0
- {zrb-1.0.0a2.dist-info → zrb-1.0.0a4.dist-info}/entry_points.txt +0 -0
zrb/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from .attr.type import (
|
1
|
+
from zrb.attr.type import (
|
2
2
|
AnyAttr,
|
3
3
|
BoolAttr,
|
4
4
|
FloatAttr,
|
@@ -7,44 +7,50 @@ from .attr.type import (
|
|
7
7
|
StrDictAttr,
|
8
8
|
fstring,
|
9
9
|
)
|
10
|
-
from .callback.any_callback import AnyCallback
|
11
|
-
from .callback.callback import Callback
|
12
|
-
from .cmd.cmd_result import CmdResult
|
13
|
-
from .cmd.cmd_val import Cmd, CmdPath
|
14
|
-
from .config import
|
15
|
-
from .content_transformer.any_content_transformer import AnyContentTransformer
|
16
|
-
from .content_transformer.content_transformer import ContentTransformer
|
17
|
-
from .context.any_context import AnyContext
|
18
|
-
from .context.any_shared_context import AnySharedContext
|
19
|
-
from .context.context import Context
|
20
|
-
from .context.shared_context import SharedContext
|
21
|
-
from .env.any_env import AnyEnv
|
22
|
-
from .env.env import Env
|
23
|
-
from .env.env_file import EnvFile
|
24
|
-
from .env.env_map import EnvMap
|
25
|
-
from .group.any_group import AnyGroup
|
26
|
-
from .group.group import Group
|
27
|
-
from .input.any_input import AnyInput
|
28
|
-
from .input.base_input import BaseInput
|
29
|
-
from .input.
|
30
|
-
from .input.
|
31
|
-
from .input.
|
32
|
-
from .input.
|
33
|
-
from .
|
34
|
-
from .
|
35
|
-
from .
|
36
|
-
from .
|
37
|
-
from .task.
|
38
|
-
from .task.
|
39
|
-
from .task.
|
40
|
-
from .task.
|
41
|
-
from .task.
|
42
|
-
from .task.
|
43
|
-
from .task.
|
44
|
-
from .task.
|
45
|
-
from .task.
|
46
|
-
from .
|
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 LOAD_BUILTIN
|
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.int_input import IntInput
|
31
|
+
from zrb.input.option_input import OptionInput
|
32
|
+
from zrb.input.password_input import PasswordInput
|
33
|
+
from zrb.input.str_input import StrInput
|
34
|
+
from zrb.input.text_input import TextInput
|
35
|
+
from zrb.runner.cli import cli
|
36
|
+
from zrb.session.session import Session
|
37
|
+
from zrb.task.any_task import AnyTask
|
38
|
+
from zrb.task.base_task import BaseTask
|
39
|
+
from zrb.task.base_trigger import BaseTrigger
|
40
|
+
from zrb.task.cmd_task import CmdTask
|
41
|
+
from zrb.task.http_check import HttpCheck
|
42
|
+
from zrb.task.llm_task import LLMTask
|
43
|
+
from zrb.task.make_task import make_task
|
44
|
+
from zrb.task.rsync_task import RsyncTask
|
45
|
+
from zrb.task.scaffolder import Scaffolder
|
46
|
+
from zrb.task.scheduler import Scheduler
|
47
|
+
from zrb.task.task import Task
|
48
|
+
from zrb.task.tcp_check import TcpCheck
|
49
|
+
from zrb.util.load import load_file, load_module
|
50
|
+
from zrb.xcom.xcom import Xcom
|
47
51
|
|
52
|
+
assert load_file
|
53
|
+
assert load_module
|
48
54
|
assert fstring
|
49
55
|
assert AnyAttr
|
50
56
|
assert BoolAttr
|
@@ -60,6 +66,7 @@ assert EnvFile
|
|
60
66
|
assert EnvMap
|
61
67
|
assert AnyInput
|
62
68
|
assert BaseInput
|
69
|
+
assert BoolInput
|
63
70
|
assert Cmd
|
64
71
|
assert CmdPath
|
65
72
|
assert CmdResult
|
@@ -67,6 +74,7 @@ assert CmdTask
|
|
67
74
|
assert HttpCheck
|
68
75
|
assert TcpCheck
|
69
76
|
assert IntInput
|
77
|
+
assert OptionInput
|
70
78
|
assert PasswordInput
|
71
79
|
assert StrInput
|
72
80
|
assert TextInput
|
@@ -77,6 +85,7 @@ assert BaseTask
|
|
77
85
|
assert BaseTrigger
|
78
86
|
assert RsyncTask
|
79
87
|
assert Task
|
88
|
+
assert LLMTask
|
80
89
|
assert Session
|
81
90
|
assert AnyContext
|
82
91
|
assert Context
|
@@ -90,7 +99,7 @@ assert Scheduler
|
|
90
99
|
assert cli
|
91
100
|
assert Xcom
|
92
101
|
|
93
|
-
if
|
94
|
-
from
|
102
|
+
if LOAD_BUILTIN:
|
103
|
+
from zrb import builtin
|
95
104
|
|
96
105
|
assert builtin
|
zrb/__main__.py
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
import sys
|
2
2
|
|
3
|
-
from .runner.cli import cli
|
4
|
-
from .util.cli.style import stylize_error
|
5
|
-
from .util.group import NodeNotFoundError
|
3
|
+
from zrb.runner.cli import cli
|
4
|
+
from zrb.util.cli.style import stylize_error, stylize_warning
|
5
|
+
from zrb.util.group import NodeNotFoundError
|
6
6
|
|
7
7
|
|
8
8
|
def serve_cli():
|
9
9
|
try:
|
10
10
|
cli.run(sys.argv[1:])
|
11
|
+
except KeyboardInterrupt:
|
12
|
+
print(stylize_warning("\nStopped"), file=sys.stderr)
|
11
13
|
except NodeNotFoundError as e:
|
12
14
|
print(stylize_error(f"{e}"), file=sys.stderr)
|
zrb/attr/type.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import Any, Callable
|
2
2
|
|
3
|
-
from
|
3
|
+
from zrb.context.any_shared_context import AnySharedContext
|
4
4
|
|
5
5
|
fstring = str
|
6
6
|
AnyAttr = Any | fstring | Callable[[AnySharedContext], Any]
|
@@ -9,3 +9,4 @@ BoolAttr = bool | fstring | Callable[[AnySharedContext], bool]
|
|
9
9
|
IntAttr = int | fstring | Callable[[AnySharedContext], int]
|
10
10
|
FloatAttr = float | fstring | Callable[[AnySharedContext], float]
|
11
11
|
StrDictAttr = dict[str, StrAttr] | Callable[[AnySharedContext], dict[str, Any]]
|
12
|
+
StrListAttr = list[StrAttr] | Callable[[AnySharedContext], list[str]]
|
zrb/builtin/__init__.py
CHANGED
@@ -1,3 +1,43 @@
|
|
1
|
-
from . import
|
1
|
+
from zrb.builtin.base64 import decode_base64, encode_base64
|
2
|
+
from zrb.builtin.git import (
|
3
|
+
get_git_diff,
|
4
|
+
git_commit,
|
5
|
+
git_pull,
|
6
|
+
git_push,
|
7
|
+
prune_local_branches,
|
8
|
+
)
|
9
|
+
from zrb.builtin.git_subtree import git_add_subtree, git_pull_subtree, git_push_subtree
|
10
|
+
from zrb.builtin.llm.llm_chat import llm_chat
|
11
|
+
from zrb.builtin.md5 import hash_md5, sum_md5
|
12
|
+
from zrb.builtin.project.add.fastapp import add_fastapp_to_project
|
13
|
+
from zrb.builtin.project.create.create import create_project
|
14
|
+
from zrb.builtin.python import format_python_code
|
15
|
+
from zrb.builtin.shell.autocomplete.bash import make_bash_autocomplete
|
16
|
+
from zrb.builtin.shell.autocomplete.subcmd import get_shell_subcommands
|
17
|
+
from zrb.builtin.shell.autocomplete.zsh import make_zsh_autocomplete
|
18
|
+
from zrb.builtin.todo import todo_add, todo_complete, todo_edit, todo_list, todo_log
|
2
19
|
|
3
|
-
assert
|
20
|
+
assert create_project
|
21
|
+
assert add_fastapp_to_project
|
22
|
+
assert get_shell_subcommands
|
23
|
+
assert make_bash_autocomplete
|
24
|
+
assert make_zsh_autocomplete
|
25
|
+
assert encode_base64
|
26
|
+
assert decode_base64
|
27
|
+
assert llm_chat
|
28
|
+
assert hash_md5
|
29
|
+
assert sum_md5
|
30
|
+
assert get_git_diff
|
31
|
+
assert prune_local_branches
|
32
|
+
assert format_python_code
|
33
|
+
assert git_commit
|
34
|
+
assert git_pull
|
35
|
+
assert git_push
|
36
|
+
assert git_add_subtree
|
37
|
+
assert git_pull_subtree
|
38
|
+
assert git_push_subtree
|
39
|
+
assert todo_list
|
40
|
+
assert todo_add
|
41
|
+
assert todo_edit
|
42
|
+
assert todo_complete
|
43
|
+
assert todo_log
|
zrb/builtin/base64.py
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
from zrb.builtin.group import base64_group
|
2
|
+
from zrb.context.any_context import AnyContext
|
3
|
+
from zrb.input.str_input import StrInput
|
4
|
+
from zrb.task.make_task import make_task
|
5
|
+
|
6
|
+
|
7
|
+
@make_task(
|
8
|
+
name="encode-base64",
|
9
|
+
input=StrInput(name="text", description="Text", prompt="Text to encode"),
|
10
|
+
description="🔐 Encode text to base64",
|
11
|
+
group=base64_group,
|
12
|
+
alias="encode",
|
13
|
+
)
|
14
|
+
def encode_base64(ctx: AnyContext) -> str:
|
15
|
+
import base64
|
16
|
+
|
17
|
+
result = base64.b64encode(ctx.input.text.encode()).decode()
|
18
|
+
ctx.print(result)
|
19
|
+
return result
|
20
|
+
|
21
|
+
|
22
|
+
@make_task(
|
23
|
+
name="decode-base64",
|
24
|
+
input=StrInput(name="text", description="Text", prompt="Text to encode"),
|
25
|
+
description="🔓 Decode base64 text",
|
26
|
+
group=base64_group,
|
27
|
+
alias="decode",
|
28
|
+
)
|
29
|
+
def decode_base64(ctx: AnyContext) -> str:
|
30
|
+
import base64
|
31
|
+
|
32
|
+
result = base64.b64decode(ctx.input.text.encode()).decode()
|
33
|
+
ctx.print(result)
|
34
|
+
return result
|
zrb/builtin/git.py
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
from zrb.builtin.group import git_branch_group, git_group
|
2
|
+
from zrb.context.any_context import AnyContext
|
3
|
+
from zrb.input.bool_input import BoolInput
|
4
|
+
from zrb.input.str_input import StrInput
|
5
|
+
from zrb.task.make_task import make_task
|
6
|
+
from zrb.util.cli.style import stylize_green, stylize_red, stylize_yellow
|
7
|
+
from zrb.util.git import (
|
8
|
+
add,
|
9
|
+
commit,
|
10
|
+
delete_branch,
|
11
|
+
get_branches,
|
12
|
+
get_current_branch,
|
13
|
+
get_diff,
|
14
|
+
pull,
|
15
|
+
push,
|
16
|
+
)
|
17
|
+
|
18
|
+
|
19
|
+
@make_task(
|
20
|
+
name="get-git-diff",
|
21
|
+
input=[
|
22
|
+
StrInput(
|
23
|
+
name="source",
|
24
|
+
description="Source branch/tag/commit",
|
25
|
+
prompt="Source branch/tag/commit",
|
26
|
+
default_str="main",
|
27
|
+
),
|
28
|
+
StrInput(
|
29
|
+
name="current",
|
30
|
+
description="Current branch/tag/commit",
|
31
|
+
prompt="Current branch/tag/commit",
|
32
|
+
default_str="HEAD",
|
33
|
+
),
|
34
|
+
BoolInput(
|
35
|
+
name="created",
|
36
|
+
description="Include created files",
|
37
|
+
prompt="Include created files",
|
38
|
+
default_str="True",
|
39
|
+
),
|
40
|
+
BoolInput(
|
41
|
+
name="removed",
|
42
|
+
description="Include removed files",
|
43
|
+
prompt="Include removed files",
|
44
|
+
default_str="True",
|
45
|
+
),
|
46
|
+
BoolInput(
|
47
|
+
name="updated",
|
48
|
+
description="Include updated files",
|
49
|
+
prompt="Include updated files",
|
50
|
+
default_str="True",
|
51
|
+
),
|
52
|
+
],
|
53
|
+
description="🔍 Get modified files",
|
54
|
+
group=git_group,
|
55
|
+
alias="diff",
|
56
|
+
)
|
57
|
+
def get_git_diff(ctx: AnyContext):
|
58
|
+
diff = get_diff(ctx.input.source, ctx.input.current)
|
59
|
+
result = []
|
60
|
+
decorated = []
|
61
|
+
if ctx.input.created and diff.created:
|
62
|
+
decorated += [stylize_green(f"++ {name}") for name in diff.created]
|
63
|
+
result += diff.created
|
64
|
+
if ctx.input.updated and diff.updated:
|
65
|
+
decorated += [stylize_yellow(f"+- {name}") for name in diff.updated]
|
66
|
+
result += diff.updated
|
67
|
+
if ctx.input.removed and diff.removed:
|
68
|
+
decorated += [stylize_red(f"-- {name}") for name in diff.removed]
|
69
|
+
result += diff.removed
|
70
|
+
if len(decorated) > 0:
|
71
|
+
decorated = [""] + decorated + [""]
|
72
|
+
ctx.print(
|
73
|
+
"\n" + "\n".join((f" {decorated_line}" for decorated_line in decorated))
|
74
|
+
)
|
75
|
+
return "\n".join(result)
|
76
|
+
|
77
|
+
|
78
|
+
@make_task(
|
79
|
+
name="prune-local-git-branches",
|
80
|
+
description="🧹 Prune local branches",
|
81
|
+
group=git_branch_group,
|
82
|
+
alias="prune",
|
83
|
+
)
|
84
|
+
def prune_local_branches(ctx: AnyContext):
|
85
|
+
branches = get_branches()
|
86
|
+
current_branch = get_current_branch()
|
87
|
+
for branch in branches:
|
88
|
+
if branch == current_branch or branch == "main" or branch == "master":
|
89
|
+
continue
|
90
|
+
ctx.print(stylize_yellow(f"Removing local branch: {branch}"))
|
91
|
+
try:
|
92
|
+
delete_branch(branch)
|
93
|
+
except Exception as e:
|
94
|
+
ctx.log_error(e)
|
95
|
+
|
96
|
+
|
97
|
+
@make_task(
|
98
|
+
name="git-commit",
|
99
|
+
input=StrInput(
|
100
|
+
name="message",
|
101
|
+
description="Commit message",
|
102
|
+
prompt="Commit message",
|
103
|
+
default_str="Add feature/fix bug",
|
104
|
+
),
|
105
|
+
description="📝 Commit changes",
|
106
|
+
group=git_group,
|
107
|
+
alias="commit",
|
108
|
+
)
|
109
|
+
def git_commit(ctx: AnyContext):
|
110
|
+
ctx.print("Add changes to staging")
|
111
|
+
add()
|
112
|
+
ctx.print("Commit changes")
|
113
|
+
try:
|
114
|
+
commit(ctx.input.message)
|
115
|
+
except Exception as e:
|
116
|
+
ctx.log_error(e)
|
117
|
+
|
118
|
+
|
119
|
+
@make_task(
|
120
|
+
name="git-pull",
|
121
|
+
description="📥 Pull changes from remote repository",
|
122
|
+
input=StrInput(
|
123
|
+
name="remote",
|
124
|
+
description="Remote name",
|
125
|
+
prompt="Remote name",
|
126
|
+
default_str="origin",
|
127
|
+
),
|
128
|
+
upstream=git_commit,
|
129
|
+
group=git_group,
|
130
|
+
alias="pull",
|
131
|
+
)
|
132
|
+
def git_pull(ctx: AnyContext):
|
133
|
+
remote = ctx.input.remote
|
134
|
+
current_branch = get_current_branch()
|
135
|
+
ctx.print(f"Pulling from {remote}/{current_branch}")
|
136
|
+
pull(remote, current_branch)
|
137
|
+
|
138
|
+
|
139
|
+
@make_task(
|
140
|
+
name="git-push",
|
141
|
+
description="📤 Push changes to remote repository",
|
142
|
+
input=StrInput(
|
143
|
+
name="remote",
|
144
|
+
description="Remote name",
|
145
|
+
prompt="Remote name",
|
146
|
+
default_str="origin",
|
147
|
+
),
|
148
|
+
upstream=git_commit,
|
149
|
+
group=git_group,
|
150
|
+
alias="push",
|
151
|
+
)
|
152
|
+
def git_push(ctx: AnyContext):
|
153
|
+
remote = ctx.input.remote
|
154
|
+
current_branch = get_current_branch()
|
155
|
+
ctx.print(f"Pushing to {remote}/{current_branch}")
|
156
|
+
push(remote, current_branch)
|
@@ -0,0 +1,88 @@
|
|
1
|
+
from zrb.builtin.git import git_commit
|
2
|
+
from zrb.builtin.group import git_subtree_group
|
3
|
+
from zrb.context.any_context import AnyContext
|
4
|
+
from zrb.input.str_input import StrInput
|
5
|
+
from zrb.task.make_task import make_task
|
6
|
+
from zrb.util.git_subtree import add_subtree, load_config, pull_subtree, push_subtree
|
7
|
+
|
8
|
+
|
9
|
+
@make_task(
|
10
|
+
name="git-add-subtree",
|
11
|
+
input=[
|
12
|
+
StrInput(
|
13
|
+
name="name", description="Subtree config name", prompt="Subtree config name"
|
14
|
+
),
|
15
|
+
StrInput(
|
16
|
+
name="repo-url", description="Subtree repo URL", prompt="Subtree repo URL"
|
17
|
+
),
|
18
|
+
StrInput(
|
19
|
+
name="repo-branch",
|
20
|
+
description="Subtree repo branch",
|
21
|
+
prompt="Subtree repo branch",
|
22
|
+
),
|
23
|
+
StrInput(
|
24
|
+
name="repo-prefix",
|
25
|
+
description="Subtree repo prefix",
|
26
|
+
prompt="Subtree repo prefix",
|
27
|
+
),
|
28
|
+
],
|
29
|
+
description="➕ Add subtree",
|
30
|
+
upstream=git_commit,
|
31
|
+
group=git_subtree_group,
|
32
|
+
alias="add",
|
33
|
+
)
|
34
|
+
def git_add_subtree(ctx: AnyContext):
|
35
|
+
add_subtree(
|
36
|
+
name=ctx.input.name,
|
37
|
+
repo_url=ctx.input["repo-url"],
|
38
|
+
branch=ctx.input["repo-branch"],
|
39
|
+
prefix=ctx.input["repo-prefix"],
|
40
|
+
)
|
41
|
+
|
42
|
+
|
43
|
+
@make_task(
|
44
|
+
name="git-pull-subtree",
|
45
|
+
description="📥 Pull subtree",
|
46
|
+
upstream=git_commit,
|
47
|
+
group=git_subtree_group,
|
48
|
+
alias="pull",
|
49
|
+
)
|
50
|
+
def git_pull_subtree(ctx: AnyContext):
|
51
|
+
config = load_config()
|
52
|
+
if not config.data:
|
53
|
+
raise ValueError("No subtree config found")
|
54
|
+
first_err: Exception | None = None
|
55
|
+
for name, detail in config.data.items():
|
56
|
+
try:
|
57
|
+
ctx.print(f"Pull from subtree {name}")
|
58
|
+
pull_subtree(detail.prefix, detail.repo_url, detail.branch)
|
59
|
+
except Exception as e:
|
60
|
+
if first_err is None:
|
61
|
+
first_err = e
|
62
|
+
ctx.log_error(e)
|
63
|
+
if first_err is not None:
|
64
|
+
raise first_err
|
65
|
+
|
66
|
+
|
67
|
+
@make_task(
|
68
|
+
name="git-push-subtree",
|
69
|
+
description="📤 Push subtree",
|
70
|
+
upstream=git_commit,
|
71
|
+
group=git_subtree_group,
|
72
|
+
alias="push",
|
73
|
+
)
|
74
|
+
def git_push_subtree(ctx: AnyContext):
|
75
|
+
config = load_config()
|
76
|
+
if not config.data:
|
77
|
+
raise ValueError("No subtree config found")
|
78
|
+
first_err: Exception | None = None
|
79
|
+
for name, detail in config.data.items():
|
80
|
+
try:
|
81
|
+
ctx.print(f"Push to subtree {name}")
|
82
|
+
push_subtree(detail.prefix, detail.repo_url, detail.branch)
|
83
|
+
except Exception as e:
|
84
|
+
if first_err is None:
|
85
|
+
first_err = e
|
86
|
+
ctx.log_error(e)
|
87
|
+
if first_err is not None:
|
88
|
+
raise first_err
|
zrb/builtin/group.py
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
from zrb.group.group import Group
|
2
|
+
from zrb.runner.cli import cli
|
3
|
+
|
4
|
+
base64_group = cli.add_group(Group(name="base64", description="📄 Base64 operations"))
|
5
|
+
git_group = cli.add_group(Group(name="git", description="🌱 Git related commands"))
|
6
|
+
git_branch_group = git_group.add_group(
|
7
|
+
Group(name="branch", description="🌿 Git branch related commands")
|
8
|
+
)
|
9
|
+
git_subtree_group = git_group.add_group(
|
10
|
+
Group(name="subtree", description="🌳 Git subtree related commands")
|
11
|
+
)
|
12
|
+
llm_group = cli.add_group(Group(name="llm", description="🤖 LLM operations"))
|
13
|
+
md5_group = cli.add_group(Group(name="md5", description="🔢 Md5 operations"))
|
14
|
+
python_group = cli.add_group(
|
15
|
+
Group(name="python", description="🐍 Python related commands")
|
16
|
+
)
|
17
|
+
todo_group = cli.add_group(Group(name="todo", description="✅ Todo management"))
|
18
|
+
|
19
|
+
shell_group = cli.add_group(
|
20
|
+
Group(name="shell", description="💬 Shell related commands")
|
21
|
+
)
|
22
|
+
shell_autocomplete_group: Group = shell_group.add_group(
|
23
|
+
Group(name="autocomplete", description="⌨️ Shell autocomplete related commands")
|
24
|
+
)
|
25
|
+
|
26
|
+
project_group = cli.add_group(
|
27
|
+
Group(name="project", description="📁 Project related commands")
|
28
|
+
)
|
29
|
+
add_to_project_group = project_group.add_group(
|
30
|
+
Group(name="add", description="➕ Add things to project")
|
31
|
+
)
|
32
|
+
add_fastapp_to_project_group = add_to_project_group.add_group(
|
33
|
+
Group(name="fastapp", description="🚀 Add Fastapp resources")
|
34
|
+
)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
from zrb.builtin.group import llm_group
|
2
|
+
from zrb.builtin.llm.tool.cli import run_shell_command
|
3
|
+
from zrb.builtin.llm.tool.web import open_web_page, query_internet
|
4
|
+
from zrb.config import (
|
5
|
+
LLM_ALLOW_ACCESS_SHELL,
|
6
|
+
LLM_ALLOW_ACCESS_WEB,
|
7
|
+
LLM_HISTORY_FILE,
|
8
|
+
LLM_MODEL,
|
9
|
+
LLM_SYSTEM_PROMPT,
|
10
|
+
)
|
11
|
+
from zrb.input.str_input import StrInput
|
12
|
+
from zrb.input.text_input import TextInput
|
13
|
+
from zrb.task.llm_task import LLMTask
|
14
|
+
|
15
|
+
llm_chat: LLMTask = llm_group.add_task(
|
16
|
+
LLMTask(
|
17
|
+
name="llm-chat",
|
18
|
+
input=[
|
19
|
+
StrInput(
|
20
|
+
"model",
|
21
|
+
description="LLM Model",
|
22
|
+
prompt="LLM Model",
|
23
|
+
default_str=LLM_MODEL,
|
24
|
+
),
|
25
|
+
StrInput(
|
26
|
+
"system-prompt",
|
27
|
+
description="System prompt",
|
28
|
+
prompt="System prompt",
|
29
|
+
default_str=LLM_SYSTEM_PROMPT,
|
30
|
+
),
|
31
|
+
TextInput("message", description="User message", prompt="Your message"),
|
32
|
+
],
|
33
|
+
history_file=LLM_HISTORY_FILE,
|
34
|
+
description="Chat with LLM",
|
35
|
+
model="{ctx.input.model}",
|
36
|
+
system_prompt="{ctx.input['system-prompt']}",
|
37
|
+
message="{ctx.input.message}",
|
38
|
+
),
|
39
|
+
alias="chat",
|
40
|
+
)
|
41
|
+
|
42
|
+
if LLM_ALLOW_ACCESS_SHELL:
|
43
|
+
llm_chat.add_tool(run_shell_command)
|
44
|
+
|
45
|
+
if LLM_ALLOW_ACCESS_WEB:
|
46
|
+
llm_chat.add_tool(open_web_page)
|
47
|
+
llm_chat.add_tool(query_internet)
|