@sebastienrousseau/dotfiles 0.2.519 → 0.2.521

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 (306) hide show
  1. package/CHANGELOG.md +200 -0
  2. package/LICENSE-APACHE +190 -0
  3. package/{LICENSE → LICENSE-MIT} +1 -1
  4. package/README.md +1172 -166
  5. package/install.sh +77 -11
  6. package/package.json +8 -8
  7. package/tools/README.md +49 -0
  8. package/tools/ci/install-chezmoi-verified.sh +68 -0
  9. package/docs/.vitepress/reports/localization-readability-audit.md +0 -73
  10. package/docs/AI.md +0 -179
  11. package/docs/CNAME +0 -1
  12. package/docs/CONFIG_STRATEGY.md +0 -124
  13. package/docs/COPYRIGHT +0 -7
  14. package/docs/GOVERNANCE.md +0 -98
  15. package/docs/MAINTAINERS.md +0 -41
  16. package/docs/NAMING_CONVENTIONS.md +0 -102
  17. package/docs/OPENCODE.md +0 -127
  18. package/docs/README.md +0 -84
  19. package/docs/STRUCTURE.md +0 -102
  20. package/docs/adr/ADR-001-ci-cd-pipeline.md +0 -118
  21. package/docs/adr/ADR-002-shell-performance.md +0 -130
  22. package/docs/adr/ADR-003-security-first.md +0 -158
  23. package/docs/adr/ADR-004-cli-architecture.md +0 -171
  24. package/docs/adr/ADR-005-chezmoi-choice.md +0 -99
  25. package/docs/adr/ADR-006-shell-selection.md +0 -124
  26. package/docs/adr/ADR-007-multi-shell-parity.md +0 -62
  27. package/docs/adr/ADR-008-alias-system-architecture.md +0 -95
  28. package/docs/adr/ADR-009-wallpaper-driven-theming.md +0 -131
  29. package/docs/adr/ADR-010-starship-transient-prompt.md +0 -144
  30. package/docs/adr/ADR-011-nushell-tier3-keep.md +0 -144
  31. package/docs/adr/ADR-012-ai-fleet-local-proxy.md +0 -79
  32. package/docs/adr/README.md +0 -40
  33. package/docs/architecture/AI_COST_OPTIMIZATION.md +0 -144
  34. package/docs/architecture/ARCHITECTURE.md +0 -117
  35. package/docs/architecture/INTEROP.md +0 -44
  36. package/docs/architecture/REPO_LAYOUT.md +0 -241
  37. package/docs/architecture/WALKTHROUGH.md +0 -86
  38. package/docs/architecture/fleet-deployment.md +0 -77
  39. package/docs/archive/EUXIS_2026_REVIEW.md +0 -127
  40. package/docs/archive/LEGACY_ROADMAP.md +0 -6
  41. package/docs/archive/MILESTONE_v0.2.493.md +0 -47
  42. package/docs/archive/PLAN.md +0 -199
  43. package/docs/archive/REPO_AUDIT.md +0 -31
  44. package/docs/articles/.pages +0 -6
  45. package/docs/articles/2026-07-05-custom-mkdocs-material-dark-theme.md +0 -216
  46. package/docs/articles/2026-07-05-fish-startup-abbr.md +0 -153
  47. package/docs/articles/2026-07-05-master-to-main-rename-runbook.md +0 -128
  48. package/docs/articles/index.md +0 -36
  49. package/docs/guides/INSTALL.md +0 -144
  50. package/docs/guides/NEOVIM_IDE_GUIDE.md +0 -61
  51. package/docs/guides/THEMING.md +0 -230
  52. package/docs/guides/TROUBLESHOOTING.md +0 -176
  53. package/docs/guides/WSL2_NIX_TROUBLESHOOTING.md +0 -792
  54. package/docs/index.md +0 -132
  55. package/docs/interop/A2A.md +0 -39
  56. package/docs/interop/POWERSHELL.md +0 -102
  57. package/docs/manual/00-introduction.md +0 -89
  58. package/docs/manual/01-concepts/01-architecture.md +0 -138
  59. package/docs/manual/01-concepts/02-trust-model.md +0 -183
  60. package/docs/manual/01-concepts/03-theme-engine.md +0 -186
  61. package/docs/manual/01-concepts/04-fleet.md +0 -148
  62. package/docs/manual/01-concepts/05-self-healing.md +0 -204
  63. package/docs/manual/02-tutorials/01-first-install.md +0 -197
  64. package/docs/manual/02-tutorials/02-add-wallpaper.md +0 -216
  65. package/docs/manual/02-tutorials/03-create-profile.md +0 -244
  66. package/docs/manual/02-tutorials/04-encrypt-secret.md +0 -281
  67. package/docs/manual/02-tutorials/05-deploy-fleet.md +0 -283
  68. package/docs/manual/03-reference/01-dot-cli.md +0 -450
  69. package/docs/manual/03-reference/02-config-files.md +0 -265
  70. package/docs/manual/03-reference/03-environment.md +0 -124
  71. package/docs/manual/03-reference/04-templates.md +0 -190
  72. package/docs/manual/03-reference/05-feature-flags.md +0 -187
  73. package/docs/manual/04-cookbook/01-recipes.md +0 -285
  74. package/docs/manual/04-cookbook/02-troubleshooting.md +0 -351
  75. package/docs/manual/04-cookbook/03-faq.md +0 -175
  76. package/docs/manual/05-appendices/A-platform-matrix.md +0 -101
  77. package/docs/manual/05-appendices/B-security-checklist.md +0 -85
  78. package/docs/manual/05-appendices/C-glossary.md +0 -40
  79. package/docs/manual/05-appendices/D-bibliography.md +0 -58
  80. package/docs/manual/05-appendices/E-license.md +0 -38
  81. package/docs/manual/_toc.yml +0 -58
  82. package/docs/manual/command-index.md +0 -155
  83. package/docs/manual/concept-index.md +0 -168
  84. package/docs/manual/index.md +0 -66
  85. package/docs/operations/ARCHITECTURE_ROADMAP.md +0 -7
  86. package/docs/operations/ATTESTATION.md +0 -44
  87. package/docs/operations/CI_CADENCE.md +0 -107
  88. package/docs/operations/CI_COMPOSITES.md +0 -156
  89. package/docs/operations/COMPLETIONS.md +0 -123
  90. package/docs/operations/COVERAGE.md +0 -204
  91. package/docs/operations/DRIFT.md +0 -107
  92. package/docs/operations/HARD_AUDIT_2026.md +0 -631
  93. package/docs/operations/MAINTENANCE.md +0 -63
  94. package/docs/operations/MANIFEST.md +0 -127
  95. package/docs/operations/MIGRATION.md +0 -109
  96. package/docs/operations/OPERATIONS.md +0 -188
  97. package/docs/operations/PERFORMANCE.md +0 -133
  98. package/docs/operations/REGISTRY.md +0 -90
  99. package/docs/operations/RELEASE_PIPELINE.md +0 -128
  100. package/docs/operations/RELIABILITY.md +0 -122
  101. package/docs/operations/RFC_v0_2_503_reorganization.md +0 -280
  102. package/docs/operations/ROADMAP.md +0 -10
  103. package/docs/operations/ROADMAP_2026.md +0 -7
  104. package/docs/operations/ROADMAP_V0_2_503.md +0 -10
  105. package/docs/operations/TESTING.md +0 -216
  106. package/docs/operations/TRACEABILITY.md +0 -43
  107. package/docs/operations/TRUSTED_AGENT_WORKSTATION.md +0 -65
  108. package/docs/operations/VERSION_SYNC.md +0 -393
  109. package/docs/reference/ALIASES.md +0 -131
  110. package/docs/reference/ALIASES_CHEATSHEET.md +0 -32
  111. package/docs/reference/ALIASES_DEPRECATIONS.md +0 -13
  112. package/docs/reference/FEATURES.md +0 -66
  113. package/docs/reference/FONTS.md +0 -112
  114. package/docs/reference/POWERSHELL_PARITY.md +0 -82
  115. package/docs/reference/PROFILES.md +0 -69
  116. package/docs/reference/SCREENSHOTS.md +0 -121
  117. package/docs/reference/SCRIPTS.md +0 -71
  118. package/docs/reference/SUPPORT_MATRIX.md +0 -80
  119. package/docs/reference/THEMES.md +0 -117
  120. package/docs/reference/TOOLS.md +0 -110
  121. package/docs/reference/UTILS.md +0 -242
  122. package/docs/registry.json +0 -6
  123. package/docs/schema/dot-env-v1.json +0 -110
  124. package/docs/schema/dot-registry-v1.json +0 -33
  125. package/docs/security/AI_ACT_COMPLIANCE.md +0 -94
  126. package/docs/security/AUDIT_BYPASS.md +0 -103
  127. package/docs/security/AUTOMATION_SECRETS.md +0 -26
  128. package/docs/security/CI_EGRESS_ALLOWLIST.md +0 -127
  129. package/docs/security/CI_PINNING.md +0 -129
  130. package/docs/security/COMMIT_SIGNING.md +0 -138
  131. package/docs/security/COMPLIANCE.md +0 -458
  132. package/docs/security/DEPS_DEV_EXCEPTIONS.md +0 -86
  133. package/docs/security/DISCLOSURE.md +0 -130
  134. package/docs/security/ENCRYPTION.md +0 -57
  135. package/docs/security/FMEA.md +0 -159
  136. package/docs/security/FUZZING.md +0 -114
  137. package/docs/security/HISTORY_FILTERING.md +0 -132
  138. package/docs/security/INCIDENT_RESPONSE.md +0 -579
  139. package/docs/security/INSTALL_VERIFICATION.md +0 -122
  140. package/docs/security/KEYS.md +0 -49
  141. package/docs/security/KEY_ROTATION.md +0 -303
  142. package/docs/security/MCP_POLICY.md +0 -78
  143. package/docs/security/POLICY_RELEASES.md +0 -37
  144. package/docs/security/README.md +0 -28
  145. package/docs/security/SCORECARD.md +0 -195
  146. package/docs/security/SECRETS.md +0 -158
  147. package/docs/security/SECURITY.md +0 -45
  148. package/docs/security/SECURITY_CHECKLIST.md +0 -55
  149. package/docs/security/SHELL_EXEMPTIONS.md +0 -145
  150. package/docs/security/SOUP_REGISTER.md +0 -36
  151. package/docs/security/THREAT_MODEL.md +0 -130
  152. package/docs/security/VERIFICATION_VALIDATION.md +0 -228
  153. package/docs/security/VERIFY_RELEASE.md +0 -201
  154. package/docs/security/security-pubkey.asc +0 -15
  155. package/docs/stylesheets/extra.css +0 -444
  156. package/docs/themes/README.md +0 -10
  157. package/docs/themes/VISUAL_INTEGRITY_REPORT.md +0 -30
  158. package/docs/themes/hero-shot.svg +0 -78
  159. package/scripts/README.md +0 -123
  160. package/scripts/ci/check-copyright-headers.sh +0 -8
  161. package/scripts/ci/check-shell-preamble.sh +0 -8
  162. package/scripts/ci/guard-gitleaks-checkout.sh +0 -8
  163. package/scripts/demo/record.sh +0 -43
  164. package/scripts/diagnostics/a2a-conformance.sh +0 -163
  165. package/scripts/diagnostics/alias-governance.sh +0 -138
  166. package/scripts/diagnostics/aliases-cheatsheet.sh +0 -74
  167. package/scripts/diagnostics/aliases-manifest.sh +0 -77
  168. package/scripts/diagnostics/benchmark.sh +0 -408
  169. package/scripts/diagnostics/conflicts.sh +0 -73
  170. package/scripts/diagnostics/doctor-unified.sh +0 -39
  171. package/scripts/diagnostics/doctor.sh +0 -751
  172. package/scripts/diagnostics/drift-dashboard.sh +0 -202
  173. package/scripts/diagnostics/health.sh +0 -623
  174. package/scripts/diagnostics/history-analysis.sh +0 -86
  175. package/scripts/diagnostics/mcp-doctor.sh +0 -582
  176. package/scripts/diagnostics/perf.sh +0 -453
  177. package/scripts/diagnostics/scorecard.sh +0 -119
  178. package/scripts/diagnostics/secret-governance.sh +0 -65
  179. package/scripts/diagnostics/security-score.sh +0 -467
  180. package/scripts/diagnostics/smoke-test.sh +0 -88
  181. package/scripts/diagnostics/snapshot.sh +0 -90
  182. package/scripts/diagnostics/verify.sh +0 -108
  183. package/scripts/diagnostics/verify_state.sh +0 -73
  184. package/scripts/diagnostics/version-locks.sh +0 -94
  185. package/scripts/diagnostics/workstation-attestation.sh +0 -187
  186. package/scripts/dot/commands/agent.sh +0 -485
  187. package/scripts/dot/commands/agents.sh +0 -336
  188. package/scripts/dot/commands/ai.sh +0 -587
  189. package/scripts/dot/commands/aliases.sh +0 -277
  190. package/scripts/dot/commands/appearance.sh +0 -110
  191. package/scripts/dot/commands/completion.sh +0 -134
  192. package/scripts/dot/commands/core.sh +0 -217
  193. package/scripts/dot/commands/diagnostics.sh +0 -265
  194. package/scripts/dot/commands/env-emit.sh +0 -203
  195. package/scripts/dot/commands/fleet.sh +0 -688
  196. package/scripts/dot/commands/init.sh +0 -185
  197. package/scripts/dot/commands/lint.sh +0 -208
  198. package/scripts/dot/commands/manual.sh +0 -169
  199. package/scripts/dot/commands/meta.sh +0 -333
  200. package/scripts/dot/commands/patterns.sh +0 -55
  201. package/scripts/dot/commands/registry.sh +0 -419
  202. package/scripts/dot/commands/restore.sh +0 -232
  203. package/scripts/dot/commands/secrets.sh +0 -296
  204. package/scripts/dot/commands/security.sh +0 -102
  205. package/scripts/dot/commands/tools.sh +0 -556
  206. package/scripts/dot/data/alias-deprecations.tsv +0 -2
  207. package/scripts/dot/powershell/Dot.psm1 +0 -319
  208. package/scripts/fonts/install-nerd-fonts.sh +0 -75
  209. package/scripts/fonts/patch-fonts.sh +0 -36
  210. package/scripts/git-hooks/install.sh +0 -12
  211. package/scripts/git-hooks/pre-commit +0 -12
  212. package/scripts/git-hooks/pre-commit-audit.sh +0 -146
  213. package/scripts/git-hooks/pre-push +0 -105
  214. package/scripts/git-hooks/prepare-commit-msg +0 -29
  215. package/scripts/lib/secrets_provider.sh +0 -185
  216. package/scripts/ops/ai-setup.sh +0 -71
  217. package/scripts/ops/bundle.sh +0 -104
  218. package/scripts/ops/chaos.sh +0 -50
  219. package/scripts/ops/chezmoi-apply.sh +0 -333
  220. package/scripts/ops/chezmoi-diff.sh +0 -16
  221. package/scripts/ops/chezmoi-remove.sh +0 -46
  222. package/scripts/ops/chezmoi-update.sh +0 -63
  223. package/scripts/ops/heal-chezmoi.sh +0 -87
  224. package/scripts/ops/heal-system.sh +0 -129
  225. package/scripts/ops/heal-tools.sh +0 -297
  226. package/scripts/ops/heal.sh +0 -223
  227. package/scripts/ops/post-apply-repair.sh +0 -107
  228. package/scripts/ops/prewarm.sh +0 -128
  229. package/scripts/ops/release.sh +0 -262
  230. package/scripts/ops/rollback.sh +0 -604
  231. package/scripts/ops/setup.sh +0 -138
  232. package/scripts/ops/teleport.sh +0 -34
  233. package/scripts/qa/check-version-consistency.sh +0 -124
  234. package/scripts/qa/coverage-baseline.sh +0 -61
  235. package/scripts/qa/docs-coverage.sh +0 -112
  236. package/scripts/qa/examples-coverage.sh +0 -94
  237. package/scripts/qa/powershell-contract.ps1 +0 -95
  238. package/scripts/qa/reliability-audit.sh +0 -139
  239. package/scripts/qa/scorecard-snapshot.sh +0 -128
  240. package/scripts/qa/traceability-coverage.sh +0 -117
  241. package/scripts/qa/validate-examples.sh +0 -27
  242. package/scripts/qa/wsl-contract.sh +0 -12
  243. package/scripts/secrets/age-init.sh +0 -82
  244. package/scripts/secrets/create-secrets-file.sh +0 -46
  245. package/scripts/secrets/encrypt-ssh-key.sh +0 -44
  246. package/scripts/security/backup.sh +0 -58
  247. package/scripts/security/check-disclosure-key-expiry.sh +0 -111
  248. package/scripts/security/dns-doh.sh +0 -52
  249. package/scripts/security/encryption-check.sh +0 -55
  250. package/scripts/security/enforce-policies.sh +0 -335
  251. package/scripts/security/firewall.sh +0 -91
  252. package/scripts/security/lock-configs.sh +0 -67
  253. package/scripts/security/lock-screen.sh +0 -56
  254. package/scripts/security/manage-secrets.sh +0 -429
  255. package/scripts/security/ssh-cert.sh +0 -204
  256. package/scripts/security/telemetry-kill.sh +0 -51
  257. package/scripts/security/usb-safety.sh +0 -52
  258. package/scripts/theme/apply-gnome-theme.sh +0 -333
  259. package/scripts/theme/extract-heic-frames.sh +0 -115
  260. package/scripts/theme/extract-theme.py +0 -742
  261. package/scripts/theme/install-boot-logo.sh +0 -63
  262. package/scripts/theme/install-catppuccin-themes.sh +0 -371
  263. package/scripts/theme/install-cursors.sh +0 -26
  264. package/scripts/theme/install-file-icons.sh +0 -27
  265. package/scripts/theme/install-grub-theme.sh +0 -62
  266. package/scripts/theme/install-lock-icon.sh +0 -31
  267. package/scripts/theme/merge-wallpaper.sh +0 -146
  268. package/scripts/theme/rebuild-themes.sh +0 -544
  269. package/scripts/theme/switch.sh +0 -449
  270. package/scripts/theme/wallpaper-rotate.sh +0 -137
  271. package/scripts/theme/wallpaper-sync.sh +0 -690
  272. package/scripts/tools/cmatrix.sh +0 -22
  273. package/scripts/tools/detect-collisions.py +0 -103
  274. package/scripts/tools/emoji-picker.sh +0 -49
  275. package/scripts/tools/figlet-banner.sh +0 -19
  276. package/scripts/tools/log-rotate.sh +0 -31
  277. package/scripts/tools/lolcat-wrap.sh +0 -20
  278. package/scripts/tools/pipes.sh +0 -49
  279. package/scripts/tuning/linux.sh +0 -186
  280. package/scripts/tuning/macos.sh +0 -56
  281. package/scripts/uninstall.sh +0 -86
  282. package/scripts/version-sync.sh +0 -654
  283. package/templates/chezmoi-data/geekom-a9.toml.example +0 -21
  284. package/templates/chezmoi-data/mac-m1.toml.example +0 -16
  285. package/templates/chezmoi-data/mac-t2-linux.toml.example +0 -21
  286. package/templates/chezmoi-data/surface-pro-7p.toml.example +0 -21
  287. package/templates/projects/go/.github/workflows/ci.yml +0 -31
  288. package/templates/projects/go/README.md +0 -7
  289. package/templates/projects/go/cmd/__PROJECT_NAME__/main.go +0 -8
  290. package/templates/projects/go/go.mod +0 -3
  291. package/templates/projects/go/go.sum +0 -0
  292. package/templates/projects/molecule/README.md +0 -7
  293. package/templates/projects/molecule/converge.yml +0 -7
  294. package/templates/projects/molecule/molecule.yml +0 -16
  295. package/templates/projects/node/.github/workflows/ci.yml +0 -30
  296. package/templates/projects/node/README.md +0 -7
  297. package/templates/projects/node/package-lock.json +0 -12
  298. package/templates/projects/node/package.json +0 -10
  299. package/templates/projects/node/src/index.js +0 -3
  300. package/templates/projects/packer/README.md +0 -15
  301. package/templates/projects/packer/main.pkr.hcl +0 -15
  302. package/templates/projects/python/.github/workflows/ci.yml +0 -34
  303. package/templates/projects/python/README.md +0 -7
  304. package/templates/projects/python/pyproject.toml +0 -25
  305. package/templates/projects/python/src/__PROJECT_NAME__/__init__.py +0 -2
  306. package/templates/projects/python/tests/test_basic.py +0 -3
