diff --git a/.agents/skills/managing-nono-profiles/SKILL.md b/.agents/skills/managing-nono-profiles/SKILL.md index d925a53b..67090e4d 100644 --- a/.agents/skills/managing-nono-profiles/SKILL.md +++ b/.agents/skills/managing-nono-profiles/SKILL.md @@ -1,6 +1,6 @@ --- name: managing-nono-profiles -description: Manage nono sandbox profiles and their shell launch wrappers in this dotfiles repo. Use when editing private_dot_config/nono/profiles, nono profile schemas, dot_agents/shell wrappers, SSH signing access for sandboxed agents, or adding/renaming agent-specific nono profiles. +description: Manage nono sandbox profiles and their shell launch wrappers in this dotfiles repo. Use when editing private_dot_config/nono/profiles, nono profile schemas, dot_agents/shell wrappers, employer-specific work-* profiles and launchers under private_dot_work, SSH signing access for sandboxed agents, or adding/renaming agent-specific nono profiles. --- # Managing Nono Profiles @@ -19,8 +19,12 @@ Edit chezmoi source files, not applied targets: | Profile schema | `private_dot_config/nono/schemas/nono-profile.schema.json` | `~/.config/nono/schemas/nono-profile.schema.json` | | Agent shell wrappers | `dot_agents/shell/` | `~/.agents/shell/` | | Wrapper sourcing | `dot_zshrc.tmpl` | `~/.zshrc` | +| Employer profiles | `private_dot_config/nono/profiles/work-{work_name}-*.jsonc` | `~/.config/nono/profiles/work-{work_name}-*.jsonc` | +| Employer profile filtering | `.chezmoiignore` | — | +| Employer launchers | `private_dot_work/private_{work_name}/agents/shell/` | `~/.work/{work_name}/agents/shell/` | +| Employer launcher sourcing | `private_dot_work/private_{work_name}/zsh/dot_zshrc.tmpl` | `~/.work/{work_name}/zsh/.zshrc` | -`.zshrc` sources `~/.agents/shell/nono.zsh` first, then per-agent shell files, only when `nono` is installed. +`.zshrc` sources `~/.agents/shell/nono.zsh` first, then per-agent shell files, only when `nono` is installed. The employer zshrc extension sources the employer launchers, also only when `nono` is installed. ## Core Rule @@ -35,6 +39,19 @@ When adding or renaming a profile: Example: profile `claude-code-go` should have a profile file named `claude-code-go.jsonc`, `meta.name: "claude-code-go"`, and a wrapper that calls `nono run --profile claude-code-go`. +## Employer-Specific Profiles + +Profiles that serve a single employer or employer project are named `work-{work_name}-` and are installed only on that employer's machines. Their launchers belong to the employer's work tree, not to `dot_agents/shell/`. + +1. Add the profile to `private_dot_config/nono/profiles/` as `work-{work_name}-.jsonc`, with the same `meta.name`. List `work-{work_name}-common` first in `extends`, followed by the personal profiles the project needs. +2. Make sure `.chezmoiignore` has a block that ignores `.config/nono/profiles/work-{work_name}-*` unless `personal.work_env` is true and `personal.work_name` matches. Each employer needs one block, not one entry per profile. +3. Add the launcher function to the matching agent file in `private_dot_work/private_{work_name}/agents/shell/`, calling the shared helper with the profile name (for example `_claude_nono work-sedg-claude-code-energy-runtime`). +4. For a new employer launcher file, source it from `private_dot_work/private_{work_name}/zsh/dot_zshrc.tmpl` inside the existing `command -v nono` block. + +Each employer project gets its own profile and launcher; there are no employer variants of the general launchers such as `claude-go`. `work-{work_name}-common` is agent-neutral: it holds the access every project of that employer needs regardless of agent (employer domains, credentials, tool config), extends nothing, and is shared by employer profiles of any agent. Put agent-specific employer access in a separate `work-{work_name}--common` profile. Keep employer access out of personal profiles such as `my-claude-code`. + +Employer profiles may extend personal profiles by name (for example `claude-code-go`). Renaming a personal profile requires updating those `extends` entries. + ## Path Conventions Prefer portable nono variables over `~` and absolute machine paths: diff --git a/.chezmoiignore b/.chezmoiignore index 0fdc2a7b..bd2c5a7a 100644 --- a/.chezmoiignore +++ b/.chezmoiignore @@ -35,3 +35,7 @@ Taskfile.yml .agents/shell/claude.zsh .config/nono/profiles/my-claude-code.jsonc {{- end }} + +{{- if not (and .personal.work_env (eq .personal.work_name "sedg")) }} +.config/nono/profiles/work-sedg-* # only install sedg profiles on sedg work machines +{{- end }} diff --git a/docs/dotfiles/domain.md b/docs/dotfiles/domain.md index a10900bc..8024e829 100644 --- a/docs/dotfiles/domain.md +++ b/docs/dotfiles/domain.md @@ -20,6 +20,8 @@ The project implements a two-tier model for separating personal and work configu | Generic work profile | `~/.work/profile` | Cross-employer shared config — sets `WORK_DIR`, `WORK_EXECUTABLES_DIR`, and shell extension paths (`WORK_ZSH_ENV_EXTENSION`, `WORK_ZSH_RC_EXTENSION`) | | Specific work profile | `~/.work/{work_name}/profile` | Employer-specific config — sourced by the generic profile | +Both profiles export their path variables, so shells started from an already-initialized shell (subshells, tmux panes) still find the shell extensions even though the profiles are not sourced again. + The generic profile delegates to the specific profile. Both layers produce shell extension files (`.zshenv` and `.zshrc` fragments) that are sourced during shell startup. See the [work environment loading process][work-env-loading] for the full loading flow. **File structure in chezmoi source:** @@ -32,11 +34,14 @@ private_dot_work/ │ └── dot_zshrc.tmpl # Generic work zshrc extension └── private_{work_name}/ ├── profile # Employer-specific profile + ├── agents/shell/ # Employer-specific agent launchers, sourced by the zshrc extension └── zsh/ ├── dot_zshenv.tmpl # Employer-specific zshenv extension └── dot_zshrc.tmpl # Employer-specific zshrc extension ``` +**Employer-specific nono profiles:** Employer profiles live with the personal profiles in `~/.config/nono/profiles/`, named `work-{work_name}-*`. A `.chezmoiignore` block per employer skips them unless `personal.work_env` is true and `personal.work_name` matches. Each employer project has its own profile and launcher. Project profiles extend `work-{work_name}-common`, an agent-neutral profile that holds the employer's shared access (domains, credentials, tool config), plus the personal profiles they need. The launchers live in `~/.work/{work_name}/agents/shell/` and call the shared wrapper helpers from `~/.agents/shell/` with these profile names. + ### Deferred Homebrew Loading A shell startup optimization pattern where Homebrew's expensive `shellenv` evaluation is postponed from `.zshenv` to `.zshrc` on macOS. This avoids the cost in non-interactive shells while keeping the environment available for interactive use. diff --git a/docs/dotfiles/processes/work-environment-loading.md b/docs/dotfiles/processes/work-environment-loading.md index 8cbdfa95..d348ef90 100644 --- a/docs/dotfiles/processes/work-environment-loading.md +++ b/docs/dotfiles/processes/work-environment-loading.md @@ -109,9 +109,9 @@ Result: Work-specific environment variables, paths, aliases, and functions are a ## State Changes -- **Environment variables**: `WORK_DIR`, `WORK_EXECUTABLES_DIR`, `WORK_ZSH_DIR`, `WORK_ZSH_RC_EXTENSION`, `WORK_ZSH_ENV_EXTENSION`, `WORK_ENV_LOADED`, plus any employer-specific variables +- **Environment variables** (exported): `WORK_DIR`, `WORK_EXECUTABLES_DIR`, `WORK_ZSH_DIR`, `WORK_ZSH_RC_EXTENSION`, `WORK_ZSH_ENV_EXTENSION`, `WORK_ENV_LOADED`, plus employer-specific path variables (e.g., `SEDG_ZSH_RC_EXTENSION`, `SEDG_AGENTS_SHELL_DIR`). Child shells inherit them, so steps 1–5 are skipped there but step 6 still finds the zshrc extensions. Non-exported state created by the zshenv extensions (shell functions, unexported variables) does not reach child shells. - **PATH**: May be extended with `WORK_EXECUTABLES_DIR` and employer-specific paths -- **Shell functions/aliases**: Employer-specific additions from zshrc extension +- **Shell functions/aliases**: Employer-specific additions from zshrc extension, including the employer's nono agent launchers when `nono` is installed ## Dependencies diff --git a/dot_agents/shell/claude.zsh b/dot_agents/shell/claude.zsh index 6746775e..8432bc48 100644 --- a/dot_agents/shell/claude.zsh +++ b/dot_agents/shell/claude.zsh @@ -24,10 +24,8 @@ function claude-chezmoi() { _claude_nono claude-code-chezmoi "$@" } function claude-go() { _claude_nono claude-code-go "$@" } -function claude-lcp-docs() { _claude_nono claude-code-lcp-docs "$@" } +function claude-node() { _claude_nono claude-code-node "$@" } function claude-python() { _claude_nono claude-code-python "$@" } function claude-rust() { _claude_nono claude-code-rust "$@" } - -function claude-typescript() { _claude_nono claude-code-typescript "$@" } diff --git a/private_dot_config/nono/profiles/claude-code-go.jsonc.tmpl b/private_dot_config/nono/profiles/claude-code-go.jsonc.tmpl index 33bbbe5f..21ae8354 100644 --- a/private_dot_config/nono/profiles/claude-code-go.jsonc.tmpl +++ b/private_dot_config/nono/profiles/claude-code-go.jsonc.tmpl @@ -31,9 +31,7 @@ "network": { "block": false, "allow_domain": [], - "open_port": [ - 1502 // Required for Modbus - ], + "open_port": [], "listen_port": [] } } diff --git a/private_dot_config/nono/profiles/claude-code-typescript.jsonc b/private_dot_config/nono/profiles/claude-code-node.jsonc similarity index 52% rename from private_dot_config/nono/profiles/claude-code-typescript.jsonc rename to private_dot_config/nono/profiles/claude-code-node.jsonc index a4d4d737..633e7dda 100644 --- a/private_dot_config/nono/profiles/claude-code-typescript.jsonc +++ b/private_dot_config/nono/profiles/claude-code-node.jsonc @@ -5,7 +5,7 @@ "my-claude-code" ], "meta": { - "name": "claude-code-typescript", - "description": "Profile for developing TypeScript applications with Claude Code" + "name": "claude-code-node", + "description": "Profile for developing Node.js applications with Claude Code" } } diff --git a/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl b/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl index 199cb7a0..0659a634 100644 --- a/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl +++ b/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl @@ -11,17 +11,13 @@ "$XDG_CACHE_HOME/uv", "$XDG_DATA_HOME/uv/tools", // Mostly for semble search "$XDG_CACHE_HOME/huggingface/hub/models--minishlab--potion-code-16M-v2", // Semble model cache - "$HOME/.azure", - "$HOME/.azure-devops", "$XDG_DATA_HOME/deck/status", // Deck writes agent status JSON here "$XDG_DATA_HOME/deck/hooks", // Deck writes session sidecar JSON here "$TMPDIR" ], "read": [ "$HOME/.agents/skills", - "$HOME/lcp-docs", "$HOME/.context7", - "$HOME/Library/Application Support/glab-cli", "$HOME/Library/Caches/semble/" // Semble's internal stats ], "write": [ @@ -40,8 +36,7 @@ "$XDG_CONFIG_HOME/git/allowed_signers", "$XDG_CONFIG_HOME/worktrunk/config.toml", "$XDG_CONFIG_HOME/gh/config.yml", - "$XDG_CONFIG_HOME/gh/hosts.yml", - "$XDG_DATA_HOME/.atlassian-token" // Atlassian's API token - For agents + "$XDG_CONFIG_HOME/gh/hosts.yml" ], "write_file": [], "deny": [], @@ -49,16 +44,13 @@ "$HOME/.ssh/id_rsa.pub", "$HOME/.ssh/id_ed25519.pub", "$HOME/.ssh/known_hosts", - "$HOME/.ssh/config", - "$HOME/.azure" + "$HOME/.ssh/config" ], "suppress_save_prompt": [ "/Users", "$HOME", "$HOME/Library/Application Support/Microsoft Edge", - "$HOME/Projects", - "$HOME/Projects/sedg", - "$HOME/Projects/sedg/hark" + "$HOME/Projects" ] }, "network": { @@ -68,16 +60,7 @@ "code.claude.com", "docs.claude.com", "mcp.context7.com", - "mcp.atlassian.com", - "mcp-proxy.anthropic.com", - "gitlab.solaredge.com", - "solaredge-prod.atlassian.net", - "dev.azure.com", - "ssh.dev.azure.com", - "balena.io", - "docs.balena.io", - "balena-cloud.com", - "edge-controller-2.internal.hark.network" + "mcp-proxy.anthropic.com" ] }, "env_credentials": {}, diff --git a/private_dot_config/nono/profiles/work-sedg-claude-code-energy-runtime.jsonc b/private_dot_config/nono/profiles/work-sedg-claude-code-energy-runtime.jsonc new file mode 100644 index 00000000..524aef16 --- /dev/null +++ b/private_dot_config/nono/profiles/work-sedg-claude-code-energy-runtime.jsonc @@ -0,0 +1,17 @@ +{ + "$schema": "../schemas/nono-profile.schema.json", + "extends": [ + "work-sedg-common", + "claude-code-go", + "claude-code-node" + ], + "meta": { + "name": "work-sedg-claude-code-energy-runtime", + "description": "Profile for developing the Energy Runtime project with Claude Code" + }, + "network": { + "open_port": [ + 0 // Any localhost port; tests bind to random ports with :0 + ] + } +} diff --git a/private_dot_config/nono/profiles/work-sedg-claude-code-inverter-driver.jsonc b/private_dot_config/nono/profiles/work-sedg-claude-code-inverter-driver.jsonc new file mode 100644 index 00000000..776e14e1 --- /dev/null +++ b/private_dot_config/nono/profiles/work-sedg-claude-code-inverter-driver.jsonc @@ -0,0 +1,16 @@ +{ + "$schema": "../schemas/nono-profile.schema.json", + "extends": [ + "work-sedg-common", + "claude-code-go" + ], + "meta": { + "name": "work-sedg-claude-code-inverter-driver", + "description": "Profile for developing the Inverter Driver project with Claude Code" + }, + "network": { + "open_port": [ + 1502 // Required for Modbus + ] + } +} diff --git a/private_dot_config/nono/profiles/claude-code-lcp-docs.jsonc b/private_dot_config/nono/profiles/work-sedg-claude-code-lcp-docs.jsonc similarity index 83% rename from private_dot_config/nono/profiles/claude-code-lcp-docs.jsonc rename to private_dot_config/nono/profiles/work-sedg-claude-code-lcp-docs.jsonc index 7725ca49..00283899 100644 --- a/private_dot_config/nono/profiles/claude-code-lcp-docs.jsonc +++ b/private_dot_config/nono/profiles/work-sedg-claude-code-lcp-docs.jsonc @@ -1,11 +1,12 @@ { "$schema": "../schemas/nono-profile.schema.json", "extends": [ + "work-sedg-common", "node-dev", "my-claude-code" ], "meta": { - "name": "claude-code-lcp-docs", + "name": "work-sedg-claude-code-lcp-docs", "description": "Profile for developing the LCP documentation project with Claude Code" }, "filesystem": { diff --git a/private_dot_config/nono/profiles/work-sedg-common.jsonc b/private_dot_config/nono/profiles/work-sedg-common.jsonc new file mode 100644 index 00000000..2e2c8aa5 --- /dev/null +++ b/private_dot_config/nono/profiles/work-sedg-common.jsonc @@ -0,0 +1,40 @@ +{ + "$schema": "../schemas/nono-profile.schema.json", + "meta": { + "name": "work-sedg-common", + "description": "Shared sedg access, mixed into every sedg project profile" + }, + "filesystem": { + "allow": [ + "$HOME/.azure", + "$HOME/.azure-devops" + ], + "read": [ + "$HOME/lcp-docs", + "$HOME/Library/Application Support/glab-cli" + ], + "read_file": [ + "$XDG_DATA_HOME/.atlassian-token" // Atlassian's API token - For agents + ], + "bypass_protection": [ + "$HOME/.azure" + ], + "suppress_save_prompt": [ + "$HOME/Projects/sedg", + "$HOME/Projects/sedg/hark" + ] + }, + "network": { + "allow_domain": [ + "mcp.atlassian.com", + "gitlab.solaredge.com", + "solaredge-prod.atlassian.net", + "dev.azure.com", + "ssh.dev.azure.com", + "balena.io", + "docs.balena.io", + "balena-cloud.com", + "edge-controller-2.internal.hark.network" + ] + } +} diff --git a/private_dot_work/private_sedg/agents/shell/claude.zsh b/private_dot_work/private_sedg/agents/shell/claude.zsh new file mode 100644 index 00000000..340dd55e --- /dev/null +++ b/private_dot_work/private_sedg/agents/shell/claude.zsh @@ -0,0 +1,5 @@ +function claude-energy-runtime() { _claude_nono work-sedg-claude-code-energy-runtime "$@" } + +function claude-inverter-driver() { _claude_nono work-sedg-claude-code-inverter-driver "$@" } + +function claude-lcp-docs() { _claude_nono work-sedg-claude-code-lcp-docs "$@" } diff --git a/private_dot_work/private_sedg/profile b/private_dot_work/private_sedg/profile index 4c12e37d..328e76a0 100644 --- a/private_dot_work/private_sedg/profile +++ b/private_dot_work/private_sedg/profile @@ -1,15 +1,17 @@ #!/bin/sh #shellcheck disable=SC1000-SC9999 -SEDG_DIR="$WORK_DIR/sedg" +export SEDG_DIR="$WORK_DIR/sedg" -SEDG_ZSH_DIR="$SEDG_DIR/zsh" -SEDG_ZSH_RC_EXTENSION="$SEDG_ZSH_DIR/.zshrc" -SEDG_ZSH_ENV_EXTENSION="$SEDG_ZSH_DIR/.zshenv" +export SEDG_ZSH_DIR="$SEDG_DIR/zsh" +export SEDG_ZSH_RC_EXTENSION="$SEDG_ZSH_DIR/.zshrc" +export SEDG_ZSH_ENV_EXTENSION="$SEDG_ZSH_DIR/.zshenv" -SEDG_EXECUTABLES_DIR="$SEDG_DIR/bin" -SEDG_FIX_VPN_EXECUTABLE_NAME="fix-vpn" -SEDG_FIX_VPN_EXECUTABLE_PATH="${SEDG_EXECUTABLES_DIR}/${SEDG_FIX_VPN_EXECUTABLE_NAME}" +export SEDG_AGENTS_SHELL_DIR="$SEDG_DIR/agents/shell" -SEDG_IOE_DEV_ENV_FRAMEWORK_DIR="$HOME/dev-env" -SEDG_IOE_DEV_ENV_FRAMEWORK_ENTRY_POINT="$HOME/dev-env.sh" +export SEDG_EXECUTABLES_DIR="$SEDG_DIR/bin" +export SEDG_FIX_VPN_EXECUTABLE_NAME="fix-vpn" +export SEDG_FIX_VPN_EXECUTABLE_PATH="${SEDG_EXECUTABLES_DIR}/${SEDG_FIX_VPN_EXECUTABLE_NAME}" + +export SEDG_IOE_DEV_ENV_FRAMEWORK_DIR="$HOME/dev-env" +export SEDG_IOE_DEV_ENV_FRAMEWORK_ENTRY_POINT="$HOME/dev-env.sh" diff --git a/private_dot_work/private_sedg/zsh/dot_zshrc.tmpl b/private_dot_work/private_sedg/zsh/dot_zshrc.tmpl index 197ae12a..e6528fb2 100755 --- a/private_dot_work/private_sedg/zsh/dot_zshrc.tmpl +++ b/private_dot_work/private_sedg/zsh/dot_zshrc.tmpl @@ -6,3 +6,8 @@ sudo fix-vpn up {{- end }} {{- end }} + +# Use sandboxed sedg agent launchers if nono is installed +if command -v nono >/dev/null 2>&1; then + [[ -r "$SEDG_AGENTS_SHELL_DIR/claude.zsh" ]] && source "$SEDG_AGENTS_SHELL_DIR/claude.zsh" +fi diff --git a/private_dot_work/profile.tmpl b/private_dot_work/profile.tmpl index 5ad489c1..f322f38a 100644 --- a/private_dot_work/profile.tmpl +++ b/private_dot_work/profile.tmpl @@ -1,12 +1,12 @@ #!/bin/sh #shellcheck disable=SC1000-SC9999 -WORK_DIR="$HOME/.work" -WORK_EXECUTABLES_DIR="$WORK_DIR/bin" +export WORK_DIR="$HOME/.work" +export WORK_EXECUTABLES_DIR="$WORK_DIR/bin" -WORK_ZSH_DIR="$WORK_DIR/zsh" -WORK_ZSH_RC_EXTENSION="$WORK_ZSH_DIR/.zshrc" -WORK_ZSH_ENV_EXTENSION="$WORK_ZSH_DIR/.zshenv" +export WORK_ZSH_DIR="$WORK_DIR/zsh" +export WORK_ZSH_RC_EXTENSION="$WORK_ZSH_DIR/.zshrc" +export WORK_ZSH_ENV_EXTENSION="$WORK_ZSH_DIR/.zshenv" # Load work-specific profile source {{ .system.work_specific_dotfiles_profile }}