Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .agents/skills/managing-nono-profiles/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,18 @@ Use this pattern instead:
- Grant exact public SSH metadata with `filesystem.read_file`.
- Add the same exact public/metadata files to `filesystem.bypass_protection` when they live under denied paths like `$HOME/.ssh`.
- Never add `$HOME/.ssh` as a directory grant or bypass unless explicitly requested and security-reviewed.
- Let shell wrappers preload keys into the host `ssh-agent` before entering nono.
- Let wrappers pass `--allow-unix-socket "$SSH_AUTH_SOCK"` so the sandbox can ask the host agent to sign without reading private key files.
- Use the shared `~/.config/git/agent.gitconfig` for agent Git configuration.
- Let `_nono_agent_run` attempt to preload the key into the host `ssh-agent` before entering nono. This is best-effort, not a fail-fast check; missing sockets, missing keys, or failed loads do not prevent launch.
- Let `_nono_agent_run` pass `--allow-unix-socket "$SSH_AUTH_SOCK"` when the socket variable is set, so the sandbox can ask the host agent to sign without reading private key files.

Public SSH metadata commonly needed by Git:

- `$HOME/.ssh/<key>.pub`
- `$HOME/.ssh/known_hosts`
- `$HOME/.ssh/config`

Profiles also need read access to the shared agent, common, and personal Git configs, the work Git config on work machines, `allowed_signers`, and `nono-git-ssh`. Grant the required public SSH metadata through both `read_file` and `bypass_protection`, while keeping private keys excluded.

Validate private keys remain blocked with:

