@sebastienrousseau/dotfiles 0.2.481 → 0.2.499

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.
Files changed (317) hide show
  1. package/docs/ARCHITECTURE.md +29 -196
  2. package/docs/COMPLIANCE.md +10 -10
  3. package/docs/COPYRIGHT +3 -4
  4. package/docs/OPERATIONS.md +38 -65
  5. package/docs/PLAN.md +3 -3
  6. package/docs/PR_DESCRIPTION.md +85 -84
  7. package/docs/ROADMAP.md +11 -11
  8. package/docs/ROADMAP_legacy.md +556 -0
  9. package/docs/SECURITY_CHECKLIST.md +1 -1
  10. package/docs/TASK.md +4 -4
  11. package/docs/WALKTHROUGH.md +33 -152
  12. package/package.json +17 -5
  13. package/scripts/backup.sh +142 -0
  14. package/scripts/banner.sh +20 -0
  15. package/scripts/benchmark.sh +20 -0
  16. package/scripts/build.sh +41 -0
  17. package/scripts/clean.sh +31 -0
  18. package/scripts/compile.sh +54 -0
  19. package/scripts/copy.sh +108 -0
  20. package/scripts/{tools/detect-collisions.py → detect-collisions.py} +1 -1
  21. package/scripts/doctor.sh +79 -0
  22. package/scripts/dotfiles.sh +63 -0
  23. package/scripts/download.sh +35 -0
  24. package/scripts/help.sh +57 -0
  25. package/scripts/lock-configs.sh +57 -0
  26. package/scripts/package.sh +46 -0
  27. package/scripts/ssh.sh +55 -0
  28. package/scripts/teleport.sh +23 -0
  29. package/scripts/{tests/test-aliases.sh → test-aliases.sh} +3 -3
  30. package/scripts/test_smoke.sh +88 -0
  31. package/scripts/unpack.sh +28 -0
  32. package/scripts/{diagnostics/verify_state.sh → verify_state.sh} +21 -21
  33. package/templates/projects/go/README.md +0 -4
  34. package/templates/projects/node/README.md +0 -4
  35. package/templates/projects/python/README.md +0 -4
  36. package/templates/projects/python/pyproject.toml +0 -15
  37. package/CHANGELOG.md +0 -285
  38. package/LICENSE +0 -1283
  39. package/README.md +0 -315
  40. package/docs/ALIASES.md +0 -128
  41. package/docs/FEATURES.md +0 -166
  42. package/docs/FONTS.md +0 -147
  43. package/docs/INSTALL.md +0 -119
  44. package/docs/KEYS.md +0 -40
  45. package/docs/KEY_ROTATION.md +0 -219
  46. package/docs/LEGACY_ROADMAP.md +0 -142
  47. package/docs/NEOVIM_IDE_GUIDE.md +0 -52
  48. package/docs/README.md +0 -269
  49. package/docs/REPO_AUDIT.md +0 -23
  50. package/docs/SCREENSHOTS.md +0 -116
  51. package/docs/SECRETS.md +0 -76
  52. package/docs/SECURITY.md +0 -30
  53. package/docs/TESTING.md +0 -190
  54. package/docs/TOOLS.md +0 -146
  55. package/docs/TROUBLESHOOTING.md +0 -112
  56. package/docs/UTILS.md +0 -105
  57. package/docs/WSL2_NIX_TROUBLESHOOTING.md +0 -723
  58. package/docs/adr/ADR-001-ci-cd-pipeline.md +0 -101
  59. package/docs/adr/ADR-002-shell-performance.md +0 -121
  60. package/docs/adr/ADR-003-security-first.md +0 -140
  61. package/docs/adr/ADR-004-cli-architecture.md +0 -157
  62. package/docs/adr/ADR-005-chezmoi-choice.md +0 -89
  63. package/docs/adr/ADR-006-shell-selection.md +0 -115
  64. package/docs/adr/README.md +0 -33
  65. package/docs/themes/README.md +0 -20
  66. package/dot_config/aider/aider.conf.yml +0 -32
  67. package/dot_config/alacritty/alacritty.toml.tmpl +0 -483
  68. package/dot_config/ansible/ansible.cfg.tmpl +0 -11
  69. package/dot_config/atuin/config.toml +0 -23
  70. package/dot_config/bat/config +0 -8
  71. package/dot_config/brave-flags.conf.tmpl +0 -7
  72. package/dot_config/btop/btop.conf +0 -16
  73. package/dot_config/btop/themes/tokyonight.theme +0 -34
  74. package/dot_config/bun/bunfig.toml.tmpl +0 -33
  75. package/dot_config/claude/mcp_servers.json +0 -49
  76. package/dot_config/clippy.toml +0 -55
  77. package/dot_config/containers/containers.conf +0 -14
  78. package/dot_config/curl/dot_curlrc +0 -18
  79. package/dot_config/dlv/config.yml +0 -39
  80. package/dot_config/docker/config.json.tmpl +0 -15
  81. package/dot_config/dotfiles/boot/README.md +0 -11
  82. package/dot_config/dotfiles/grub/README.md +0 -11
  83. package/dot_config/dotfiles/lock/README.md +0 -11
  84. package/dot_config/dotfiles/versions.env.tmpl +0 -19
  85. package/dot_config/duf/duf.conf +0 -6
  86. package/dot_config/duti/defaults.duti +0 -5
  87. package/dot_config/emoji/emoji.txt +0 -34
  88. package/dot_config/fastfetch/config.jsonc +0 -28
  89. package/dot_config/firefox/user.js +0 -8
  90. package/dot_config/flatpak/flatpak.list +0 -4
  91. package/dot_config/fontconfig/fonts.conf.tmpl +0 -44
  92. package/dot_config/gem/gemrc +0 -9
  93. package/dot_config/gh/config.yml +0 -12
  94. package/dot_config/ghostty/config.tmpl +0 -661
  95. package/dot_config/git/attributes +0 -12
  96. package/dot_config/git/config.tmpl +0 -77
  97. package/dot_config/git/ignore +0 -27
  98. package/dot_config/gnupg/gpg-agent.conf.tmpl +0 -11
  99. package/dot_config/go/aliases.sh +0 -61
  100. package/dot_config/go/env.sh +0 -24
  101. package/dot_config/go/golangci.yml +0 -118
  102. package/dot_config/go/gopls.json +0 -30
  103. package/dot_config/goose/config.yaml +0 -29
  104. package/dot_config/gtk-3.0/gtk.css.tmpl +0 -305
  105. package/dot_config/gtk-3.0/settings.ini.tmpl +0 -66
  106. package/dot_config/gtk-4.0/gtk.css.tmpl +0 -309
  107. package/dot_config/gtk-4.0/settings.ini.tmpl +0 -21
  108. package/dot_config/htop/htoprc +0 -20
  109. package/dot_config/ice/README.md +0 -13
  110. package/dot_config/inputrc +0 -2
  111. package/dot_config/ipython/profile_default/ipython_config.py.tmpl +0 -5
  112. package/dot_config/just/justfile +0 -104
  113. package/dot_config/k9s/config.yaml.tmpl +0 -65
  114. package/dot_config/k9s/skins/catppuccin-mocha.yaml +0 -116
  115. package/dot_config/karabiner/karabiner.json +0 -14
  116. package/dot_config/kitty/kitty.conf.tmpl +0 -517
  117. package/dot_config/lazydocker/config.yml +0 -186
  118. package/dot_config/lazygit/config.yml +0 -23
  119. package/dot_config/lsd/config.yaml +0 -19
  120. package/dot_config/mas/masapps.txt +0 -5
  121. package/dot_config/minikube/config.json +0 -13
  122. package/dot_config/mise/config.toml +0 -41
  123. package/dot_config/mongosh/mongoshrc.js +0 -67
  124. package/dot_config/mycli/myclirc +0 -67
  125. package/dot_config/nano/nanorc +0 -28
  126. package/dot_config/ncdu/config +0 -12
  127. package/dot_config/nvim/init.lua +0 -4
  128. package/dot_config/nvim/lazy-lock.json +0 -27
  129. package/dot_config/nvim/lua/config/autocmds.lua +0 -63
  130. package/dot_config/nvim/lua/config/keymaps.lua +0 -87
  131. package/dot_config/nvim/lua/config/lazy.lua +0 -34
  132. package/dot_config/nvim/lua/config/options.lua +0 -48
  133. package/dot_config/nvim/lua/plugins/coding.lua +0 -234
  134. package/dot_config/nvim/lua/plugins/dap.lua +0 -201
  135. package/dot_config/nvim/lua/plugins/editor.lua +0 -59
  136. package/dot_config/nvim/lua/plugins/git.lua +0 -9
  137. package/dot_config/nvim/lua/plugins/lsp.lua +0 -221
  138. package/dot_config/nvim/lua/plugins/markdown.lua +0 -17
  139. package/dot_config/nvim/lua/plugins/rust.lua +0 -33
  140. package/dot_config/nvim/lua/plugins/sessions.lua +0 -32
  141. package/dot_config/nvim/lua/plugins/ui.lua +0 -537
  142. package/dot_config/nvim/snippets/all.lua +0 -9
  143. package/dot_config/nvim/snippets/python.lua +0 -16
  144. package/dot_config/pip/pip.conf.tmpl +0 -32
  145. package/dot_config/pypoetry/config.toml.tmpl +0 -6
  146. package/dot_config/pyrightconfig.json.tmpl +0 -5
  147. package/dot_config/raycast/README.md +0 -13
  148. package/dot_config/redis/redisclirc +0 -41
  149. package/dot_config/shell/00-container-detect.sh +0 -53
  150. package/dot_config/shell/00-core-paths.sh.tmpl +0 -95
  151. package/dot_config/shell/05-core-safety.sh.tmpl +0 -13
  152. package/dot_config/shell/40-ls-colors.sh.tmpl +0 -31
  153. package/dot_config/shell/50-logic-functions.sh.tmpl +0 -10
  154. package/dot_config/shell/90-theme-switch.sh +0 -70
  155. package/dot_config/shell/90-ux-aliases.sh.tmpl +0 -35
  156. package/dot_config/shell/91-ux-aliases-lazy.sh.tmpl +0 -23
  157. package/dot_config/shell/Brewfile +0 -207
  158. package/dot_config/shell/Brewfile.cask +0 -92
  159. package/dot_config/shell/Brewfile.cli +0 -119
  160. package/dot_config/shell/README.md +0 -267
  161. package/dot_config/shell/custom/context_suggest.zsh +0 -68
  162. package/dot_config/shell/custom/error_analysis.zsh +0 -45
  163. package/dot_config/sops/dot_sops.yaml +0 -23
  164. package/dot_config/starship.toml.tmpl +0 -124
  165. package/dot_config/task/Taskfile.yml +0 -86
  166. package/dot_config/tflint/tflint.hcl.tmpl +0 -9
  167. package/dot_config/tmux/tmux.conf.tmpl +0 -181
  168. package/dot_config/topgrade/topgrade.toml.tmpl +0 -42
  169. package/dot_config/vscode/extensions.txt +0 -11
  170. package/dot_config/vscode/settings.json.tmpl +0 -123
  171. package/dot_config/waybar/style.css +0 -8
  172. package/dot_config/wezterm/wezterm.lua.tmpl +0 -236
  173. package/dot_config/wget/wgetrc +0 -12
  174. package/dot_config/yarn/yarnrc.yml.tmpl +0 -36
  175. package/dot_config/yazi/yazi.toml +0 -40
  176. package/dot_config/zellij/config.kdl +0 -79
  177. package/dot_config/zsh/dot_zprofile +0 -13
  178. package/dot_config/zsh/dot_zshenv +0 -6
  179. package/dot_config/zsh/dot_zshrc.tmpl +0 -199
  180. package/dot_config/zsh/rc.d/05-ssh-agent.zsh +0 -5
  181. package/dot_config/zsh/rc.d/10-env.zsh.tmpl +0 -28
  182. package/dot_config/zsh/rc.d/20-zinit.zsh.tmpl +0 -22
  183. package/dot_config/zsh/rc.d/30-options.zsh.tmpl +0 -123
  184. package/dot_config/zsh/rc.d/40-bell.zsh.tmpl +0 -20
  185. package/dot_config/zsh/rc.d/50-login-fortune.zsh.tmpl +0 -9
  186. package/dot_local/bin/executable_ai_core +0 -130
  187. package/dot_local/bin/executable_b64 +0 -59
  188. package/dot_local/bin/executable_dot +0 -178
  189. package/dot_local/bin/executable_dot_completion +0 -55
  190. package/dot_local/bin/executable_epoch +0 -62
  191. package/dot_local/bin/executable_extract +0 -108
  192. package/dot_local/bin/executable_git-ai-commit +0 -160
  193. package/dot_local/bin/executable_git-ai-diff +0 -154
  194. package/dot_local/bin/executable_hash +0 -123
  195. package/dot_local/bin/executable_hex +0 -79
  196. package/dot_local/bin/executable_ip +0 -37
  197. package/dot_local/bin/executable_jsonv +0 -54
  198. package/dot_local/bin/executable_jwt +0 -78
  199. package/dot_local/bin/executable_kill-port +0 -59
  200. package/dot_local/bin/executable_lorem +0 -103
  201. package/dot_local/bin/executable_regex +0 -96
  202. package/dot_local/bin/executable_tmux-sessionizer +0 -187
  203. package/dot_local/bin/executable_tour +0 -137
  204. package/dot_local/bin/executable_update +0 -108
  205. package/dot_local/bin/executable_uuid +0 -57
  206. package/dot_local/bin/executable_yamlv +0 -39
  207. package/dot_local/bin/executable_zig-install +0 -89
  208. package/dot_local/bin/voice_ops +0 -7
  209. package/dot_local/share/bash-completion/completions/dot +0 -54
  210. package/dot_local/share/zsh/completions/.keep +0 -0
  211. package/install.sh +0 -255
  212. package/scripts/ci/validate-ci-config.sh +0 -222
  213. package/scripts/demo/record.sh +0 -41
  214. package/scripts/diagnostics/benchmark.sh +0 -201
  215. package/scripts/diagnostics/doctor.sh +0 -115
  216. package/scripts/diagnostics/drift-dashboard.sh +0 -26
  217. package/scripts/diagnostics/health.sh +0 -356
  218. package/scripts/diagnostics/history-analysis.sh +0 -77
  219. package/scripts/diagnostics/security-score.sh +0 -392
  220. package/scripts/dot/commands/appearance.sh +0 -63
  221. package/scripts/dot/commands/core.sh +0 -130
  222. package/scripts/dot/commands/diagnostics.sh +0 -100
  223. package/scripts/dot/commands/meta.sh +0 -117
  224. package/scripts/dot/commands/restore.sh +0 -209
  225. package/scripts/dot/commands/secrets.sh +0 -81
  226. package/scripts/dot/commands/security.sh +0 -73
  227. package/scripts/dot/commands/tools.sh +0 -228
  228. package/scripts/dot/lib/utils.sh +0 -72
  229. package/scripts/fonts/install-nerd-fonts.sh +0 -59
  230. package/scripts/fonts/patch-fonts.sh +0 -34
  231. package/scripts/ops/chezmoi-apply.sh +0 -42
  232. package/scripts/ops/chezmoi-diff.sh +0 -14
  233. package/scripts/ops/chezmoi-remove.sh +0 -43
  234. package/scripts/ops/chezmoi-update.sh +0 -16
  235. package/scripts/ops/heal.sh +0 -466
  236. package/scripts/ops/health-check.sh +0 -380
  237. package/scripts/ops/rollback.sh +0 -531
  238. package/scripts/ops/teleport.sh +0 -32
  239. package/scripts/secrets/age-init.sh +0 -69
  240. package/scripts/secrets/create-secrets-file.sh +0 -44
  241. package/scripts/secrets/encrypt-ssh-key.sh +0 -42
  242. package/scripts/security/backup.sh +0 -17
  243. package/scripts/security/dns-doh.sh +0 -29
  244. package/scripts/security/encryption-check.sh +0 -39
  245. package/scripts/security/enforce-policies.sh +0 -339
  246. package/scripts/security/firewall.sh +0 -34
  247. package/scripts/security/lock-configs.sh +0 -57
  248. package/scripts/security/lock-screen.sh +0 -33
  249. package/scripts/security/manage-secrets.sh +0 -415
  250. package/scripts/security/telemetry-kill.sh +0 -28
  251. package/scripts/security/usb-safety.sh +0 -29
  252. package/scripts/tests/README.md +0 -241
  253. package/scripts/tests/benchmark.sh +0 -91
  254. package/scripts/tests/framework/assertions.sh +0 -283
  255. package/scripts/tests/framework/mocks.sh +0 -201
  256. package/scripts/tests/framework/test_runner.sh +0 -189
  257. package/scripts/tests/integration/test_install.sh +0 -237
  258. package/scripts/tests/performance/benchmark_runner.sh +0 -156
  259. package/scripts/tests/performance/regression_check.sh +0 -73
  260. package/scripts/tests/performance/stress_test.sh +0 -65
  261. package/scripts/tests/test-docker.sh +0 -48
  262. package/scripts/tests/unit/test_ai_aliases.sh +0 -158
  263. package/scripts/tests/unit/test_ai_cli_checks.sh +0 -47
  264. package/scripts/tests/unit/test_backup.sh +0 -227
  265. package/scripts/tests/unit/test_case_functions.sh +0 -238
  266. package/scripts/tests/unit/test_cd_aliases.sh +0 -367
  267. package/scripts/tests/unit/test_dot_cli.sh +0 -217
  268. package/scripts/tests/unit/test_encode64.sh +0 -67
  269. package/scripts/tests/unit/test_environment.sh +0 -78
  270. package/scripts/tests/unit/test_extract.sh +0 -163
  271. package/scripts/tests/unit/test_framework_edge_cases.sh +0 -113
  272. package/scripts/tests/unit/test_genpass.sh +0 -298
  273. package/scripts/tests/unit/test_install_edge_cases.sh +0 -167
  274. package/scripts/tests/unit/test_installers.sh +0 -172
  275. package/scripts/tests/unit/test_keygen.sh +0 -68
  276. package/scripts/tests/unit/test_logging.sh +0 -96
  277. package/scripts/tests/unit/test_os_detection_comprehensive.sh +0 -388
  278. package/scripts/tests/unit/test_package_managers_comprehensive.sh +0 -321
  279. package/scripts/tests/unit/test_prependpath.sh +0 -66
  280. package/scripts/tests/unit/test_prependpath_refactored.sh +0 -89
  281. package/scripts/tests/unit/test_rd.sh +0 -230
  282. package/scripts/tests/unit/test_security_fixes.sh +0 -130
  283. package/scripts/tests/unit/test_security_scripts.sh +0 -87
  284. package/scripts/tests/unit/test_template_validation.sh +0 -238
  285. package/scripts/tests/unit/test_utility_functions.sh +0 -144
  286. package/scripts/tests/unit/test_wave1_alias_split.sh +0 -132
  287. package/scripts/tests/unit/test_wave1_ci_pinning.sh +0 -61
  288. package/scripts/tests/unit/test_wave1_gitleaks_config.sh +0 -52
  289. package/scripts/tests/unit/test_wave1_heal_fixes.sh +0 -97
  290. package/scripts/tests/unit/test_wave1_install_gpg.sh +0 -35
  291. package/scripts/tests/unit/test_wave1_zshenv_path.sh +0 -89
  292. package/scripts/tests/unit/test_wave1_zshrc_lazy_hook.sh +0 -115
  293. package/scripts/tests/unit/test_wave2_dot_new_guard.sh +0 -75
  294. package/scripts/tests/unit/test_zipf.sh +0 -76
  295. package/scripts/theme/apply-gnome-theme.sh +0 -297
  296. package/scripts/theme/install-boot-logo.sh +0 -61
  297. package/scripts/theme/install-catppuccin-themes.sh +0 -346
  298. package/scripts/theme/install-cursors.sh +0 -24
  299. package/scripts/theme/install-file-icons.sh +0 -25
  300. package/scripts/theme/install-grub-theme.sh +0 -51
  301. package/scripts/theme/install-lock-icon.sh +0 -29
  302. package/scripts/theme/switch.sh +0 -250
  303. package/scripts/theme/wallpaper-rotate.sh +0 -82
  304. package/scripts/theme/wallpaper-sync.sh +0 -42
  305. package/scripts/tools/cmatrix.sh +0 -20
  306. package/scripts/tools/emoji-picker.sh +0 -45
  307. package/scripts/tools/figlet-banner.sh +0 -17
  308. package/scripts/tools/log-rotate.sh +0 -29
  309. package/scripts/tools/lolcat-wrap.sh +0 -18
  310. package/scripts/tools/pipes.sh +0 -47
  311. package/scripts/tuning/linux.sh +0 -175
  312. package/scripts/tuning/macos.sh +0 -46
  313. package/templates/projects/molecule/README.md +0 -7
  314. package/templates/projects/molecule/converge.yml +0 -7
  315. package/templates/projects/molecule/molecule.yml +0 -16
  316. package/templates/projects/packer/README.md +0 -15
  317. package/templates/projects/packer/main.pkr.hcl +0 -15
