machineconfig 6.82__py3-none-any.whl → 7.98__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.
- machineconfig/cluster/remote/cloud_manager.py +1 -1
- machineconfig/cluster/sessions_managers/utils/maker.py +25 -13
- machineconfig/cluster/sessions_managers/wt_local.py +16 -221
- machineconfig/cluster/sessions_managers/wt_local_manager.py +55 -193
- machineconfig/cluster/sessions_managers/wt_remote_manager.py +42 -198
- machineconfig/cluster/sessions_managers/wt_utils/manager_persistence.py +52 -0
- machineconfig/cluster/sessions_managers/wt_utils/monitoring_helpers.py +50 -0
- machineconfig/cluster/sessions_managers/wt_utils/status_reporting.py +76 -0
- machineconfig/cluster/sessions_managers/wt_utils/wt_helpers.py +199 -0
- machineconfig/cluster/sessions_managers/zellij_local_manager.py +3 -1
- machineconfig/cluster/sessions_managers/zellij_remote_manager.py +3 -2
- machineconfig/cluster/sessions_managers/zellij_utils/process_monitor.py +2 -2
- machineconfig/jobs/installer/custom/boxes.py +2 -2
- machineconfig/jobs/installer/custom/hx.py +75 -18
- machineconfig/jobs/installer/custom/yazi.py +119 -0
- machineconfig/jobs/installer/custom_dev/brave.py +5 -3
- machineconfig/jobs/installer/custom_dev/cloudflare_warp_cli.py +23 -0
- machineconfig/jobs/installer/custom_dev/code.py +4 -1
- machineconfig/jobs/installer/custom_dev/dubdb_adbc.py +1 -1
- machineconfig/jobs/installer/custom_dev/nerdfont.py +1 -1
- machineconfig/jobs/installer/custom_dev/nerfont_windows_helper.py +27 -22
- machineconfig/jobs/installer/custom_dev/sysabc.py +139 -0
- machineconfig/jobs/installer/custom_dev/wezterm.py +2 -19
- machineconfig/jobs/installer/custom_dev/winget.py +10 -14
- machineconfig/jobs/installer/installer_data.json +1287 -216
- machineconfig/jobs/installer/linux_scripts/q.sh +10 -7
- machineconfig/jobs/installer/linux_scripts/redis.sh +1 -0
- machineconfig/jobs/installer/package_groups.py +58 -89
- machineconfig/jobs/installer/powershell_scripts/install_fonts.ps1 +129 -34
- machineconfig/logger.py +0 -1
- machineconfig/profile/create_helper.py +43 -16
- machineconfig/profile/create_links.py +2 -1
- machineconfig/profile/create_links_export.py +64 -18
- machineconfig/profile/create_shell_profile.py +78 -127
- machineconfig/profile/mapper.toml +15 -8
- machineconfig/scripts/__init__.py +0 -4
- machineconfig/scripts/linux/wrap_mcfg +46 -0
- machineconfig/scripts/nu/wrap_mcfg.nu +69 -0
- machineconfig/scripts/python/agents.py +52 -37
- machineconfig/scripts/python/ai/initai.py +1 -1
- machineconfig/scripts/python/ai/scripts/command_runner.ps1 +33 -0
- machineconfig/scripts/python/ai/{command_runner → scripts}/command_runner.sh +1 -1
- machineconfig/scripts/python/ai/solutions/copilot/{chatmodes/Thinking-Beast-Mode.chatmode.md → agents/Thinking-Beast-Mode.agent.md} +0 -1
- machineconfig/scripts/python/ai/solutions/copilot/{chatmodes/Ultimate-Transparent-Thinking-Beast-Mode.chatmode.md → agents/Ultimate-Transparent-Thinking-Beast-Mode.agent.md} +0 -1
- machineconfig/scripts/python/ai/solutions/copilot/{chatmodes/deepResearch.chatmode.md → agents/deepResearch.agent.md} +2 -2
- machineconfig/scripts/python/ai/solutions/copilot/github_copilot.py +5 -5
- machineconfig/scripts/python/ai/solutions/copilot/instructions/python/dev.instructions.md +4 -0
- machineconfig/scripts/python/ai/solutions/copilot/instructions/python/watch_exec.prompt.md +20 -0
- machineconfig/scripts/python/ai/solutions/generic.py +1 -1
- machineconfig/scripts/python/ai/{generate_files.py → utils/generate_files.py} +2 -2
- machineconfig/scripts/python/ai/{vscode_tasks.py → utils/vscode_tasks.py} +7 -2
- machineconfig/scripts/python/croshell.py +77 -78
- machineconfig/scripts/python/devops.py +39 -21
- machineconfig/scripts/python/devops_navigator.py +0 -4
- machineconfig/scripts/python/env_manager/env_manager_tui.py +204 -0
- machineconfig/scripts/python/env_manager/path_manager_tui.py +1 -1
- machineconfig/scripts/python/fire_jobs.py +84 -115
- machineconfig/scripts/python/ftpx.py +42 -16
- machineconfig/scripts/python/helpers/ast_search.py +74 -0
- machineconfig/scripts/python/helpers/qr_code.py +166 -0
- machineconfig/scripts/python/helpers/repo_rag.py +325 -0
- machineconfig/scripts/python/helpers/run_py_script.py +79 -0
- machineconfig/scripts/python/helpers/symantic_search.py +25 -0
- machineconfig/scripts/python/helpers/tmp_py_scripts/a.py +26 -0
- machineconfig/scripts/python/{helpers_fire → helpers_agents}/agentic_frameworks/fire_crush.json +1 -1
- machineconfig/scripts/python/helpers_agents/agentic_frameworks/fire_crush.py +39 -0
- machineconfig/scripts/python/{helpers_fire → helpers_agents}/agentic_frameworks/fire_cursor_agents.py +3 -4
- machineconfig/scripts/python/helpers_agents/agentic_frameworks/fire_gemini.py +55 -0
- machineconfig/scripts/python/helpers_agents/agentic_frameworks/fire_qwen.py +30 -0
- machineconfig/scripts/python/{helpers_fire → helpers_agents}/fire_agents_help_launch.py +32 -13
- machineconfig/scripts/python/{helpers_fire → helpers_agents}/fire_agents_helper_types.py +11 -14
- machineconfig/scripts/python/helpers_agents/templates/prompt.txt +10 -0
- machineconfig/scripts/python/helpers_agents/templates/template.sh +32 -0
- machineconfig/scripts/python/helpers_cloud/cloud_copy.py +28 -21
- machineconfig/scripts/python/helpers_cloud/cloud_helpers.py +1 -1
- machineconfig/scripts/python/helpers_cloud/cloud_mount.py +19 -17
- machineconfig/scripts/python/helpers_cloud/cloud_sync.py +8 -7
- machineconfig/scripts/python/helpers_croshell/crosh.py +3 -3
- machineconfig/scripts/python/helpers_croshell/start_slidev.py +6 -7
- machineconfig/scripts/python/helpers_devops/cli_config.py +46 -61
- machineconfig/scripts/python/helpers_devops/cli_config_dotfile.py +67 -55
- machineconfig/scripts/python/helpers_devops/cli_nw.py +157 -16
- machineconfig/scripts/python/helpers_devops/cli_repos.py +55 -21
- machineconfig/scripts/python/helpers_devops/cli_self.py +98 -48
- machineconfig/scripts/python/helpers_devops/cli_share_file.py +137 -0
- machineconfig/scripts/python/helpers_devops/cli_share_server.py +80 -42
- machineconfig/scripts/python/helpers_devops/{cli_terminal.py → cli_share_terminal.py} +15 -17
- machineconfig/scripts/python/helpers_devops/cli_utils.py +3 -128
- machineconfig/scripts/python/helpers_devops/devops_backup_retrieve.py +4 -4
- machineconfig/scripts/python/helpers_devops/devops_status.py +7 -19
- machineconfig/scripts/python/helpers_devops/themes/choose_wezterm_theme.py +1 -1
- machineconfig/scripts/python/{helpers_fire/helpers4.py → helpers_fire_command/file_wrangler.py} +56 -20
- machineconfig/scripts/python/helpers_fire_command/fire_jobs_route_helper.py +26 -16
- machineconfig/scripts/python/helpers_msearch/__init__.py +5 -0
- machineconfig/scripts/{linux → python/helpers_msearch/scripts_linux}/fzfg +3 -3
- machineconfig/scripts/python/helpers_msearch/scripts_windows/fzfg.ps1 +59 -0
- machineconfig/scripts/python/helpers_navigator/command_tree.py +50 -18
- machineconfig/scripts/python/helpers_network/address.py +132 -0
- machineconfig/scripts/python/{nw → helpers_network}/devops_add_ssh_key.py +24 -5
- machineconfig/scripts/python/{nw → helpers_network}/mount_nfs +0 -1
- machineconfig/scripts/python/{nw → helpers_network}/mount_nfs.py +2 -2
- machineconfig/scripts/python/{nw → helpers_network}/mount_ssh.py +1 -1
- machineconfig/scripts/python/{nw → helpers_network}/ssh_debug_linux.py +7 -7
- machineconfig/scripts/python/{nw → helpers_network}/ssh_debug_windows.py +4 -4
- machineconfig/scripts/python/{nw → helpers_network}/wifi_conn.py +1 -53
- machineconfig/scripts/python/{nw → helpers_network}/wsl_windows_transfer.py +3 -2
- machineconfig/scripts/python/helpers_repos/clone.py +0 -1
- machineconfig/scripts/python/helpers_repos/cloud_repo_sync.py +46 -19
- machineconfig/scripts/python/helpers_repos/entrypoint.py +2 -1
- machineconfig/scripts/python/helpers_repos/grource.py +1 -1
- machineconfig/scripts/python/helpers_repos/record.py +2 -1
- machineconfig/scripts/python/helpers_repos/repo_analyzer_1.py +160 -0
- machineconfig/scripts/python/helpers_repos/{count_lines.py → repo_analyzer_2.py} +113 -192
- machineconfig/scripts/python/helpers_sessions/sessions_multiprocess.py +20 -13
- machineconfig/scripts/python/helpers_utils/download.py +150 -0
- machineconfig/scripts/python/helpers_utils/path.py +185 -0
- machineconfig/scripts/python/interactive.py +19 -26
- machineconfig/scripts/python/{mcfg.py → mcfg_entry.py} +10 -0
- machineconfig/scripts/python/msearch.py +71 -0
- machineconfig/scripts/python/sessions.py +94 -25
- machineconfig/scripts/python/terminal.py +133 -0
- machineconfig/scripts/python/utils.py +28 -30
- machineconfig/scripts/windows/mounts/mount_ssh.ps1 +1 -1
- machineconfig/scripts/windows/wrap_mcfg.ps1 +63 -0
- machineconfig/settings/broot/conf.toml +1 -1
- machineconfig/settings/helix/config.toml +16 -0
- machineconfig/settings/helix/languages.toml +13 -4
- machineconfig/settings/helix/yazi-picker.sh +12 -0
- machineconfig/settings/lf/linux/exe/lfcd.sh +1 -0
- machineconfig/settings/lf/linux/exe/previewer.sh +3 -2
- machineconfig/settings/lf/windows/lfcd.ps1 +1 -1
- machineconfig/settings/lf/windows/lfrc +14 -16
- machineconfig/settings/marimo/marimo.toml +1 -1
- machineconfig/settings/marimo/snippets/globalize.py +34 -0
- machineconfig/settings/shells/bash/init.sh +43 -11
- machineconfig/settings/shells/ipy/profiles/default/startup/playext.py +1 -1
- machineconfig/settings/shells/nushell/config.nu +2 -32
- machineconfig/settings/shells/nushell/env.nu +45 -6
- machineconfig/settings/shells/nushell/init.nu +314 -0
- machineconfig/settings/shells/pwsh/init.ps1 +40 -14
- machineconfig/settings/shells/starship/starship.toml +16 -0
- machineconfig/settings/shells/wezterm/wezterm.lua +2 -0
- machineconfig/settings/shells/wt/settings.json +14 -5
- machineconfig/settings/shells/zsh/init.sh +17 -19
- machineconfig/settings/television/cable_unix/alias.toml +8 -0
- machineconfig/settings/television/cable_unix/aws-buckets.toml +14 -0
- machineconfig/settings/television/cable_unix/aws-instances.toml +13 -0
- machineconfig/settings/television/cable_unix/bash-history.toml +8 -0
- machineconfig/settings/television/cable_unix/channels.toml +19 -0
- machineconfig/settings/television/cable_unix/dirs.toml +13 -0
- machineconfig/settings/television/cable_unix/distrobox-list.toml +42 -0
- machineconfig/settings/television/cable_unix/docker-images.toml +13 -0
- machineconfig/settings/television/cable_unix/dotfiles.toml +11 -0
- machineconfig/settings/television/cable_unix/env.toml +17 -0
- machineconfig/settings/television/cable_unix/files.toml +11 -0
- machineconfig/settings/television/cable_unix/fish-history.toml +8 -0
- machineconfig/settings/television/cable_unix/git-branch.toml +11 -0
- machineconfig/settings/television/cable_unix/git-diff.toml +10 -0
- machineconfig/settings/television/cable_unix/git-log.toml +12 -0
- machineconfig/settings/television/cable_unix/git-reflog.toml +12 -0
- machineconfig/settings/television/cable_unix/git-repos.toml +16 -0
- machineconfig/settings/television/cable_unix/guix.toml +20 -0
- machineconfig/settings/television/cable_unix/just-recipes.toml +18 -0
- machineconfig/settings/television/cable_unix/k8s-deployments.toml +36 -0
- machineconfig/settings/television/cable_unix/k8s-pods.toml +50 -0
- machineconfig/settings/television/cable_unix/k8s-services.toml +36 -0
- machineconfig/settings/television/cable_unix/man-pages.toml +24 -0
- machineconfig/settings/television/cable_unix/nu-history.toml +7 -0
- machineconfig/settings/television/cable_unix/procs.toml +20 -0
- machineconfig/settings/television/cable_unix/text.toml +17 -0
- machineconfig/settings/television/cable_unix/tldr.toml +18 -0
- machineconfig/settings/television/cable_unix/zsh-history.toml +9 -0
- machineconfig/settings/television/cable_windows/alias.toml +7 -0
- machineconfig/settings/television/cable_windows/dirs.toml +13 -0
- machineconfig/settings/television/cable_windows/docker-images.toml +13 -0
- machineconfig/settings/television/cable_windows/dotfiles.toml +11 -0
- machineconfig/settings/television/cable_windows/env.toml +17 -0
- machineconfig/settings/television/cable_windows/files.toml +14 -0
- machineconfig/settings/television/cable_windows/git-branch.toml +11 -0
- machineconfig/settings/television/cable_windows/git-diff.toml +10 -0
- machineconfig/settings/television/cable_windows/git-log.toml +11 -0
- machineconfig/settings/television/cable_windows/git-reflog.toml +11 -0
- machineconfig/settings/television/cable_windows/git-repos.toml +15 -0
- machineconfig/settings/television/cable_windows/nu-history.toml +7 -0
- machineconfig/settings/television/cable_windows/pwsh-history.toml +6 -0
- machineconfig/settings/television/cable_windows/text.toml +17 -0
- machineconfig/settings/yazi/init.lua +61 -0
- machineconfig/settings/yazi/keymap_linux.toml +94 -0
- machineconfig/settings/yazi/keymap_windows.toml +78 -0
- machineconfig/settings/yazi/shell/yazi_cd.ps1 +33 -0
- machineconfig/settings/yazi/shell/yazi_cd.sh +8 -0
- machineconfig/settings/yazi/theme.toml +4 -0
- machineconfig/settings/yazi/yazi_linux.toml +84 -0
- machineconfig/settings/yazi/yazi_windows.toml +58 -0
- machineconfig/setup_linux/__init__.py +2 -1
- machineconfig/setup_linux/web_shortcuts/interactive.sh +27 -12
- machineconfig/setup_linux/web_shortcuts/live_from_github.sh +31 -0
- machineconfig/setup_mac/__init__.py +2 -3
- machineconfig/setup_mac/apps_gui.sh +248 -0
- machineconfig/setup_windows/__init__.py +3 -3
- machineconfig/setup_windows/uv.ps1 +8 -1
- machineconfig/setup_windows/web_shortcuts/interactive.ps1 +26 -11
- machineconfig/setup_windows/web_shortcuts/live_from_github.ps1 +30 -0
- machineconfig/setup_windows/web_shortcuts/quick_init.ps1 +17 -0
- machineconfig/utils/accessories.py +7 -4
- machineconfig/utils/code.py +99 -32
- machineconfig/utils/files/ascii_art.py +1 -1
- machineconfig/utils/files/headers.py +3 -2
- machineconfig/utils/installer_utils/github_release_bulk.py +156 -119
- machineconfig/utils/installer_utils/install_from_url.py +183 -0
- machineconfig/utils/installer_utils/installer_class.py +42 -99
- machineconfig/utils/installer_utils/installer_cli.py +175 -0
- machineconfig/utils/installer_utils/installer_helper.py +129 -0
- machineconfig/utils/installer_utils/{installer_abc.py → installer_locator_utils.py} +36 -85
- machineconfig/utils/{installer.py → installer_utils/installer_runner.py} +16 -61
- machineconfig/utils/io.py +69 -1
- machineconfig/utils/links.py +56 -38
- machineconfig/utils/meta.py +33 -18
- machineconfig/utils/options.py +46 -18
- machineconfig/utils/options_tv.py +119 -0
- machineconfig/utils/path_extended.py +44 -95
- machineconfig/utils/path_helper.py +76 -23
- machineconfig/utils/procs.py +1 -1
- machineconfig/utils/scheduler.py +20 -53
- machineconfig/utils/scheduling.py +0 -2
- machineconfig/utils/schemas/fire_agents/fire_agents_input.py +1 -1
- machineconfig/utils/schemas/layouts/layout_types.py +1 -1
- machineconfig/utils/ssh.py +159 -412
- machineconfig/utils/ssh_utils/abc.py +5 -0
- machineconfig/utils/ssh_utils/copy_from_here.py +111 -0
- machineconfig/utils/ssh_utils/copy_to_here.py +302 -0
- machineconfig/utils/ssh_utils/utils.py +142 -0
- machineconfig/utils/ssh_utils/wsl.py +210 -0
- machineconfig/utils/terminal.py +1 -0
- machineconfig/utils/upgrade_packages.py +104 -28
- machineconfig/utils/ve.py +12 -4
- machineconfig-7.98.dist-info/METADATA +132 -0
- {machineconfig-6.82.dist-info → machineconfig-7.98.dist-info}/RECORD +259 -196
- {machineconfig-6.82.dist-info → machineconfig-7.98.dist-info}/entry_points.txt +4 -1
- machineconfig/jobs/installer/linux_scripts/pgsql.sh +0 -41
- machineconfig/jobs/installer/linux_scripts/timescaledb.sh +0 -71
- machineconfig/jobs/installer/powershell_scripts/archive_pygraphviz.ps1 +0 -12
- machineconfig/scripts/linux/fzf2g +0 -21
- machineconfig/scripts/linux/fzfag +0 -17
- machineconfig/scripts/linux/fzffg +0 -25
- machineconfig/scripts/linux/fzfrga +0 -21
- machineconfig/scripts/linux/mcfgs +0 -38
- machineconfig/scripts/linux/other/share_smb +0 -1
- machineconfig/scripts/linux/skrg +0 -4
- machineconfig/scripts/linux/warp-cli.sh +0 -122
- machineconfig/scripts/linux/z_ls +0 -104
- machineconfig/scripts/python/ai/command_runner/prompt.txt +0 -9
- machineconfig/scripts/python/helpers_fire/agentic_frameworks/fire_crush.py +0 -37
- machineconfig/scripts/python/helpers_fire/agentic_frameworks/fire_gemini.py +0 -44
- machineconfig/scripts/python/helpers_fire/agentic_frameworks/fire_qwen.py +0 -43
- machineconfig/scripts/python/helpers_fire/prompt.txt +0 -2
- machineconfig/scripts/python/helpers_fire/template.sh +0 -15
- machineconfig/scripts/python/helpers_repos/count_lines_frontend.py +0 -17
- machineconfig/scripts/python/helpers_repos/secure_repo.py +0 -15
- machineconfig/scripts/python/nw/add_ssh_key.py +0 -148
- machineconfig/scripts/windows/fzfb.ps1 +0 -3
- machineconfig/scripts/windows/fzfg.ps1 +0 -2
- machineconfig/scripts/windows/fzfrga.bat +0 -20
- machineconfig/scripts/windows/mcfgs.ps1 +0 -17
- machineconfig/settings/lf/linux/exe/fzf_nano.sh +0 -16
- machineconfig/settings/lf/windows/fzf_edit.ps1 +0 -6
- machineconfig/settings/lf/windows/tst.ps1 +0 -1
- machineconfig/settings/yazi/yazi.toml +0 -4
- machineconfig/setup_linux/apps.sh +0 -66
- machineconfig/setup_linux/others/cli_installation.sh +0 -137
- machineconfig/setup_mac/apps.sh +0 -73
- machineconfig/setup_windows/apps.ps1 +0 -62
- machineconfig/utils/installer_utils/installer.py +0 -225
- machineconfig-6.82.dist-info/METADATA +0 -82
- /machineconfig/jobs/installer/linux_scripts/{warp-cli.sh → cloudflare_warp_cli.sh} +0 -0
- /machineconfig/scripts/python/{helpers_fire → ai/utils}/__init__.py +0 -0
- /machineconfig/scripts/python/{helpers_fire/agentic_frameworks → helpers_agents}/__init__.py +0 -0
- /machineconfig/scripts/python/{nw → helpers_agents/agentic_frameworks}/__init__.py +0 -0
- /machineconfig/scripts/python/{helpers_fire → helpers_agents}/fire_agents_help_search.py +0 -0
- /machineconfig/scripts/python/{helpers_fire → helpers_agents}/fire_agents_load_balancer.py +0 -0
- /machineconfig/scripts/python/{helpers_fire → helpers_agents/templates}/template.ps1 +0 -0
- /machineconfig/{settings/shells/pwsh/profile.ps1 → scripts/python/helpers_fire_command/f.py} +0 -0
- /machineconfig/{settings/yazi/keymap.toml → scripts/python/helpers_network/__init__.py} +0 -0
- /machineconfig/scripts/python/{nw → helpers_network}/devops_add_identity.py +0 -0
- /machineconfig/scripts/python/{nw → helpers_network}/mount_drive +0 -0
- /machineconfig/scripts/python/{nw → helpers_network}/mount_nw_drive +0 -0
- /machineconfig/scripts/python/{nw → helpers_network}/mount_nw_drive.py +0 -0
- /machineconfig/scripts/python/{nw → helpers_network}/mount_smb +0 -0
- /machineconfig/scripts/python/{nw → helpers_network}/onetimeshare.py +0 -0
- /machineconfig/scripts/{Restore-ThunderbirdProfile.ps1 → windows/mounts/Restore-ThunderbirdProfile.ps1} +0 -0
- /machineconfig/{jobs/installer/powershell_scripts → setup_windows/ssh}/openssh-server_add_key.ps1 +0 -0
- /machineconfig/{jobs/installer/powershell_scripts → setup_windows/ssh}/openssh-server_copy-ssh-id.ps1 +0 -0
- {machineconfig-6.82.dist-info → machineconfig-7.98.dist-info}/WHEEL +0 -0
- {machineconfig-6.82.dist-info → machineconfig-7.98.dist-info}/top_level.txt +0 -0
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
"""shell"""
|
|
2
2
|
|
|
3
|
-
from machineconfig.utils.path_extended import PathExtended
|
|
4
|
-
from machineconfig.utils.source_of_truth import CONFIG_ROOT
|
|
5
3
|
from pathlib import Path
|
|
6
|
-
import platform
|
|
7
|
-
import os
|
|
8
|
-
import subprocess
|
|
9
|
-
from rich.console import Console
|
|
10
|
-
from rich.panel import Panel
|
|
11
4
|
|
|
12
5
|
|
|
13
|
-
system = platform.system()
|
|
14
|
-
sep = ";" if system == "Windows" else ":" # PATH separator, this is special for PATH object, not to be confused with PathExtended.sep (normal paths), usually / or \
|
|
15
|
-
PATH = os.environ["PATH"].split(sep)
|
|
16
|
-
console = Console()
|
|
17
|
-
BOX_WIDTH = 100 # Define BOX_WIDTH or get it from a config
|
|
18
|
-
|
|
19
6
|
|
|
20
7
|
def get_shell_profile_path() -> Path:
|
|
8
|
+
import platform
|
|
9
|
+
import subprocess
|
|
10
|
+
from rich.console import Console
|
|
11
|
+
from rich.panel import Panel
|
|
12
|
+
system = platform.system()
|
|
13
|
+
console = Console()
|
|
21
14
|
if system == "Windows":
|
|
22
15
|
result = subprocess.run(["pwsh", "-Command", "$PROFILE"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=False)
|
|
23
16
|
if result.returncode == 0 and result.stdout.strip():
|
|
@@ -37,8 +30,34 @@ def get_shell_profile_path() -> Path:
|
|
|
37
30
|
return profile_path
|
|
38
31
|
|
|
39
32
|
|
|
33
|
+
def get_nu_shell_profile_path() -> Path:
|
|
34
|
+
import platform
|
|
35
|
+
from rich.console import Console
|
|
36
|
+
from rich.panel import Panel
|
|
37
|
+
system = platform.system()
|
|
38
|
+
console = Console()
|
|
39
|
+
if system == "Windows":
|
|
40
|
+
profile_path = Path.home().joinpath(r"AppData\Roaming\nushell")
|
|
41
|
+
elif system == "Linux":
|
|
42
|
+
profile_path = Path.home().joinpath(".config/nushell")
|
|
43
|
+
elif system == "Darwin":
|
|
44
|
+
profile_path = Path.home().joinpath("Library/Application Support/nushell")
|
|
45
|
+
else:
|
|
46
|
+
raise ValueError(f"""Not implemented for this system {system}""")
|
|
47
|
+
console.print(Panel(f"""🐚 NU SHELL PROFILE | Working with path: `{profile_path}`""", title="[bold cyan]Nu Shell Profile[/bold cyan]", border_style="cyan"))
|
|
48
|
+
return profile_path
|
|
49
|
+
|
|
50
|
+
|
|
40
51
|
def create_default_shell_profile() -> None:
|
|
41
52
|
shell_profile_path = get_shell_profile_path()
|
|
53
|
+
import platform
|
|
54
|
+
import subprocess
|
|
55
|
+
from rich.console import Console
|
|
56
|
+
from rich.panel import Panel
|
|
57
|
+
from machineconfig.utils.source_of_truth import CONFIG_ROOT
|
|
58
|
+
from machineconfig.utils.path_extended import PathExtended
|
|
59
|
+
system = platform.system()
|
|
60
|
+
console = Console()
|
|
42
61
|
if not shell_profile_path.exists():
|
|
43
62
|
console.print(Panel(f"""🆕 PROFILE | Profile does not exist at `{shell_profile_path}`. Creating a new one.""", title="[bold blue]Profile[/bold blue]", border_style="blue"))
|
|
44
63
|
shell_profile_path.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -47,13 +66,17 @@ def create_default_shell_profile() -> None:
|
|
|
47
66
|
from machineconfig.profile.create_helper import copy_assets_to_machine
|
|
48
67
|
copy_assets_to_machine("settings") # init.ps1 or init.sh live here
|
|
49
68
|
copy_assets_to_machine("scripts") # init scripts are going to reference those scripts.
|
|
69
|
+
shell_name = ""
|
|
50
70
|
if system == "Windows":
|
|
71
|
+
shell_name = "pwsh"
|
|
51
72
|
init_script = PathExtended(CONFIG_ROOT).joinpath("settings/shells/pwsh/init.ps1")
|
|
52
73
|
source_line = f""". {str(init_script.collapseuser(placeholder="$HOME"))}"""
|
|
53
74
|
elif system == "Linux":
|
|
75
|
+
shell_name = "bash"
|
|
54
76
|
init_script = PathExtended(CONFIG_ROOT).joinpath("settings/shells/bash/init.sh")
|
|
55
77
|
source_line = f"""source {str(init_script.collapseuser(placeholder="$HOME"))}"""
|
|
56
78
|
elif system == "Darwin":
|
|
79
|
+
shell_name = "zsh"
|
|
57
80
|
init_script = PathExtended(CONFIG_ROOT).joinpath("settings/shells/zsh/init.sh")
|
|
58
81
|
source_line = f"""source {str(init_script.collapseuser(placeholder="$HOME"))}"""
|
|
59
82
|
else:
|
|
@@ -61,17 +84,24 @@ def create_default_shell_profile() -> None:
|
|
|
61
84
|
|
|
62
85
|
was_shell_updated = False
|
|
63
86
|
if source_line in shell_profile:
|
|
64
|
-
console.print(Panel("🔄 PROFILE | Skipping init script sourcing - already present in profile", title="[bold blue]Profile[/bold blue]", border_style="blue"))
|
|
87
|
+
console.print(Panel("🔄 PROFILE | Skipping init script sourcing - already present in profile", title="[bold blue]Profile[/bold blue]", border_style="blue"))
|
|
65
88
|
else:
|
|
66
89
|
console.print(Panel("📝 PROFILE | Adding init script sourcing to profile", title="[bold blue]Profile[/bold blue]", border_style="blue"))
|
|
67
90
|
shell_profile += "\n" + source_line + "\n"
|
|
68
|
-
if
|
|
91
|
+
if shell_name == "bash":
|
|
69
92
|
result = subprocess.run(["cat", "/proc/version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=False)
|
|
70
93
|
if result.returncode == 0 and result.stdout:
|
|
71
94
|
version_info = result.stdout.lower()
|
|
72
|
-
|
|
95
|
+
is_wsl = "microsoft" in version_info or "wsl" in version_info
|
|
96
|
+
if is_wsl:
|
|
73
97
|
shell_profile += "\ncd $HOME"
|
|
74
98
|
console.print("📌 WSL detected - adding 'cd $HOME' to profile to avoid Windows filesystem")
|
|
99
|
+
# Sync shell history between Windows and WSL
|
|
100
|
+
# https://www.hanselman.com/blog/sharing-powershell-history-between-windows-and-wsl
|
|
101
|
+
shell_profile += """
|
|
102
|
+
# Sync shell history between Windows and WSL
|
|
103
|
+
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\\n'}history -a; history -c; history -r"
|
|
104
|
+
"""
|
|
75
105
|
was_shell_updated = True
|
|
76
106
|
if was_shell_updated:
|
|
77
107
|
shell_profile_path.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -79,117 +109,38 @@ def create_default_shell_profile() -> None:
|
|
|
79
109
|
console.print(Panel("✅ Profile updated successfully", title="[bold blue]Profile[/bold blue]", border_style="blue"))
|
|
80
110
|
|
|
81
111
|
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
# console.print(Panel("🔄 Adding sources to shell profile", title="[bold blue]Sources[/bold blue]", border_style="blue"))
|
|
115
|
-
|
|
116
|
-
# if choice is None:
|
|
117
|
-
# choice_obj = choose_from_options(msg="Which patch to add?", options=sources + ["all", "none(EXIT)"], default="none(EXIT)", multi=True)
|
|
118
|
-
# if isinstance(choice_obj, str):
|
|
119
|
-
# if choice_obj == "all":
|
|
120
|
-
# choice = choice_obj
|
|
121
|
-
# elif choice_obj == "none(EXIT)":
|
|
122
|
-
# return
|
|
123
|
-
# else:
|
|
124
|
-
# sources = [choice_obj]
|
|
125
|
-
# else: # isinstance(choice_obj, list):
|
|
126
|
-
# sources = choice_obj
|
|
127
|
-
# elif choice == "none(EXIT)":
|
|
128
|
-
# return
|
|
129
|
-
|
|
130
|
-
# if isinstance(profile_path, str):
|
|
131
|
-
# profile_path_obj = PathExtended(profile_path)
|
|
132
|
-
# else:
|
|
133
|
-
# profile_path_obj = get_shell_profile_path()
|
|
134
|
-
# profile = profile_path_obj.read_text(encoding="utf-8")
|
|
135
|
-
|
|
136
|
-
# for a_file in sources:
|
|
137
|
-
# tmp = a_file.replace("REPO_ROOT", REPO_ROOT.as_posix()).replace("LIBRARY_ROOT", LIBRARY_ROOT.as_posix())
|
|
138
|
-
# file = PathExtended(tmp).collapseuser() # this makes the shell profile interuseable across machines.
|
|
139
|
-
# file = file.as_posix() if system == "Linux" else str(file)
|
|
140
|
-
# if file not in profile:
|
|
141
|
-
# if system == "Windows":
|
|
142
|
-
# profile += f"\n. {file}"
|
|
143
|
-
# console.print(f"➕ Added PowerShell source: {file}")
|
|
144
|
-
# elif system == "Linux":
|
|
145
|
-
# profile += f"\nsource {file}"
|
|
146
|
-
# console.print(f"➕ Added Bash source: {file}")
|
|
147
|
-
# else:
|
|
148
|
-
# raise ValueError(f"Not implemented for this system {system}")
|
|
149
|
-
# else:
|
|
150
|
-
# console.print(f"⏭️ Source already present: {file}")
|
|
151
|
-
|
|
152
|
-
# profile_path_obj.write_text(profile, encoding="utf-8")
|
|
153
|
-
# console.print(Panel("✅ Shell profile updated with sources", title="[bold blue]Sources[/bold blue]", border_style="blue"))
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
# def main_add_patches_to_shell_profile(profile_path: Optional[str], choice: Optional[str]) -> None:
|
|
157
|
-
# patches: list[str] = [item.as_posix() for item in PathExtended(LIBRARY_ROOT).joinpath(f"profile/patches/{system.lower()}").search()]
|
|
158
|
-
|
|
159
|
-
# console.print(Panel("🩹 Adding patches to shell profile", title="[bold blue]Patches[/bold blue]", border_style="blue"))
|
|
160
|
-
|
|
161
|
-
# if choice is None:
|
|
162
|
-
# choice_chosen = choose_from_options(msg="Which patch to add?", options=list(patches) + ["all", "none(EXIT)"], default="none(EXIT)", multi=False)
|
|
163
|
-
# assert isinstance(choice_chosen, str), f"Choice must be a string or a list of strings, not {type(choice)}"
|
|
164
|
-
# choice = choice_chosen
|
|
165
|
-
# if choice == "none(EXIT)":
|
|
166
|
-
# return None
|
|
167
|
-
# elif str(choice) == "all":
|
|
168
|
-
# console.print("📌 Adding all patches to profile")
|
|
169
|
-
# else:
|
|
170
|
-
# patches = [choice]
|
|
171
|
-
# console.print(f"📌 Adding selected patch: {choice}")
|
|
172
|
-
|
|
173
|
-
# profile_path_obj = PathExtended(profile_path) if isinstance(profile_path, str) else get_shell_profile_path()
|
|
174
|
-
# profile = profile_path_obj.read_text(encoding="utf-8")
|
|
175
|
-
|
|
176
|
-
# for patch_path in patches:
|
|
177
|
-
# patch_path_obj = PathExtended(patch_path)
|
|
178
|
-
# patch = patch_path_obj.read_text(encoding="utf-8")
|
|
179
|
-
# if patch in profile:
|
|
180
|
-
# console.print(f"⏭️ Patch already present: {patch_path_obj.name}")
|
|
181
|
-
# else:
|
|
182
|
-
# profile += "\n" + patch
|
|
183
|
-
# console.print(f"➕ Added patch: {patch_path_obj.name}")
|
|
184
|
-
|
|
185
|
-
# if system == "Linux":
|
|
186
|
-
# res = Terminal().run("cat /proc/version").op
|
|
187
|
-
# if "microsoft" in res.lower() or "wsl" in res.lower():
|
|
188
|
-
# profile += "\ncd ~" # this is to make sure that the current dir is not in the windows file system, which is terribly slow and its a bad idea to be there anyway.
|
|
189
|
-
# console.print("📌 WSL detected - adding 'cd ~' to profile to avoid Windows filesystem")
|
|
190
|
-
|
|
191
|
-
# profile_path_obj.write_text(profile, encoding="utf-8")
|
|
192
|
-
# console.print(Panel("✅ Shell profile updated with patches", title="[bold blue]Patches[/bold blue]", border_style="blue"))
|
|
112
|
+
def create_nu_shell_profile() -> None:
|
|
113
|
+
from rich.console import Console
|
|
114
|
+
from rich.panel import Panel
|
|
115
|
+
from machineconfig.utils.source_of_truth import CONFIG_ROOT
|
|
116
|
+
from machineconfig.utils.path_extended import PathExtended
|
|
117
|
+
console = Console()
|
|
118
|
+
nu_profile_path = get_nu_shell_profile_path()
|
|
119
|
+
config_dir = nu_profile_path
|
|
120
|
+
config_file = config_dir.joinpath("config.nu")
|
|
121
|
+
if not config_dir.exists():
|
|
122
|
+
console.print(Panel(f"""🆕 NU SHELL CONFIG | Config directory does not exist at `{config_dir}`. Creating a new one.""", title="[bold cyan]Nu Shell Config[/bold cyan]", border_style="cyan"))
|
|
123
|
+
config_dir.mkdir(parents=True, exist_ok=True)
|
|
124
|
+
if not config_file.exists():
|
|
125
|
+
console.print(Panel(f"""🆕 NU SHELL CONFIG | config.nu file does not exist at `{config_file}`. Creating a new one.""", title="[bold cyan]Nu Shell Config[/bold cyan]", border_style="cyan"))
|
|
126
|
+
config_file.write_text("", encoding="utf-8")
|
|
127
|
+
config_content = config_file.read_text(encoding="utf-8")
|
|
128
|
+
from machineconfig.profile.create_helper import copy_assets_to_machine
|
|
129
|
+
copy_assets_to_machine("settings")
|
|
130
|
+
copy_assets_to_machine("scripts")
|
|
131
|
+
init_script = PathExtended(CONFIG_ROOT).joinpath("settings/shells/nushell/init.nu")
|
|
132
|
+
source_line = f"""use {str(init_script)}"""
|
|
133
|
+
was_config_updated = False
|
|
134
|
+
if source_line in config_content:
|
|
135
|
+
console.print(Panel("🔄 NU SHELL CONFIG | Skipping init script sourcing - already present in config.nu", title="[bold cyan]Nu Shell Config[/bold cyan]", border_style="cyan"))
|
|
136
|
+
else:
|
|
137
|
+
console.print(Panel("📝 NU SHELL CONFIG | Adding init script sourcing to config.nu", title="[bold cyan]Nu Shell Config[/bold cyan]", border_style="cyan"))
|
|
138
|
+
config_content += "\n" + source_line + "\n"
|
|
139
|
+
was_config_updated = True
|
|
140
|
+
if was_config_updated:
|
|
141
|
+
config_dir.mkdir(parents=True, exist_ok=True)
|
|
142
|
+
config_file.write_text(config_content, encoding="utf-8")
|
|
143
|
+
console.print(Panel("✅ Nu shell config updated successfully", title="[bold cyan]Nu Shell Config[/bold cyan]", border_style="cyan"))
|
|
193
144
|
|
|
194
145
|
|
|
195
146
|
if __name__ == "__main__":
|
|
@@ -33,9 +33,6 @@ config2 = {this = '~/.cli-m365-all-connections.json', to_this = '~/dotfiles/cred
|
|
|
33
33
|
config3 = {this = '~/.cli-m365-connection.json', to_this = '~/dotfiles/creds/tokens/.cli-m365-connection.json'}
|
|
34
34
|
# config2 = {this = '~/.cli-m365-tokens.json', to_this = '~/dotfiles/creds/tokens/.cli-m365-tokens.json'}
|
|
35
35
|
|
|
36
|
-
# [bash_linux]
|
|
37
|
-
# bashrc = {this = '~/.inputrc', to_this = '~/dotfiles/shells/bash/.inputrc'}
|
|
38
|
-
|
|
39
36
|
[remmina]
|
|
40
37
|
data = {this = '~/.var/app/org.remmina.Remmina/data/remmina', to_this = '~/dotfiles/creds/RDP/remmina/data/remmina'}
|
|
41
38
|
|
|
@@ -97,14 +94,23 @@ config_again = {this = '~/.config/procs/config.toml', to_this = 'CONFIG_ROOT/set
|
|
|
97
94
|
config = {this = '~/.config/rofi/config.rasi', to_this = 'CONFIG_ROOT/settings/rofi/config.rasi'}
|
|
98
95
|
|
|
99
96
|
[yazi_windows]
|
|
100
|
-
yazi = {this = '~/AppData/Roaming/yazi/config/yazi.toml', to_this = 'CONFIG_ROOT/settings/yazi/
|
|
101
|
-
keymap = {this = '~/AppData/Roaming/yazi/config/keymap.toml', to_this = 'CONFIG_ROOT/settings/yazi/
|
|
97
|
+
yazi = {this = '~/AppData/Roaming/yazi/config/yazi.toml', to_this = 'CONFIG_ROOT/settings/yazi/yazi_windows.toml'}
|
|
98
|
+
keymap = {this = '~/AppData/Roaming/yazi/config/keymap.toml', to_this = 'CONFIG_ROOT/settings/yazi/keymap_windows.toml'}
|
|
102
99
|
theme = {this = '~/AppData/Roaming/yazi/config/theme.toml', to_this = 'CONFIG_ROOT/settings/yazi/theme.toml'}
|
|
100
|
+
init = {this = '~/AppData/Roaming/yazi/config/init.lua', to_this = 'CONFIG_ROOT/settings/yazi/init.lua'}
|
|
101
|
+
|
|
102
|
+
[television_linux]
|
|
103
|
+
cable = {this = '~/.config/television/cable', to_this = 'CONFIG_ROOT/settings/television/cable_unix', contents = true}
|
|
104
|
+
|
|
105
|
+
[television_windows]
|
|
106
|
+
cable = {this = '~/AppData/Local/television/config/cable', to_this = 'CONFIG_ROOT/settings/television/cable_windows', contents = true}
|
|
107
|
+
|
|
103
108
|
|
|
104
109
|
[yazi_linux]
|
|
105
|
-
yazi = {this = '~/.config/yazi/yazi.toml', to_this = 'CONFIG_ROOT/settings/yazi/
|
|
106
|
-
keymap = {this = '~/.config/yazi/keymap.toml', to_this = 'CONFIG_ROOT/settings/yazi/
|
|
110
|
+
yazi = {this = '~/.config/yazi/yazi.toml', to_this = 'CONFIG_ROOT/settings/yazi/yazi_linux.toml'}
|
|
111
|
+
keymap = {this = '~/.config/yazi/keymap.toml', to_this = 'CONFIG_ROOT/settings/yazi/keymap_linux.toml'}
|
|
107
112
|
theme = {this = '~/.config/yazi/theme.toml', to_this = 'CONFIG_ROOT/settings/yazi/theme.toml'}
|
|
113
|
+
init = {this = '~/.config/yazi/init.lua', to_this = 'CONFIG_ROOT/settings/yazi/init.lua'}
|
|
108
114
|
|
|
109
115
|
[lf_windows]
|
|
110
116
|
config = {this = '~/AppData/Local/lf/lfrc', to_this = 'CONFIG_ROOT/settings/lf/windows/lfrc'}
|
|
@@ -162,7 +168,7 @@ config = {this = '~/.config/pudb/pudb.cfg', to_this = 'CONFIG_ROOT/settings/pudb
|
|
|
162
168
|
# AllUsersCurrentHost = {this = 'C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1', to_this = '~/dotfiles/shells/powershell/AllUsersCurrentHost/Microsoft.PowerShell_profile.ps1'}
|
|
163
169
|
# AllUsersAllHosts = {this = 'C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1', to_this = '~/dotfiles/shells/windows_powershell/AllUsersAllHosts/profile.ps1'}
|
|
164
170
|
|
|
165
|
-
[pwsh_windows]
|
|
171
|
+
# [pwsh_windows]
|
|
166
172
|
# CurrentUserCurrentHost = {this = '~/Documents/PowerShell/Microsoft.PowerShell_profile.ps1', to_this = 'CONFIG_ROOT/settings/shells/pwsh/init.ps1'}
|
|
167
173
|
# CurrentUserAllHosts = {this = '~/Documents/PowerShell/profile.ps1', to_this = 'CONFIG_ROOT/settings/shells/pwsh/profile.ps1'}
|
|
168
174
|
# AllUsersCurrentHost = {this = 'C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1', to_this = 'CONFIG_ROOT/settings/shells/pwsh/init.ps1'}
|
|
@@ -225,6 +231,7 @@ config = { this = '~/AppData/Roaming/helix/config.toml', to_this = 'CONFIG_ROOT/
|
|
|
225
231
|
[helix_linux]
|
|
226
232
|
languages = { this = '~/.config/helix/languages.toml', to_this = 'CONFIG_ROOT/settings/helix/languages.toml' }
|
|
227
233
|
config = { this = '~/.config/helix/config.toml', to_this = 'CONFIG_ROOT/settings/helix/config.toml' }
|
|
234
|
+
yazi_picker = { this = '~/.config/helix/yazi-picker.sh', to_this = 'CONFIG_ROOT/settings/helix/yazi-picker.sh' }
|
|
228
235
|
|
|
229
236
|
[lvim_windows]
|
|
230
237
|
config = { this = '~/AppData/Local/lvim/config.lua', to_this = 'CONFIG_ROOT/settings/lvim/windows/config.lua' }
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
wrap_in_shell_script() {
|
|
5
|
+
# set -euo pipefail
|
|
6
|
+
# ANSI color/style codes
|
|
7
|
+
# BOLD="\033[1m"
|
|
8
|
+
# RESET="\033[0m"
|
|
9
|
+
# GREEN="\033[32m"
|
|
10
|
+
# YELLOW="\033[33m"
|
|
11
|
+
# BLUE="\033[34m"
|
|
12
|
+
# RED="\033[31m"
|
|
13
|
+
|
|
14
|
+
local command="$1"
|
|
15
|
+
shift
|
|
16
|
+
local RANDOM_NAME=$(LC_ALL=C tr -dc 'A-Za-z0-9' </dev/urandom | head -c 12)
|
|
17
|
+
local OP_DIR="$HOME/tmp_results/tmp_scripts/machineconfig"
|
|
18
|
+
local OP_PROGRAM_PATH="$OP_DIR/${RANDOM_NAME}.sh"
|
|
19
|
+
export OP_PROGRAM_PATH
|
|
20
|
+
# local timestamp=$(date -u +"%Y-%m-%d %H:%M:%SZ")
|
|
21
|
+
# printf "%b\n" "${BOLD}${BLUE}🛠️ machineconfig — running ${command}${RESET}"
|
|
22
|
+
# printf "%b\n" "${BLUE}Timestamp:${RESET} ${timestamp}"
|
|
23
|
+
# printf "%b\n" "${BLUE}Op program path:${RESET} ${OP_PROGRAM_PATH}"
|
|
24
|
+
# Forward arguments to the command
|
|
25
|
+
"$command" "$@"
|
|
26
|
+
if [[ -f "$OP_PROGRAM_PATH" ]]; then
|
|
27
|
+
printf "%b\n" "🚀 Taking over from python script @ ${OP_PROGRAM_PATH}${RESET}"
|
|
28
|
+
bat --style=full --theme=OneHalfDark --paging=never "$OP_PROGRAM_PATH"
|
|
29
|
+
# printf "%b\n" "${GREEN}▶ Running...${RESET}"
|
|
30
|
+
. "$OP_PROGRAM_PATH"
|
|
31
|
+
status=$?
|
|
32
|
+
# if [[ $status -eq 0 ]]; then
|
|
33
|
+
# printf "%b\n" "${GREEN}✅ '${command}' execution completed.${RESET}"
|
|
34
|
+
# else
|
|
35
|
+
# printf "%b\n" "${YELLOW}⚠️ Program exited with status ${status}${RESET}"
|
|
36
|
+
# fi
|
|
37
|
+
else
|
|
38
|
+
echo " "
|
|
39
|
+
# printf "%b\n" "${GREEN}✅ '${command}' execution completed.${RESET}"
|
|
40
|
+
fi
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if [[ $# -gt 0 ]]; then
|
|
44
|
+
wrap_in_shell_script "$@"
|
|
45
|
+
fi
|
|
46
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env nu
|
|
2
|
+
|
|
3
|
+
def wrap-in-shell-script [command: string ...args: string] -> nothing {
|
|
4
|
+
# ANSI color/style codes
|
|
5
|
+
let bold = (char ansi_reset | str append "\e[1m")
|
|
6
|
+
let reset = "\e[0m"
|
|
7
|
+
let green = "\e[32m"
|
|
8
|
+
let yellow = "\e[33m"
|
|
9
|
+
let blue = "\e[34m"
|
|
10
|
+
let red = "\e[31m"
|
|
11
|
+
|
|
12
|
+
let random_name = (date now | format date "%s%N" | sha256sum | str substring 0..16)
|
|
13
|
+
let op_dir = $"($env.HOME)/tmp_results/tmp_scripts/machineconfig"
|
|
14
|
+
let op_program_path = $"($op_dir)/($random_name).sh"
|
|
15
|
+
|
|
16
|
+
$env.OP_PROGRAM_PATH = $op_program_path
|
|
17
|
+
|
|
18
|
+
let timestamp = (date now --utc | format date "%Y-%m-%d %H:%M:%SZ")
|
|
19
|
+
|
|
20
|
+
print $"($bold)($blue)🛠️ machineconfig — running ($command)($reset)"
|
|
21
|
+
print $"($blue)Timestamp:($reset) ($timestamp)"
|
|
22
|
+
print $"($blue)Op program path:($reset) ($op_program_path)"
|
|
23
|
+
|
|
24
|
+
# Forward arguments to the command
|
|
25
|
+
let result = (
|
|
26
|
+
try {
|
|
27
|
+
nu -c $"($command) ($args | str join ' ')"
|
|
28
|
+
} catch {
|
|
29
|
+
$"Error running command: ($in)"
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
if ($op_program_path | path exists) {
|
|
34
|
+
print $"($green)🚀 Taking over from python script @ ($op_program_path)($reset)"
|
|
35
|
+
|
|
36
|
+
if (which bat | is-empty | not) {
|
|
37
|
+
bat --style=plain --paging=never $op_program_path
|
|
38
|
+
} else {
|
|
39
|
+
open $op_program_path
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
print $"($green)▶ Running...($reset)"
|
|
43
|
+
|
|
44
|
+
let status = (
|
|
45
|
+
try {
|
|
46
|
+
bash $op_program_path
|
|
47
|
+
0
|
|
48
|
+
} catch {
|
|
49
|
+
1
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
if ($status == 0) {
|
|
54
|
+
print $"($green)✅ '($command)' execution completed.($reset)"
|
|
55
|
+
} else {
|
|
56
|
+
print $"($yellow)⚠️ Program exited with status ($status)($reset)"
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
print $"($green)✅ '($command)' execution completed.($reset)"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
def main [] {
|
|
64
|
+
if ($nu.env.args | length) > 0 {
|
|
65
|
+
wrap-in-shell-script ...$nu.env.args
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
main
|
|
@@ -2,33 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from pathlib import Path
|
|
6
5
|
from typing import cast, Optional, get_args, Annotated
|
|
7
6
|
import typer
|
|
8
|
-
from machineconfig.scripts.python.
|
|
7
|
+
from machineconfig.scripts.python.helpers_agents.fire_agents_helper_types import AGENTS, HOST, PROVIDER
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
def create(
|
|
12
11
|
agent: Annotated[AGENTS, typer.Option(..., "--agents", "-a", help=f"Agent type. One of {', '.join(get_args(AGENTS)[:3])}")],
|
|
13
12
|
host: Annotated[HOST, typer.Option(..., "--host", "-h", help=f"Machine to run agents on. One of {', '.join(get_args(HOST))}")],
|
|
14
|
-
model: Annotated[
|
|
13
|
+
model: Annotated[str, typer.Option(..., "--model", "-m", help="Model to use (for crush agent).")],
|
|
15
14
|
provider: Annotated[PROVIDER, typer.Option(..., "--provider", "-p", help=f"Provider to use (for crush agent). One of {', '.join(get_args(PROVIDER)[:3])}")],
|
|
16
|
-
context_path: Annotated[Optional[
|
|
15
|
+
context_path: Annotated[Optional[str], typer.Option(..., "--context-path", "-c", help="Path to the context file/folder, defaults to .ai/todo/")] = None,
|
|
17
16
|
separator: Annotated[str, typer.Option(..., "--separator", "-s", help="Separator for context")] = "\n",
|
|
18
17
|
agent_load: Annotated[int, typer.Option(..., "--agent-load", "-al", help="Number of tasks per prompt")] = 13,
|
|
19
18
|
prompt: Annotated[Optional[str], typer.Option(..., "--prompt", "-P", help="Prompt prefix as string")] = None,
|
|
20
|
-
prompt_path: Annotated[Optional[
|
|
19
|
+
prompt_path: Annotated[Optional[str], typer.Option(..., "--prompt-path", "-pp", help="Path to prompt file")] = None,
|
|
21
20
|
job_name: Annotated[str, typer.Option(..., "--job-name", "-j", help="Job name")] = "AI_Agents",
|
|
22
21
|
separate: Annotated[bool, typer.Option(..., "--separate", "-S", help="Keep prompt material in separate file to the context.")] = True,
|
|
23
|
-
output_path: Annotated[Optional[
|
|
24
|
-
agents_dir: Annotated[Optional[
|
|
22
|
+
output_path: Annotated[Optional[str], typer.Option(..., "--output-path", "-o", help="Path to write the layout.json file")] = None,
|
|
23
|
+
agents_dir: Annotated[Optional[str], typer.Option(..., "--agents-dir", "-ad", help="Directory to store agent files. If not provided, will be constructed automatically.")] = None,
|
|
25
24
|
):
|
|
26
25
|
|
|
27
|
-
from machineconfig.scripts.python.
|
|
28
|
-
from machineconfig.scripts.python.
|
|
26
|
+
from machineconfig.scripts.python.helpers_agents.fire_agents_help_launch import prep_agent_launch, get_agents_launch_layout
|
|
27
|
+
from machineconfig.scripts.python.helpers_agents.fire_agents_load_balancer import chunk_prompts
|
|
29
28
|
from machineconfig.utils.accessories import get_repo_root, randstr
|
|
30
29
|
import json
|
|
31
|
-
|
|
30
|
+
from pathlib import Path
|
|
32
31
|
# validate mutual exclusive
|
|
33
32
|
prompt_options = [prompt, prompt_path]
|
|
34
33
|
provided_prompt = [opt for opt in prompt_options if opt is not None]
|
|
@@ -39,12 +38,13 @@ def create(
|
|
|
39
38
|
if repo_root is None:
|
|
40
39
|
typer.echo("💥 Could not determine the repository root. Please run this script from within a git repository.")
|
|
41
40
|
raise typer.Exit(1)
|
|
41
|
+
return
|
|
42
42
|
typer.echo(f"Operating @ {repo_root}")
|
|
43
43
|
|
|
44
44
|
if context_path is None:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
context_path_resolved = Path(repo_root) / ".ai" / "todo"
|
|
46
|
+
else: context_path_resolved = Path(context_path).expanduser().resolve()
|
|
47
|
+
|
|
48
48
|
if not context_path_resolved.exists():
|
|
49
49
|
raise typer.BadParameter(f"Path does not exist: {context_path_resolved}")
|
|
50
50
|
|
|
@@ -60,20 +60,21 @@ def create(
|
|
|
60
60
|
raise typer.BadParameter(f"Path is neither file nor directory: {context_path_resolved}")
|
|
61
61
|
|
|
62
62
|
if prompt_path is not None:
|
|
63
|
-
prompt_prefix = prompt_path.read_text(encoding="utf-8")
|
|
63
|
+
prompt_prefix = Path(prompt_path).read_text(encoding="utf-8")
|
|
64
64
|
else:
|
|
65
65
|
prompt_prefix = cast(str, prompt)
|
|
66
66
|
agent_selected = agent
|
|
67
|
-
if agents_dir is None:
|
|
67
|
+
if agents_dir is None: agents_dir_obj = Path(repo_root) / ".ai" / f"tmp_prompts/{job_name}_{randstr()}"
|
|
68
68
|
else:
|
|
69
69
|
import shutil
|
|
70
|
-
if agents_dir.exists():
|
|
70
|
+
if Path(agents_dir).exists():
|
|
71
71
|
shutil.rmtree(agents_dir)
|
|
72
|
-
|
|
72
|
+
agents_dir_obj = Path(agents_dir)
|
|
73
|
+
prep_agent_launch(repo_root=repo_root, agents_dir=agents_dir_obj, prompts_material=prompt_material_re_splitted,
|
|
73
74
|
keep_material_in_separate_file=separate,
|
|
74
75
|
prompt_prefix=prompt_prefix, machine=host, agent=agent_selected, model=model, provider=provider,
|
|
75
76
|
job_name=job_name)
|
|
76
|
-
layoutfile = get_agents_launch_layout(session_root=
|
|
77
|
+
layoutfile = get_agents_launch_layout(session_root=agents_dir_obj)
|
|
77
78
|
regenerate_py_code = f"""
|
|
78
79
|
#!/usr/bin/env uv run --python 3.14 --with machineconfig
|
|
79
80
|
agents create "{context_path_resolved}" \\
|
|
@@ -85,11 +86,11 @@ agents create "{context_path_resolved}" \\
|
|
|
85
86
|
--separator "{separator}" \\
|
|
86
87
|
{"--separate" if separate else ""}
|
|
87
88
|
"""
|
|
88
|
-
(
|
|
89
|
-
layout_output_path = output_path if output_path is not None else
|
|
89
|
+
(agents_dir_obj / "aa_agents_relaunch.sh").write_text(data=regenerate_py_code, encoding="utf-8")
|
|
90
|
+
layout_output_path = Path(output_path) if output_path is not None else agents_dir_obj / "layout.json"
|
|
90
91
|
layout_output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
91
92
|
layout_output_path.write_text(data=json.dumps(layoutfile, indent=4), encoding="utf-8")
|
|
92
|
-
typer.echo(f"Created agents in {
|
|
93
|
+
typer.echo(f"Created agents in {agents_dir_obj}")
|
|
93
94
|
typer.echo(f"Ceated layout in {layout_output_path}")
|
|
94
95
|
|
|
95
96
|
|
|
@@ -99,6 +100,7 @@ def collect(
|
|
|
99
100
|
separator: Annotated[str, typer.Option(..., help="Separator to use when concatenating material files")] = "\n",
|
|
100
101
|
) -> None:
|
|
101
102
|
"""Collect all material files from an agent directory and concatenate them."""
|
|
103
|
+
from pathlib import Path
|
|
102
104
|
if not Path(agent_dir).exists() or not Path(agent_dir).is_dir():
|
|
103
105
|
raise typer.BadParameter(f"Agent directory does not exist or is not a directory: {agent_dir}")
|
|
104
106
|
|
|
@@ -134,13 +136,15 @@ def collect(
|
|
|
134
136
|
typer.echo(f"Concatenated material written to {output_path}")
|
|
135
137
|
|
|
136
138
|
|
|
137
|
-
def
|
|
139
|
+
def make_agents_command_template():
|
|
138
140
|
from platform import system
|
|
139
|
-
import machineconfig.scripts.python.
|
|
141
|
+
import machineconfig.scripts.python.helpers_agents as module
|
|
142
|
+
from pathlib import Path
|
|
143
|
+
|
|
140
144
|
if system() == "Linux" or system() == "Darwin":
|
|
141
|
-
template_path = Path(module.__file__).parent / "template.sh"
|
|
145
|
+
template_path = Path(module.__file__).parent / "templates/template.sh"
|
|
142
146
|
elif system() == "Windows":
|
|
143
|
-
template_path = Path(module.__file__).parent / "template.ps1"
|
|
147
|
+
template_path = Path(module.__file__).parent / "templates/template.ps1"
|
|
144
148
|
else:
|
|
145
149
|
raise typer.BadParameter(f"Unsupported OS: {system()}")
|
|
146
150
|
|
|
@@ -149,16 +153,29 @@ def template():
|
|
|
149
153
|
if repo_root is None:
|
|
150
154
|
typer.echo("💥 Could not determine the repository root. Please run this script from within a git repository.")
|
|
151
155
|
raise typer.Exit(1)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
|
|
157
|
+
save_path_root = repo_root / ".ai" / "agents"
|
|
158
|
+
|
|
159
|
+
save_path_root.mkdir(parents=True, exist_ok=True)
|
|
160
|
+
save_path_root.joinpath("template_fire_agents.sh").write_text(template_path.read_text(encoding="utf-8"), encoding="utf-8")
|
|
161
|
+
typer.echo(f"Template bash script written to {save_path_root}")
|
|
162
|
+
|
|
163
|
+
from machineconfig.scripts.python.ai.utils.generate_files import make_todo_files
|
|
164
|
+
make_todo_files(
|
|
165
|
+
pattern=".py", repo=str(repo_root), strategy="name", output_path=str(save_path_root / "files.md"), split_every=None, split_to=None
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
prompt_path = Path(module.__file__).parent / "templates/prompt.txt"
|
|
169
|
+
save_path_root.joinpath("prompt.txt").write_text(prompt_path.read_text(encoding="utf-8"), encoding="utf-8")
|
|
170
|
+
typer.echo(f"Prompt template written to {save_path_root}")
|
|
156
171
|
|
|
157
172
|
|
|
158
173
|
def init_config():
|
|
159
174
|
from machineconfig.scripts.python.ai.initai import add_ai_configs
|
|
175
|
+
from pathlib import Path
|
|
160
176
|
add_ai_configs(repo_root=Path.cwd())
|
|
161
177
|
|
|
178
|
+
|
|
162
179
|
def get_app():
|
|
163
180
|
agents_app = typer.Typer(help="🤖 AI Agents management subcommands", no_args_is_help=True, add_help_option=False, add_completion=False)
|
|
164
181
|
sep = "\n"
|
|
@@ -168,21 +185,19 @@ def get_app():
|
|
|
168
185
|
PROVIDER options: {', '.join(get_args(PROVIDER))}
|
|
169
186
|
{sep}
|
|
170
187
|
AGENT options: {', '.join(get_args(AGENTS))}
|
|
171
|
-
{sep}
|
|
172
|
-
MODEL options: {sep.join(get_args(MODEL))}
|
|
173
188
|
"""
|
|
174
189
|
agents_app.command("create", no_args_is_help=True, help=agents_full_help)(create)
|
|
175
190
|
agents_app.command("c", no_args_is_help=True, help="Create agents layout file, ready to run.", hidden=True)(create)
|
|
176
191
|
agents_app.command("collect", no_args_is_help=True, help="[T] Collect all agent materials into a single file.")(collect)
|
|
177
192
|
agents_app.command("T", no_args_is_help=True, help="Collect all agent materials into a single file.", hidden=True)(collect)
|
|
178
|
-
agents_app.command("make-template", no_args_is_help=False, help="[t] Create a template for fire agents")(
|
|
179
|
-
agents_app.command("t", no_args_is_help=False, help="Create a template for fire agents", hidden=True)(
|
|
193
|
+
agents_app.command("make-template", no_args_is_help=False, help="[t] Create a template for fire agents")(make_agents_command_template)
|
|
194
|
+
agents_app.command("t", no_args_is_help=False, help="Create a template for fire agents", hidden=True)(make_agents_command_template)
|
|
180
195
|
agents_app.command("make-config", no_args_is_help=False, help="[g] Initialize AI configurations in the current repository")(init_config)
|
|
181
196
|
agents_app.command("g", no_args_is_help=False, help="Initialize AI configurations in the current repository", hidden=True)(init_config)
|
|
182
|
-
from machineconfig.scripts.python.ai.generate_files import
|
|
183
|
-
agents_app.command("make-todo", no_args_is_help=True, help="[d] Generate a markdown file listing all Python files in the repo")(
|
|
184
|
-
agents_app.command("d", no_args_is_help=True, help="Generate a markdown file listing all Python files in the repo", hidden=True)(
|
|
185
|
-
from machineconfig.scripts.python.ai.generate_files import create_symlink_command
|
|
197
|
+
from machineconfig.scripts.python.ai.utils.generate_files import make_todo_files
|
|
198
|
+
agents_app.command("make-todo", no_args_is_help=True, help="[d] Generate a markdown file listing all Python files in the repo")(make_todo_files)
|
|
199
|
+
agents_app.command("d", no_args_is_help=True, help="Generate a markdown file listing all Python files in the repo", hidden=True)(make_todo_files)
|
|
200
|
+
from machineconfig.scripts.python.ai.utils.generate_files import create_symlink_command
|
|
186
201
|
agents_app.command(name="make-symlinks", no_args_is_help=True, help="[s] Create symlinks to the current repo in ~/code_copies/")(create_symlink_command)
|
|
187
202
|
agents_app.command(name="s", no_args_is_help=True, help="Create symlinks to the current repo in ~/code_copies/", hidden=True)(create_symlink_command)
|
|
188
203
|
return agents_app
|
|
@@ -7,7 +7,7 @@ from machineconfig.scripts.python.ai.solutions.copilot import github_copilot
|
|
|
7
7
|
from machineconfig.scripts.python.ai.solutions.crush import crush
|
|
8
8
|
from machineconfig.scripts.python.ai.solutions.cursor import cursors
|
|
9
9
|
from machineconfig.scripts.python.ai.solutions.gemini import gemini
|
|
10
|
-
from machineconfig.scripts.python.ai.vscode_tasks import add_lint_and_type_check_task
|
|
10
|
+
from machineconfig.scripts.python.ai.utils.vscode_tasks import add_lint_and_type_check_task
|
|
11
11
|
from machineconfig.utils.accessories import get_repo_root
|
|
12
12
|
|
|
13
13
|
|