```sh
Expand All @@ -96,6 +99,8 @@ Expected result: `DENIED` by `deny_credentials`.

Shared nono wrapper helpers live in `dot_agents/shell/nono.zsh.tmpl`.

`_nono_agent_run` owns `GIT_CONFIG_GLOBAL="$HOME/.config/git/agent.gitconfig"` for all agents. Per-agent wrappers pass the profile, command, preload key paths, and command arguments. The `OPENCODE_SSH_SIGNING_*`, `CLAUDE_SSH_SIGNING_*`, and `CODEX_SSH_SIGNING_*` environment overrides affect preloading only; they do not change Git's configured signing key.

Per-agent files should call `_nono_agent_run` instead of duplicating nono setup:

- `dot_agents/shell/opencode.zsh`
Expand Down
4 changes: 1 addition & 3 deletions .chezmoiignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ Taskfile.yml

{{- if not .personal.work_env }}
.work/ # only manage work state on work machines
# Work-specific Claude integration requires work SSH key names.
.agents/shell/claude.zsh
.config/nono/profiles/my-claude-code.jsonc
.config/git/work.gitconfig
{{- end }}

{{- if not (and .personal.work_env (eq .personal.work_name "sedg")) }}
Expand Down
12 changes: 6 additions & 6 deletions docs/contracts/chezmoi-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Chezmoi's built-in `.chezmoi.*` values are not part of this installer-owned cont

| TOML key | Template access | Presence | Producer source | Current consumers |
|----------|-----------------|----------|-----------------|-------------------|
| `data.personal.email` | `.personal.email` | Always | `DotfilesData.Email` | Common Git identity (non-work fallback), personal-repo override, and signer templates |
| `data.personal.email` | `.personal.email` | Always | `DotfilesData.Email` | Common Git personal-email fallback and signer templates |
| `data.personal.full_name` | `.personal.full_name` | Always | `FirstName` and `LastName`, joined with a space | Common Git identity template |
| `data.personal.work_env` | `.personal.work_env` | Always | Whether `DotfilesData.WorkEnv` is present | `.chezmoiignore`, shell templates, and work-dependent agent/Git templates |
| `data.personal.work_name` | `.personal.work_name` | Work environments only | `DotfilesWorkEnvData.WorkName` | Work profile extensions and work-dependent agent/Git templates |
| `data.personal.work_email` | `.personal.work_email` | Work environments only | `DotfilesWorkEnvData.WorkEmail` | Common Git identity and signer templates (work environments) |
| `data.personal.work_env` | `.personal.work_env` | Always | Whether `DotfilesData.WorkEnv` is present | `.chezmoiignore`, work shell templates, work Git identity, and allowed signer identities |
| `data.personal.work_name` | `.personal.work_name` | Work environments only | `DotfilesWorkEnvData.WorkName` | Work shell profile extensions and employer nono profile filtering |
| `data.personal.work_email` | `.personal.work_email` | Work environments only | `DotfilesWorkEnvData.WorkEmail` | Work Git identity and signer templates (work environments) |

### `system`

Expand All @@ -44,9 +44,9 @@ Chezmoi's built-in `.chezmoi.*` values are not part of this installer-owned cont

## Work-Environment Invariants

When `personal.work_env` is `false`, the installer omits `work_name`, `work_email`, and both work-profile paths. `.chezmoiignore` excludes the managed work tree and work-dependent agent configuration in that mode.
When `personal.work_env` is `false`, the installer omits `work_name`, `work_email`, and both work-profile paths. `.chezmoiignore` excludes the managed work tree, employer-specific nono profiles, and the work Git configuration in that mode.

When `personal.work_env` is `true`, the installer writes the work identity and both profile paths. Templates may therefore treat those conditional values as a group. The dotfile meaning of the two profile paths is documented in the [dotfiles domain][dotfiles-domain], and their runtime use is documented by [work environment loading][work-environment-loading].
When `personal.work_env` is `true`, the installer writes the work identity and both profile paths. The work Git configuration overrides the common personal-email fallback only for matching configured GitLab and Azure DevOps repository URLs. Templates may therefore treat the conditional values as a group. The dotfile meaning of the two profile paths is documented in the [dotfiles domain][dotfiles-domain], and their runtime use is documented by [work environment loading][work-environment-loading].

## GPG Signing Key

Expand Down
15 changes: 15 additions & 0 deletions docs/dotfiles/domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ private_dot_work/

**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.

### Agent Git Signing

OpenCode, Claude Code, and Codex launched through the shared nono helpers use `~/.config/git/agent.gitconfig`. The [agent Git template][agent-git-template] includes the common Git configuration, selects SSH signing with `~/.ssh/id_ed25519.pub`, and sets `core.sshCommand` to `~/.local/bin/nono-git-ssh` for Git SSH transport.

Signing method and Git identity are separate. The [common Git template][common-git-template] sets the shared name, personal email, and `user.useConfigOnly=true`. On work machines, conditional includes override the personal email with the work identity for configured GitLab and Azure DevOps repository URLs. These rules examine every remote, not only `origin`.

Unmatched repositories, including repositories without remotes, use the personal email. Existing repository-local settings and environment overrides still take precedence. URL spelling and SSH aliases affect matching. Identity here means Git authorship metadata, not signing or repository authentication. The conditional includes require Git 2.36 or later and must not define remote URLs.

The shared `_nono_agent_run` helper sets `GIT_CONFIG_GLOBAL`, attempts to preload the key into the host `ssh-agent`, and grants access to its socket. Sandboxed agents read public metadata, not private key files. Preloading is best-effort and does not guarantee that signing will succeed. Manual Git sessions use the GPG configuration in `~/.gitconfig`.

See the [agent commit signing process][agent-commit-signing] for host setup, sandbox access, and verification.

### 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.
Expand Down Expand Up @@ -79,3 +91,6 @@ See the [shell startup process][shell-startup] for the full shell startup flow i
[shell-startup]: processes/shell-startup.md
[work-env-loading]: processes/work-environment-loading.md
[chezmoi-data-contract]: ../contracts/chezmoi-data.md
[agent-git-template]: ../../private_dot_config/git/agent.gitconfig.tmpl
[common-git-template]: ../../private_dot_config/git/common.gitconfig.tmpl
[agent-commit-signing]: processes/agent-commit-signing.md
95 changes: 95 additions & 0 deletions docs/dotfiles/processes/agent-commit-signing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Agent Commit Signing

## Overview

Signs Git commits from nono-launched OpenCode, Claude Code, and Codex with the host's Ed25519 key through `ssh-agent`. The [shared agent Git configuration][agent-git] selects the signing key, while the [common configuration][common-git] supplies the shared name and personal-email fallback. See [agent Git signing][domain-signing] for identity selection and configuration ownership.

## Trigger

A coding agent starts through a shell wrapper and later runs a Git commit with signing enabled.

## Actors

- **Host user**: Registers the public signing key with the Git hosting account and makes the private key available to the host `ssh-agent`.
- **[Shared launcher][shared-launcher]**: Attempts key preloading, sets the agent Git config, and passes the agent socket to nono.
- **Nono profiles**: Permit public metadata and socket access without private-key reads.
- **Git and `ssh-agent`**: Request and produce the SSH signature.
- **Local Git or Git host**: Verify the signature using separate trust configuration.

## Flow

### Host Setup

1. Register `~/.ssh/id_ed25519.pub` as a signing key on each Git hosting account that needs to verify its signatures. Where the host supports multiple signing keys, register each machine's public key with the account.
2. Ensure the host `ssh-agent` is available through `SSH_AUTH_SOCK` and can use the matching private key. Key loading happens on the host, before the sandbox starts; private keys are not granted to the sandbox.
3. Configure repository authentication separately. Registering a signing key does not by itself grant clone, fetch, or push access, even when the same public key is used for authentication.

### Agent Launch and Signing

1. The [OpenCode][opencode-wrapper], [Claude Code][claude-wrapper], or [Codex][codex-wrapper] wrapper passes its profile, command, and preload key paths to `_nono_agent_run`. The defaults are `~/.ssh/id_ed25519.pub` and `~/.ssh/id_ed25519`.
2. `_nono_agent_ensure_ssh_signing_key` checks the socket, `ssh-add`, and public key, then tests agent signing with `ssh-add -T`. If needed and readable on the host, it attempts to load the private key. On macOS it tries `--apple-use-keychain` before ordinary `ssh-add`.
3. `_nono_agent_run` launches nono with `GIT_CONFIG_GLOBAL="$HOME/.config/git/agent.gitconfig"`. If `SSH_AUTH_SOCK` is set, it adds `--allow-unix-socket "$SSH_AUTH_SOCK"`.
4. Git reads the shared agent config, which includes `common.gitconfig`, enables SSH signature format, and selects `~/.ssh/id_ed25519.pub`. The common config enables commit signing. Git asks the host agent to sign using the corresponding private key.
5. For Git SSH transport, `core.sshCommand` selects [`nono-git-ssh`][git-ssh], which uses `ncat` for proxy-aware SSH connections. This transport setting is separate from commit signing.

Preloading is best-effort: missing prerequisites or failed key loading do not stop agent launch. The `OPENCODE_SSH_SIGNING_PUBLIC_KEY` / `OPENCODE_SSH_SIGNING_KEY`, `CLAUDE_SSH_SIGNING_PUBLIC_KEY` / `CLAUDE_SSH_SIGNING_KEY`, and `CODEX_SSH_SIGNING_PUBLIC_KEY` / `CODEX_SSH_SIGNING_KEY` overrides change only preload inputs. They do not change Git's configured `~/.ssh/id_ed25519.pub` signing key.

### Identity Selection

The common configuration sets the personal email and `user.useConfigOnly=true`. On work machines, conditional includes override it with the work email for GitLab `gitlab.solaredge.com`, Azure SSH `ssh.dev.azure.com`, and Azure HTTP(S) `dev.azure.com` URLs. Any remote can match; Git does not limit the check to `origin`.

Repositories that do not match, including those without remotes, use the personal email. Repository-local settings and environment overrides still take precedence. URL spelling and SSH aliases affect matching, and Git 2.36 or later is required. These identity rules do not change GPG or SSH signing methods, signing keys, or repository authentication. Conditional configuration files select identity only; they must not define remote URLs.

### Sandbox Access

The [OpenCode][opencode-profile], [Claude Code][claude-profile], and [Codex][codex-profile] profiles grant these exact files in both `filesystem.read_file` and `filesystem.bypass_protection`:

- `$HOME/.ssh/id_ed25519.pub`
- `$HOME/.ssh/known_hosts`
- `$HOME/.ssh/config`

They also allow reading the agent Git configuration and SSH transport helper, with common configuration and local signer trust available through exact-file or Git-directory grants. The launch-time socket grant permits requests to the host agent. None of these grants requires reading private key files or granting the whole `~/.ssh` directory.

### Verification

- **Local verification**: `common.gitconfig` sets `gpg.ssh.allowedSignersFile` to `~/.config/git/allowed_signers`. The [signer template][allowed-signers] includes available local `id_rsa.pub` and `id_ed25519.pub` keys for the personal email and, on work machines, the work email.
- **Git host verification**: The host checks its registered signing keys and account identity rules. A successful local verification does not register a key with the host or guarantee its verified status there.

## Failure Scenarios

| Condition | Result |
|-----------|--------|
| Socket absent, key not loaded, or preload fails | The agent still launches; a later signed commit can fail because the configured key is unavailable |
| Preload override selects a different key | Git still requests the key matching `~/.ssh/id_ed25519.pub` |
| Public metadata or socket access missing | Signing or SSH transport can fail; inspect the exact profile grants rather than exposing private keys |
| Local signer entry missing | Local verification cannot establish trust even if the host recognizes the signature |
| Signing key not registered with the host | Local verification can succeed without host verification |
| Authentication not configured | Signing can work while repository access fails |

## State Changes

- The host `ssh-agent` may gain a loaded key.
- The launched process and its children inherit the shared agent Git config selection.
- A successful signed commit stores an SSH signature in the repository.

Manual Git outside these wrappers reads [`~/.gitconfig`][manual-git], which selects the installer-configured GPG key when present.

## Dependencies

- Rendered agent/common Git configs and nono profiles, plus a host key pair and usable `ssh-agent`.
- Host signing-key registration for host verification; local `allowed_signers` for local verification.
- SSH transport additionally requires `ncat` and separate authentication access.

[domain-signing]: ../domain.md#agent-git-signing
[agent-git]: ../../../private_dot_config/git/agent.gitconfig.tmpl
[common-git]: ../../../private_dot_config/git/common.gitconfig.tmpl
[shared-launcher]: ../../../dot_agents/shell/nono.zsh.tmpl
[opencode-wrapper]: ../../../dot_agents/shell/opencode.zsh
[claude-wrapper]: ../../../dot_agents/shell/claude.zsh
[codex-wrapper]: ../../../dot_agents/shell/codex.zsh
[opencode-profile]: ../../../private_dot_config/nono/profiles/my-opencode.jsonc
[claude-profile]: ../../../private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl
[codex-profile]: ../../../private_dot_config/nono/profiles/my-codex.jsonc
[git-ssh]: ../../../private_dot_local/bin/executable_nono-git-ssh
[allowed-signers]: ../../../private_dot_config/git/allowed_signers.tmpl
[manual-git]: ../../../dot_gitconfig.tmpl
11 changes: 2 additions & 9 deletions dot_agents/shell/claude.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@ function _claude_nono() {
local profile="$1"
shift

_nono_agent_ensure_ssh_signing_keys \
"${CLAUDE_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_rsa.pub}" \
"${CLAUDE_SSH_SIGNING_KEY:-$HOME/.ssh/id_rsa}" \
"${CLAUDE_ED25519_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_ed25519.pub}" \
"${CLAUDE_ED25519_SSH_SIGNING_KEY:-$HOME/.ssh/id_ed25519}"

_nono_agent_run \
"$profile" \
"$HOME/.claude/gitconfig" \
claude \
"${CLAUDE_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_rsa.pub}" \
"${CLAUDE_SSH_SIGNING_KEY:-$HOME/.ssh/id_rsa}" \
"${CLAUDE_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_ed25519.pub}" \
"${CLAUDE_SSH_SIGNING_KEY:-$HOME/.ssh/id_ed25519}" \
--dangerously-skip-permissions \
"$@"
}
Expand Down
2 changes: 0 additions & 2 deletions dot_agents/shell/codex.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ function _codex() {

_codex_nono_run \
"$profile" \
"$HOME/.codex/gitconfig" \
codex \
"${CODEX_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_ed25519.pub}" \
"${CODEX_SSH_SIGNING_KEY:-$HOME/.ssh/id_ed25519}" \
Expand All @@ -28,7 +27,6 @@ function _codex_acp() {

_codex_nono_run \
"$profile" \
"$HOME/.codex/gitconfig" \
npx \
"${CODEX_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_ed25519.pub}" \
"${CODEX_SSH_SIGNING_KEY:-$HOME/.ssh/id_ed25519}" \
Expand Down
18 changes: 5 additions & 13 deletions dot_agents/shell/nono.zsh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,12 @@ function _nono_agent_ensure_ssh_signing_key() {
{{- end }}
}

function _nono_agent_ensure_ssh_signing_keys() {
while (( $# >= 2 )); do
_nono_agent_ensure_ssh_signing_key "$1" "$2"
shift 2
done
}

function _nono_agent_run() {
local profile="$1"
local git_config="$2"
local command_name="$3"
local public_key="$4"
local private_key="$5"
shift 5
local command_name="$2"
local public_key="$3"
local private_key="$4"
shift 4

_nono_agent_ensure_ssh_signing_key "$public_key" "$private_key"

Expand Down Expand Up @@ -81,7 +73,7 @@ function _nono_agent_run() {
acp_args=(--silent --startup-timeout 0)
fi

GIT_CONFIG_GLOBAL="$git_config" \
GIT_CONFIG_GLOBAL="$HOME/.config/git/agent.gitconfig" \
nono run \
--profile "$profile" \
--allow-cwd \
Expand Down
1 change: 0 additions & 1 deletion dot_agents/shell/opencode.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ function _opencode_nono() {

_nono_agent_run \
"$profile" \
"$HOME/.config/opencode/gitconfig" \
"$command_name" \
"${OPENCODE_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_ed25519.pub}" \
"${OPENCODE_SSH_SIGNING_KEY:-$HOME/.ssh/id_ed25519}" \
Expand Down
12 changes: 0 additions & 12 deletions dot_claude/gitconfig.tmpl

This file was deleted.

1 change: 0 additions & 1 deletion dot_codex/gitconfig.tmpl

This file was deleted.

Loading
Loading