@@ -1,466 +0,0 @@
1
- #!/usr/bin/env bash
2
- # shellcheck disable=SC2034
3
- # =============================================================================
4
- # Dotfiles Heal Script - Auto-repair common dotfiles issues
5
- # Runs diagnostics and attempts automatic fixes
6
- # Usage: ./scripts/ops/heal.sh [OPTIONS]
7
- # =============================================================================
8
-
9
- set -euo pipefail
10
-
11
- # Configuration
12
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13
- REPO_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"
14
- DOTFILES_SOURCE="$REPO_ROOT"
15
- BACKUP_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/dotfiles/backups"
16
- STATE_DIR="${XDG_STATE_HOME:-$HOME/.local/state}/dotfiles"
17
- HEAL_LOG="$STATE_DIR/heal.log"
18
-
19
- # Colors (respect NO_COLOR: https://no-color.org)
20
- if [[ -z "${NO_COLOR:-}" ]] && [[ -t 1 ]]; then
21
- RED='\033[0;31m'
22
- GREEN='\033[0;32m'
23
- YELLOW='\033[0;33m'
24
- BLUE='\033[0;34m'
25
- BOLD='\033[1m'
26
- NC='\033[0m'
27
- else
28
- RED='' GREEN='' YELLOW='' BLUE='' BOLD='' NC=''
29
- fi
30
-
31
- # Logging
32
- log() { echo -e "$*"; }
33
- log_info() { log "${BLUE}[INFO]${NC} $*"; }
34
- log_success() { log "${GREEN}[OK]${NC} $*"; }
35
- log_warn() { log "${YELLOW}[WARN]${NC} $*"; }
36
- log_error() { log "${RED}[ERROR]${NC} $*"; }
37
- log_step() { log "\n${BOLD}==> $*${NC}"; }
38
- log_dry() { log "${YELLOW}[DRY-RUN]${NC} Would: $*"; }
39
-
40
- # Persistent logging
41
- persist_log() {
42
- mkdir -p "$STATE_DIR"
43
- echo "[$(date -Iseconds)] $*" >>"$HEAL_LOG"
44
- }
45
-
46
- # Options
47
- DRY_RUN=0
48
- FORCE=0
49
- FIXES_APPLIED=0
50
- ISSUES_FOUND=0
51
- CHEZMOI_APPLIED=0
52
-
53
- usage() {
54
- cat <<EOF
55
- Dotfiles Heal - Auto-repair common issues
56
-
57
- Usage: $(basename "$0") [OPTIONS]
58
-
59
- Options:
60
- -n, --dry-run Preview what would be fixed without making changes
61
- -f, --force Skip confirmation prompts
62
- -h, --help Show this help message
63
-
64
- Repairs:
65
- - Missing core dependencies (chezmoi, starship, rg, bat)
66
- - Broken symlinks in \$HOME (depth 3)
67
- - Chezmoi drift (re-applies dotfiles)
68
- - Missing critical files (.zshrc, .bashrc, .profile)
69
- - Missing XDG config directories
70
-
71
- EOF
72
- }
73
-
74
- # Parse arguments
75
- while [[ $# -gt 0 ]]; do
76
- case "$1" in
77
- -n | --dry-run)
78
- DRY_RUN=1
79
- shift
80
- ;;
81
- -f | --force)
82
- FORCE=1
83
- shift
84
- ;;
85
- -h | --help)
86
- usage
87
- exit 0
88
- ;;
89
- *)
90
- log_error "Unknown option: $1"
91
- usage
92
- exit 1
93
- ;;
94
- esac
95
- done
96
-
97
- # =============================================================================
98
- # Backup before making changes
99
- # =============================================================================
100
-
101
- create_pre_heal_backup() {
102
- local rollback_script="$REPO_ROOT/scripts/ops/rollback.sh"
103
- if [[ -f "$rollback_script" ]]; then
104
- log_info "Creating backup before heal..."
105
- bash "$rollback_script" backup --force 2>/dev/null || true
106
- else
107
- # Minimal inline backup
108
- local timestamp
109
- timestamp=$(date +"%Y%m%d_%H%M%S")
110
- local backup_path="$BACKUP_DIR/backup_${timestamp}_pre_heal"
111
- mkdir -p "$backup_path"
112
- for f in "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.profile"; do
113
- if [[ -f "$f" ]]; then
114
- cp -a "$f" "$backup_path/" 2>/dev/null || true
115
- fi
116
- done
117
- log_info "Backup created at $backup_path"
118
- fi
119
- }
120
-
121
- # =============================================================================
122
- # Repair Functions
123
- # =============================================================================
124
-
125
- detect_pkg_manager() {
126
- if command -v brew >/dev/null 2>&1; then
127
- echo "brew"
128
- elif command -v apt-get >/dev/null 2>&1; then
129
- echo "apt"
130
- elif command -v dnf >/dev/null 2>&1; then
131
- echo "dnf"
132
- elif command -v pacman >/dev/null 2>&1; then
133
- echo "pacman"
134
- elif command -v nix-env >/dev/null 2>&1; then
135
- echo "nix"
136
- else
137
- echo ""
138
- fi
139
- }
140
-
141
- install_package() {
142
- local pkg="$1"
143
- local pkg_mgr
144
- pkg_mgr=$(detect_pkg_manager)
145
-
146
- case "$pkg_mgr" in
147
- brew) brew install "$pkg" ;;
148
- apt) sudo apt-get install -y "$pkg" ;;
149
- dnf) sudo dnf install -y "$pkg" ;;
150
- pacman) sudo pacman -S --noconfirm "$pkg" ;;
151
- nix) nix-env -iA "nixpkgs.$pkg" ;;
152
- *)
153
- log_error "No supported package manager found. Install '$pkg' manually."
154
- return 1
155
- ;;
156
- esac
157
- }
158
-
159
- # Map command names to package names per package manager
160
- get_package_name() {
161
- local cmd="$1"
162
- local pkg_mgr
163
- pkg_mgr=$(detect_pkg_manager)
164
-
165
- case "$cmd" in
166
- rg)
167
- case "$pkg_mgr" in
168
- apt | dnf) echo "ripgrep" ;;
169
- *) echo "ripgrep" ;;
170
- esac
171
- ;;
172
- bat)
173
- case "$pkg_mgr" in
174
- apt) echo "bat" ;;
175
- *) echo "bat" ;;
176
- esac
177
- ;;
178
- *) echo "$cmd" ;;
179
- esac
180
- }
181
-
182
- heal_missing_dependencies() {
183
- log_step "Checking core dependencies"
184
- local deps=(chezmoi starship rg bat)
185
- local missing=()
186
-
187
- for cmd in "${deps[@]}"; do
188
- if ! command -v "$cmd" >/dev/null 2>&1; then
189
- missing+=("$cmd")
190
- ISSUES_FOUND=$((ISSUES_FOUND + 1))
191
- fi
192
- done
193
-
194
- if [[ ${#missing[@]} -eq 0 ]]; then
195
- log_success "All core dependencies present"
196
- return 0
197
- fi
198
-
199
- log_warn "Missing dependencies: ${missing[*]}"
200
-
201
- local pkg_mgr
202
- pkg_mgr=$(detect_pkg_manager)
203
-
204
- if [[ -z "$pkg_mgr" ]]; then
205
- log_error "No supported package manager detected. Install manually: ${missing[*]}"
206
- return 1
207
- fi
208
-
209
- for cmd in "${missing[@]}"; do
210
- local pkg
211
- pkg=$(get_package_name "$cmd")
212
-
213
- if [[ "$DRY_RUN" == "1" ]]; then
214
- log_dry "install '$pkg' via $pkg_mgr"
215
- else
216
- log_info "Installing $pkg via $pkg_mgr..."
217
- if install_package "$pkg"; then
218
- log_success "Installed $pkg"
219
- FIXES_APPLIED=$((FIXES_APPLIED + 1))
220
- persist_log "HEAL: installed $pkg via $pkg_mgr"
221
- else
222
- log_error "Failed to install $pkg"
223
- fi
224
- fi
225
- done
226
- }
227
-
228
- heal_broken_symlinks() {
229
- log_step "Checking for broken symlinks"
230
- local broken=()
231
-
232
- while IFS= read -r -d '' link; do
233
- if [[ ! -e "$link" ]]; then
234
- broken+=("$link")
235
- fi
236
- done < <(find "$HOME" -maxdepth 3 -type l -print0 2>/dev/null)
237
-
238
- if [[ ${#broken[@]} -eq 0 ]]; then
239
- log_success "No broken symlinks found"
240
- return 0
241
- fi
242
-
243
- ISSUES_FOUND=$((ISSUES_FOUND + ${#broken[@]}))
244
- log_warn "${#broken[@]} broken symlink(s) found"
245
-
246
- for link in "${broken[@]}"; do
247
- local target
248
- target=$(readlink "$link" 2>/dev/null || echo "unknown")
249
- if [[ "$DRY_RUN" == "1" ]]; then
250
- log_dry "remove broken symlink: $link -> $target"
251
- else
252
- if [[ "$FORCE" != "1" ]]; then
253
- read -rp "Remove broken symlink $link -> $target? [y/N] " response
254
- if [[ ! "$response" =~ ^[Yy]$ ]]; then
255
- log_info "Skipped: $link"
256
- continue
257
- fi
258
- fi
259
- rm -f "$link"
260
- log_success "Removed broken symlink: $link -> $target"
261
- FIXES_APPLIED=$((FIXES_APPLIED + 1))
262
- persist_log "HEAL: removed broken symlink $link"
263
- fi
264
- done
265
- }
266
-
267
- heal_chezmoi_drift() {
268
- log_step "Checking chezmoi state"
269
-
270
- if ! command -v chezmoi >/dev/null 2>&1; then
271
- log_warn "chezmoi not installed, skipping drift check"
272
- return 0
273
- fi
274
-
275
- local status_output
276
- status_output=$(chezmoi status 2>/dev/null || echo "")
277
-
278
- if [[ -z "$status_output" ]]; then
279
- log_success "Chezmoi state is synchronized"
280
- return 0
281
- fi
282
-
283
- local drift_count
284
- drift_count=$(echo "$status_output" | wc -l | tr -d ' ')
285
- ISSUES_FOUND=$((ISSUES_FOUND + 1))
286
- log_warn "$drift_count file(s) out of sync"
287
-
288
- if [[ "$DRY_RUN" == "1" ]]; then
289
- log_dry "run 'chezmoi apply --force' to re-sync"
290
- echo "$status_output" | while read -r line; do
291
- log_info " $line"
292
- done
293
- else
294
- log_info "Re-applying dotfiles with chezmoi..."
295
- if chezmoi apply --force; then
296
- log_success "Chezmoi re-applied successfully"
297
- FIXES_APPLIED=$((FIXES_APPLIED + 1))
298
- CHEZMOI_APPLIED=1
299
- persist_log "HEAL: chezmoi apply --force ($drift_count files drifted)"
300
- else
301
- log_error "Chezmoi apply failed"
302
- fi
303
- fi
304
- }
305
-
306
- heal_missing_critical_files() {
307
- log_step "Checking critical files"
308
- local critical_files=(
309
- "$HOME/.zshrc"
310
- "$HOME/.bashrc"
311
- "$HOME/.profile"
312
- )
313
- local missing=()
314
-
315
- for file in "${critical_files[@]}"; do
316
- if [[ ! -f "$file" ]] && [[ ! -L "$file" ]]; then
317
- missing+=("$file")
318
- ISSUES_FOUND=$((ISSUES_FOUND + 1))
319
- fi
320
- done
321
-
322
- if [[ ${#missing[@]} -eq 0 ]]; then
323
- log_success "All critical shell configs present"
324
- return 0
325
- fi
326
-
327
- log_warn "Missing critical files: ${missing[*]}"
328
-
329
- if ! command -v chezmoi >/dev/null 2>&1; then
330
- log_error "chezmoi not available to regenerate files"
331
- return 1
332
- fi
333
-
334
- if [[ "$DRY_RUN" == "1" ]]; then
335
- log_dry "run 'chezmoi apply --force' to regenerate missing files"
336
- elif [[ "$CHEZMOI_APPLIED" == "1" ]]; then
337
- log_info "chezmoi already re-applied during drift repair, verifying files..."
338
- local restored=0
339
- for file in "${missing[@]}"; do
340
- if [[ -f "$file" ]] || [[ -L "$file" ]]; then
341
- log_success "Restored (via earlier apply): $file"
342
- restored=$((restored + 1))
343
- else
344
- log_warn "Still missing after apply: $file"
345
- fi
346
- done
347
- FIXES_APPLIED=$((FIXES_APPLIED + restored))
348
- else
349
- log_info "Re-applying chezmoi to regenerate missing files..."
350
- if chezmoi apply --force; then
351
- CHEZMOI_APPLIED=1
352
- # Verify files were restored
353
- local restored=0
354
- for file in "${missing[@]}"; do
355
- if [[ -f "$file" ]] || [[ -L "$file" ]]; then
356
- log_success "Restored: $file"
357
- restored=$((restored + 1))
358
- else
359
- log_warn "Still missing after apply: $file"
360
- fi
361
- done
362
- FIXES_APPLIED=$((FIXES_APPLIED + restored))
363
- persist_log "HEAL: regenerated $restored critical file(s)"
364
- else
365
- log_error "Chezmoi apply failed"
366
- fi
367
- fi
368
- }
369
-
370
- heal_missing_xdg_dirs() {
371
- log_step "Checking XDG config directories"
372
- local xdg_dirs=(
373
- "$HOME/.config/shell"
374
- "$HOME/.config/nvim"
375
- "$HOME/.config/git"
376
- )
377
- local missing=()
378
-
379
- for dir in "${xdg_dirs[@]}"; do
380
- if [[ ! -d "$dir" ]]; then
381
- missing+=("$dir")
382
- ISSUES_FOUND=$((ISSUES_FOUND + 1))
383
- fi
384
- done
385
-
386
- if [[ ${#missing[@]} -eq 0 ]]; then
387
- log_success "All XDG config directories present"
388
- return 0
389
- fi
390
-
391
- log_warn "Missing XDG directories: ${missing[*]}"
392
-
393
- for dir in "${missing[@]}"; do
394
- if [[ "$DRY_RUN" == "1" ]]; then
395
- log_dry "create directory: $dir"
396
- else
397
- mkdir -p "$dir"
398
- log_success "Created: $dir"
399
- FIXES_APPLIED=$((FIXES_APPLIED + 1))
400
- persist_log "HEAL: created directory $dir"
401
- fi
402
- done
403
- }
404
-
405
- # =============================================================================
406
- # Main
407
- # =============================================================================
408
-
409
- main() {
410
- echo ""
411
- echo "=========================================="
412
- echo " Dotfiles Heal - Auto-Repair"
413
- echo "=========================================="
414
-
415
- if [[ "$DRY_RUN" == "1" ]]; then
416
- log_info "Running in dry-run mode (no changes will be made)"
417
- fi
418
-
419
- # Confirm before making changes (unless --force or --dry-run)
420
- if [[ "$DRY_RUN" != "1" ]] && [[ "$FORCE" != "1" ]]; then
421
- echo ""
422
- log_warn "This will attempt to auto-repair your dotfiles environment."
423
- log_info "A backup will be created before any changes are made."
424
- read -rp "Continue? [y/N] " response
425
- if [[ ! "$response" =~ ^[Yy]$ ]]; then
426
- log_info "Aborted."
427
- exit 0
428
- fi
429
- fi
430
-
431
- # Create backup before making changes
432
- if [[ "$DRY_RUN" != "1" ]]; then
433
- create_pre_heal_backup
434
- fi
435
-
436
- # Run all repairs
437
- heal_missing_dependencies || true
438
- heal_broken_symlinks || true
439
- heal_chezmoi_drift || true
440
- heal_missing_critical_files || true
441
- heal_missing_xdg_dirs || true
442
-
443
- # Summary
444
- echo ""
445
- echo "=========================================="
446
- if [[ "$DRY_RUN" == "1" ]]; then
447
- if [[ $ISSUES_FOUND -eq 0 ]]; then
448
- log_success "No issues found. System is healthy."
449
- else
450
- log_info "Found $ISSUES_FOUND issue(s). Run without --dry-run to apply fixes."
451
- fi
452
- else
453
- if [[ $ISSUES_FOUND -eq 0 ]]; then
454
- log_success "No issues found. System is healthy."
455
- elif [[ $FIXES_APPLIED -gt 0 ]]; then
456
- log_success "Applied $FIXES_APPLIED fix(es) for $ISSUES_FOUND issue(s) found."
457
- persist_log "HEAL_COMPLETE: $FIXES_APPLIED fixes applied"
458
- else
459
- log_warn "Found $ISSUES_FOUND issue(s) but no fixes could be applied."
460
- log_info "Try running 'dot doctor' for detailed diagnostics."
461
- fi
462
- fi
463
- echo "=========================================="
464
- }
465
-
466
- main