@@ -1,485 +0,0 @@
1
- #!/usr/bin/env bash
2
- # SPDX-License-Identifier: MIT
3
- # Copyright (c) 2015-2026 Sebastien Rousseau
4
- # Dotfiles CLI - Agent Mode Commands (extracted from meta.sh)
5
- # mode list|current|show|set|run|doctor|card|log|checkpoint|conformance
6
-
7
- set -euo pipefail
8
-
9
- # Guard: only define functions, do not execute on source.
10
- # These functions are sourced by meta.sh for dispatch.
11
-
12
- _agent_repo_root() {
13
- # Post-Phase-4b: agent profile/card JSON ships under defaults/dot_config/.
14
- # Prefer the chezmoi source dir so callers can append dot_config/... directly.
15
- local dir
16
- dir="$(resolve_chezmoi_source_dir)"
17
- [[ -n "$dir" ]] && {
18
- printf '%s\n' "$dir"
19
- return
20
- }
21
- require_source_dir
22
- }
23
-
24
- _agent_profiles_file() {
25
- local repo_root
26
- repo_root="$(_agent_repo_root)"
27
- echo "${AGENT_PROFILE_CONFIG:-$repo_root/dot_config/dotfiles/agent-profiles.json}"
28
- }
29
-
30
- _agent_state_file() {
31
- echo "${AGENT_STATE_FILE:-$HOME/.config/dotfiles/agent-mode.env}"
32
- }
33
-
34
- _agent_default_profile() {
35
- local file
36
- file="$(_agent_profiles_file)"
37
- jq -r '.defaultProfile' "$file"
38
- }
39
-
40
- _agent_current_profile() {
41
- local state_file current
42
- state_file="$(_agent_state_file)"
43
- if [[ -f "$state_file" ]]; then
44
- current="$(sed -n 's/^DOT_AGENT_PROFILE=//p' "$state_file" | tail -n 1)"
45
- if [[ -n "$current" ]]; then
46
- echo "$current"
47
- return 0
48
- fi
49
- fi
50
- _agent_default_profile
51
- }
52
-
53
- _agent_profile_exists() {
54
- local name="$1"
55
- jq -e --arg name "$name" '.profiles[$name]' "$(_agent_profiles_file)" >/dev/null 2>&1
56
- }
57
-
58
- _agent_profile_field() {
59
- local name="$1" field="$2"
60
- jq -r --arg name "$name" --arg field "$field" '.profiles[$name][$field]' "$(_agent_profiles_file)"
61
- }
62
-
63
- _agent_assert_dependencies() {
64
- local file
65
- file="$(_agent_profiles_file)"
66
- if [[ ! -f "$file" ]]; then
67
- die "Agent profile config not found: $file"
68
- fi
69
- if ! command -v jq >/dev/null 2>&1; then
70
- die "jq is required for dot mode"
71
- fi
72
- }
73
-
74
- _agent_card_file() {
75
- local repo_root
76
- repo_root="$(_agent_repo_root)"
77
- echo "${AGENT_CARD_CONFIG:-$repo_root/dot_config/dotfiles/agent-card.json}"
78
- }
79
-
80
- _agent_checkpoint_file() {
81
- local checkpoint_id="$1"
82
- echo "$(dot_agent_checkpoint_dir)/${checkpoint_id}.json"
83
- }
84
-
85
- _agent_apply_profile_env() {
86
- local name="$1"
87
- export DOT_AGENT_PROFILE="$name"
88
- # Split declare-and-assign to avoid masking the field-getter's exit
89
- # code (SC2155). If the profile JSON is malformed, the assignment
90
- # now fails the function instead of silently exporting an empty value.
91
- local approval filesystem network mcp_profile max_steps tuple
92
- # One jq read of all five policy fields (was five separate jq processes on
93
- # every profile application). `|| return 1` preserves fail-on-malformed.
94
- tuple="$(jq -r --arg name "$name" \
95
- '.profiles[$name] | [.approval, .filesystem, .network, .mcpProfile, .maxSteps] | @tsv' \
96
- "$(_agent_profiles_file)")" || return 1
97
- IFS=$'\t' read -r approval filesystem network mcp_profile max_steps <<<"$tuple"
98
- export DOT_AGENT_APPROVAL="$approval"
99
- export DOT_AGENT_FILESYSTEM="$filesystem"
100
- export DOT_AGENT_NETWORK="$network"
101
- export DOT_AGENT_MCP_PROFILE="$mcp_profile"
102
- export DOT_AGENT_MAX_STEPS="$max_steps"
103
- }
104
-
105
- _agent_rbac_enforcement() {
106
- local file
107
- file="$(_agent_profiles_file)"
108
- jq -r '.rbac.enforcement // "advisory"' "$file"
109
- }
110
-
111
- _agent_current_role() {
112
- local state_file role
113
- state_file="$(_agent_state_file)"
114
- if [[ -f "$state_file" ]]; then
115
- role="$(sed -n 's/^DOT_AGENT_ROLE=//p' "$state_file" | tail -n 1)"
116
- if [[ -n "$role" ]]; then
117
- echo "$role"
118
- return 0
119
- fi
120
- fi
121
- jq -r '.rbac.defaultRole // "developer"' "$(_agent_profiles_file)"
122
- }
123
-
124
- _agent_role_allows_profile() {
125
- local role="$1" profile="$2"
126
- local file
127
- file="$(_agent_profiles_file)"
128
- jq -e --arg role "$role" --arg profile "$profile" '
129
- .rbac.roles[$role].allowedProfiles // [] | index($profile)
130
- ' "$file" >/dev/null 2>&1
131
- }
132
-
133
- _agent_enforce_rbac() {
134
- local target_profile="$1"
135
- local enforcement role
136
- enforcement="$(_agent_rbac_enforcement)"
137
- role="$(_agent_current_role)"
138
- if _agent_role_allows_profile "$role" "$target_profile"; then
139
- return 0
140
- fi
141
- if [[ "$enforcement" == "strict" ]]; then
142
- die "RBAC: role '$role' is not allowed to use profile '$target_profile' (enforcement: strict)"
143
- else
144
- ui_warn "RBAC" "role '$role' is not recommended for profile '$target_profile' (enforcement: advisory)"
145
- fi
146
- }
147
-
148
- cmd_mode() {
149
- _agent_assert_dependencies
150
-
151
- local subcommand="${1:-current}"
152
- if [[ -z "${1:-}" ]] || [[ "${1:-}" == --* ]]; then
153
- subcommand="current"
154
- else
155
- shift || true
156
- fi
157
-
158
- case "$subcommand" in
159
- list)
160
- local current
161
- current="$(_agent_current_profile)"
162
- dot_agent_session_log "list" "$current" "ok"
163
- ui_header "Agent Modes"
164
- jq -r '.profiles | to_entries[] | "\(.key)\t\(.value.description)"' "$(_agent_profiles_file)" |
165
- while IFS=$'\t' read -r name description; do
166
- if [[ "$name" == "$current" ]]; then
167
- ui_ok "$name" "$description [current]"
168
- else
169
- ui_info "$name" "$description"
170
- fi
171
- done
172
- ;;
173
- current)
174
- local current
175
- current="$(_agent_current_profile)"
176
- dot_agent_session_log "current" "$current" "ok"
177
- ui_header "Agent Mode"
178
- ui_ok "Profile" "$current"
179
- ui_ok "Approval" "$(_agent_profile_field "$current" "approval")"
180
- ui_ok "Filesystem" "$(_agent_profile_field "$current" "filesystem")"
181
- ui_ok "Network" "$(_agent_profile_field "$current" "network")"
182
- ui_ok "MCP" "$(_agent_profile_field "$current" "mcpProfile")"
183
- ;;
184
- show)
185
- local name="${1:-}"
186
- [[ -n "$name" ]] || die "Usage: dot mode show <profile>"
187
- _agent_profile_exists "$name" || die "Unknown agent profile: $name"
188
- dot_agent_session_log "show" "$name" "ok"
189
- ui_header "Agent Mode"
190
- ui_ok "Profile" "$name"
191
- ui_ok "Description" "$(_agent_profile_field "$name" "description")"
192
- ui_ok "Approval" "$(_agent_profile_field "$name" "approval")"
193
- ui_ok "Filesystem" "$(_agent_profile_field "$name" "filesystem")"
194
- ui_ok "Network" "$(_agent_profile_field "$name" "network")"
195
- ui_ok "Max steps" "$(_agent_profile_field "$name" "maxSteps")"
196
- ui_ok "MCP" "$(_agent_profile_field "$name" "mcpProfile")"
197
- ;;
198
- set)
199
- local name="${1:-}" state_file
200
- [[ -n "$name" ]] || die "Usage: dot mode set <profile>"
201
- _agent_profile_exists "$name" || die "Unknown agent profile: $name"
202
- _agent_enforce_rbac "$name"
203
- state_file="$(_agent_state_file)"
204
- mkdir -p "$(dirname "$state_file")"
205
- cat >"$state_file" <<EOF
206
- DOT_AGENT_PROFILE=$name
207
- DOT_AGENT_APPROVAL=$(_agent_profile_field "$name" "approval")
208
- DOT_AGENT_FILESYSTEM=$(_agent_profile_field "$name" "filesystem")
209
- DOT_AGENT_NETWORK=$(_agent_profile_field "$name" "network")
210
- DOT_AGENT_MCP_PROFILE=$(_agent_profile_field "$name" "mcpProfile")
211
- DOT_AGENT_MAX_STEPS=$(_agent_profile_field "$name" "maxSteps")
212
- EOF
213
- dot_agent_session_log "set" "$name" "ok" "state_file=$state_file"
214
- ui_ok "Agent mode" "$name"
215
- ui_info "State file" "$state_file"
216
- ;;
217
- run)
218
- local name="${1:-}" current
219
- if [[ -n "$name" ]] && _agent_profile_exists "$name"; then
220
- shift || true
221
- else
222
- name="$(_agent_current_profile)"
223
- fi
224
- [[ $# -gt 0 ]] || die "Usage: dot mode run [profile] <command> [args...]"
225
- _agent_apply_profile_env "$name"
226
- local checkpoint_file checkpoint_id
227
- checkpoint_file="$(dot_agent_checkpoint_create "$name" "ready" "$@")"
228
- checkpoint_id="$(basename "$checkpoint_file" .json)"
229
- ui_info "Agent mode" "$name"
230
- dot_agent_session_log "run_start" "$name" "running" "argv=$*" "checkpoint_id=$checkpoint_id"
231
- # `if !` instead of `set +e / "$@" / set -e` — bash's errexit
232
- # is automatically suspended inside a conditional, so we capture
233
- # the exit code cleanly without toggling shell options.
234
- local exit_code=0
235
- if ! "$@"; then
236
- exit_code=$?
237
- dot_agent_session_log "run_finish" "$name" "failed" "exit_code=$exit_code" "checkpoint_id=$checkpoint_id"
238
- else
239
- dot_agent_session_log "run_finish" "$name" "ok" "exit_code=$exit_code" "checkpoint_id=$checkpoint_id"
240
- fi
241
- return "$exit_code"
242
- ;;
243
- doctor)
244
- local file
245
- file="$(_agent_profiles_file)"
246
- dot_agent_session_log "doctor" "$(_agent_current_profile)" "ok"
247
- ui_header "Agent Mode Doctor"
248
- if jq empty "$file" >/dev/null 2>&1; then
249
- ui_ok "Profile config" "$file"
250
- else
251
- die "Invalid JSON: $file"
252
- fi
253
- jq -e '.profiles[.defaultProfile]' "$file" >/dev/null 2>&1 || die "Default profile missing"
254
- ui_ok "Default profile" "$(_agent_default_profile)"
255
- ;;
256
- card)
257
- local card_file json_mode=0
258
- card_file="$(_agent_card_file)"
259
- [[ -f "$card_file" ]] || die "Agent card not found: $card_file"
260
- if [[ "${1:-}" == "--json" ]]; then
261
- json_mode=1
262
- fi
263
- dot_agent_session_log "card" "$(_agent_current_profile)" "ok"
264
- if [[ "$json_mode" -eq 1 ]] || ! command -v jq >/dev/null 2>&1; then
265
- exec cat "$card_file"
266
- fi
267
- ui_header "Agent Card"
268
- jq -r '
269
- "Name\t\(.name)",
270
- "Version\t\(.version)",
271
- "Protocols\t\(.protocols | join(", "))",
272
- "Default mode\t\(.defaultProfile)",
273
- "Support\t\(.platforms | join(", "))"
274
- ' "$card_file" | while IFS=$'\t' read -r key value; do
275
- ui_ok "$key" "$value"
276
- done
277
- ;;
278
- log)
279
- dot_agent_session_log "log" "$(_agent_current_profile)" "ok"
280
- dot_agent_session_tail "${1:-20}"
281
- ;;
282
- checkpoint)
283
- local action="${1:-list}"
284
- shift || true
285
- case "$action" in
286
- save)
287
- local name="${1:-}" checkpoint_file checkpoint_id
288
- if [[ -n "$name" ]] && _agent_profile_exists "$name"; then
289
- shift || true
290
- else
291
- name="$(_agent_current_profile)"
292
- fi
293
- [[ $# -gt 0 ]] || die "Usage: dot agent checkpoint save [profile] <command> [args...]"
294
- _agent_apply_profile_env "$name"
295
- checkpoint_file="$(dot_agent_checkpoint_create "$name" "saved" "$@")"
296
- checkpoint_id="$(basename "$checkpoint_file" .json)"
297
- dot_agent_session_log "checkpoint_save" "$name" "ok" "checkpoint_id=$checkpoint_id"
298
- ui_header "Agent Checkpoint"
299
- ui_ok "ID" "$checkpoint_id"
300
- ui_ok "Profile" "$name"
301
- ui_ok "Command" "$*"
302
- ui_ok "File" "$checkpoint_file"
303
- ;;
304
- list)
305
- local count="${1:-20}"
306
- dot_agent_session_log "checkpoint_list" "$(_agent_current_profile)" "ok"
307
- if ! command -v jq >/dev/null 2>&1; then
308
- dot_agent_checkpoint_tail "$count"
309
- return 0
310
- fi
311
- ui_header "Agent Checkpoints"
312
- dot_agent_checkpoint_tail "$count" | jq -r '"\(.id)\t\(.profile)\t\(.status)\t\(.created_at)\t\(.argv | join(" "))"' | while IFS=$'\t' read -r id profile status created_at argv; do
313
- ui_ok "$id" "$profile / $status / $created_at / $argv"
314
- done
315
- ;;
316
- show)
317
- local checkpoint_id="${1:-}" checkpoint_file json_mode=0
318
- [[ -n "$checkpoint_id" ]] || die "Usage: dot agent checkpoint show <id> [--json]"
319
- shift || true
320
- [[ "${1:-}" == "--json" || "${1:-}" == "-j" ]] && json_mode=1
321
- checkpoint_file="$(_agent_checkpoint_file "$checkpoint_id")"
322
- [[ -f "$checkpoint_file" ]] || die "Checkpoint not found: $checkpoint_id"
323
- dot_agent_session_log "checkpoint_show" "$(_agent_current_profile)" "ok" "checkpoint_id=$checkpoint_id"
324
- if [[ "$json_mode" -eq 1 ]] || ! command -v jq >/dev/null 2>&1; then
325
- exec cat "$checkpoint_file"
326
- fi
327
- ui_header "Agent Checkpoint"
328
- jq -r '"ID\t\(.id)",
329
- "Profile\t\(.profile)",
330
- "Status\t\(.status)",
331
- "Created\t\(.created_at)",
332
- "Command\t\(.argv | join(" "))"' "$checkpoint_file" | while IFS=$'\t' read -r key value; do
333
- ui_ok "$key" "$value"
334
- done
335
- ;;
336
- replay)
337
- local checkpoint_id="${1:-}" checkpoint_file replay_profile
338
- local -a replay_argv=()
339
- [[ -n "$checkpoint_id" ]] || die "Usage: dot agent checkpoint replay <id>"
340
- checkpoint_file="$(_agent_checkpoint_file "$checkpoint_id")"
341
- [[ -f "$checkpoint_file" ]] || die "Checkpoint not found: $checkpoint_id"
342
- replay_profile="$(jq -r '.profile' "$checkpoint_file")"
343
- while IFS= read -r item; do
344
- replay_argv+=("$item")
345
- done < <(jq -r '.argv[]' "$checkpoint_file")
346
- [[ "${#replay_argv[@]}" -gt 0 ]] || die "Checkpoint has no replayable command: $checkpoint_id"
347
- _agent_apply_profile_env "$replay_profile"
348
- dot_agent_session_log "checkpoint_replay" "$replay_profile" "running" "checkpoint_id=$checkpoint_id"
349
- local exit_code=0
350
- if ! "${replay_argv[@]}"; then
351
- exit_code=$?
352
- dot_agent_session_log "checkpoint_replay_finish" "$replay_profile" "failed" "checkpoint_id=$checkpoint_id" "exit_code=$exit_code"
353
- else
354
- dot_agent_session_log "checkpoint_replay_finish" "$replay_profile" "ok" "checkpoint_id=$checkpoint_id" "exit_code=$exit_code"
355
- fi
356
- return "$exit_code"
357
- ;;
358
- *)
359
- echo "Usage: dot agent checkpoint [save|list|show|replay]" >&2
360
- exit 1
361
- ;;
362
- esac
363
- ;;
364
- delegate)
365
- local delegate_name="${1:-}"
366
- [[ -n "$delegate_name" ]] || die "Usage: dot agent delegate <name> <command> [args...]"
367
- shift || true
368
- [[ $# -gt 0 ]] || die "Usage: dot agent delegate <name> <command> [args...]"
369
- local profiles_file current_profile
370
- profiles_file="$(_agent_profiles_file)"
371
- current_profile="$(_agent_current_profile)"
372
- # Check delegation is enabled
373
- local delegation_enabled
374
- delegation_enabled="$(jq -r '.delegation.enabled // false' "$profiles_file")"
375
- [[ "$delegation_enabled" == "true" ]] || die "Delegation is not enabled in agent-profiles.json"
376
- # Check current profile can delegate
377
- local can_delegate
378
- can_delegate="$(jq -r --arg p "$current_profile" '.profiles[$p].canDelegate // false' "$profiles_file")"
379
- [[ "$can_delegate" == "true" ]] || die "Profile '$current_profile' cannot delegate"
380
- # Check delegate name exists
381
- jq -e --arg d "$delegate_name" '.delegation.allowedDelegates[$d]' "$profiles_file" >/dev/null 2>&1 || die "Unknown delegate: $delegate_name"
382
- # Read delegate config
383
- local delegate_profile delegate_timeout delegate_max_steps
384
- delegate_profile="$(jq -r --arg d "$delegate_name" '.delegation.allowedDelegates[$d].profile' "$profiles_file")"
385
- delegate_timeout="$(jq -r --arg d "$delegate_name" '.delegation.allowedDelegates[$d].timeout // 300' "$profiles_file")"
386
- delegate_max_steps="$(jq -r --arg d "$delegate_name" '.delegation.allowedDelegates[$d].maxSteps // 4' "$profiles_file")"
387
- # Apply delegate profile env
388
- _agent_apply_profile_env "$delegate_profile"
389
- export DOT_AGENT_MAX_STEPS="$delegate_max_steps"
390
- export DOT_AGENT_DELEGATE="$delegate_name"
391
- export DOT_AGENT_PARENT_PROFILE="$current_profile"
392
- dot_agent_session_log "delegate_start" "$delegate_profile" "running" "delegate=$delegate_name" "parent=$current_profile" "timeout=$delegate_timeout"
393
- ui_info "Delegating" "$delegate_name (profile: $delegate_profile, timeout: ${delegate_timeout}s)"
394
- local exit_code=0
395
- if ! timeout "$delegate_timeout" "$@"; then
396
- exit_code=$?
397
- dot_agent_session_log "delegate_finish" "$delegate_profile" "failed" "delegate=$delegate_name" "exit_code=$exit_code"
398
- ui_err "Delegate" "$delegate_name failed (exit $exit_code)"
399
- else
400
- dot_agent_session_log "delegate_finish" "$delegate_profile" "ok" "delegate=$delegate_name" "exit_code=$exit_code"
401
- ui_ok "Delegate" "$delegate_name completed"
402
- fi
403
- return "$exit_code"
404
- ;;
405
- a2a-card)
406
- local a2a_card_file json_mode=0 validate_mode=0 strict_mode=0
407
- local repo_root
408
- # `.well-known/` is NOT chezmoi-tracked — it lives at the
409
- # actual repo root, not the descended `defaults/` subdir.
410
- # Bypass `_agent_repo_root` (which descends) and read the
411
- # true root directly.
412
- repo_root="$(require_source_dir)"
413
- a2a_card_file="$repo_root/.well-known/agent-card.json"
414
- while [[ $# -gt 0 ]]; do
415
- case "$1" in
416
- --json | -j)
417
- json_mode=1
418
- shift
419
- ;;
420
- --validate | --strict | -s)
421
- validate_mode=1
422
- strict_mode=1
423
- shift
424
- ;;
425
- *) shift ;;
426
- esac
427
- done
428
- [[ -f "$a2a_card_file" ]] || die "A2A v0.3 card not found: $a2a_card_file"
429
- dot_agent_session_log "a2a-card" "$(_agent_current_profile)" "ok"
430
- if [[ "$json_mode" -eq 1 ]]; then
431
- exec cat "$a2a_card_file"
432
- fi
433
- if [[ "$validate_mode" -eq 1 ]]; then
434
- local v_issues=0
435
- jq empty "$a2a_card_file" >/dev/null 2>&1 || {
436
- ui_err "JSON" "invalid"
437
- exit 1
438
- }
439
- ui_header "A2A v0.3 Card Validation"
440
- local sv
441
- sv="$(jq -r '.specVersion // empty' "$a2a_card_file")"
442
- if [[ "$sv" == "0.3" ]]; then ui_ok "specVersion" "$sv"; else
443
- ui_err "specVersion" "expected 0.3, got $sv"
444
- v_issues=$((v_issues + 1))
445
- fi
446
- if jq -e '.skills | type == "array" and length > 0' "$a2a_card_file" >/dev/null 2>&1; then
447
- ui_ok "skills" "$(jq '.skills | length' "$a2a_card_file") skills"
448
- else
449
- ui_err "skills" "missing or empty"
450
- v_issues=$((v_issues + 1))
451
- fi
452
- if jq -e '.authentication' "$a2a_card_file" >/dev/null 2>&1; then ui_ok "authentication" "present"; else
453
- ui_err "authentication" "missing"
454
- v_issues=$((v_issues + 1))
455
- fi
456
- if jq -e '.signing.method' "$a2a_card_file" >/dev/null 2>&1; then ui_ok "signing" "$(jq -r '.signing.method' "$a2a_card_file")"; else
457
- ui_err "signing" "missing method"
458
- v_issues=$((v_issues + 1))
459
- fi
460
- if [[ "$v_issues" -gt 0 && "$strict_mode" -eq 1 ]]; then exit 1; fi
461
- return 0
462
- fi
463
- ui_header "A2A v0.3 Agent Card"
464
- jq -r '
465
- "Name\t\(.name)",
466
- "Version\t\(.version)",
467
- "Spec\t\(.specVersion)",
468
- "Protocols\t\(.protocols | join(", "))",
469
- "Skills\t\(.skills | length) defined",
470
- "Auth\t\(.authentication.schemes | join(", "))",
471
- "Signing\t\(.signing.method)"
472
- ' "$a2a_card_file" | while IFS=$'\t' read -r key value; do
473
- ui_ok "$key" "$value"
474
- done
475
- ;;
476
- conformance)
477
- dot_agent_session_log "conformance" "$(_agent_current_profile)" "ok"
478
- run_script "scripts/diagnostics/a2a-conformance.sh" "A2A conformance script" "$@"
479
- ;;
480
- *)
481
- echo "Usage: dot mode [list|current|show|set|run|doctor|card|log|checkpoint|conformance|a2a-card]" >&2
482
- exit 1
483
- ;;
484
- esac
485
- }