feat(client): config search chain, --repo zero-config override, actionable missing-config error

sync/status now resolve the work repository from a fallback chain:
--repo flag > --config flag > AGENT_LIB_CONFIG env > user-level config
(XDG / AppData) > admin platform default. --repo works without any
config file; tokens fall back to AGENT_LIB_GIT_TOKEN/AGENT_LIB_GIT_USER
without ever overriding a configured token. A completely empty chain
yields an error listing every searched location, a minimal config
example and the --repo shortcut.

Closes beads: agent-lib-9o8
This commit is contained in:
2026-08-23 15:08:27 +02:00
parent 1b2fcb6fbb
commit 7070d8cc25
7 changed files with 627 additions and 31 deletions
+32 -4
View File
@@ -123,6 +123,9 @@ agent-lib sync # pull the work repository and deploy
agent-lib status # report local state; exit 1 when updates are blocked
```
Both accept `--repo <url>` / `--ref <ref>` for config-free personal use —
see [Configuration](#configuration) below.
Deployment mapping (OpenCode target):
| Type | Destination |
@@ -149,9 +152,22 @@ an unreachable repository never leaves a half-deployed machine.
### Configuration
The client config is admin-provided (fleet rollout), JSON at
`C:\ProgramData\agent-lib\config.json` on Windows, `/etc/agent-lib/config.json`
elsewhere. Override per run with `--config` or `AGENT_LIB_CONFIG`:
The repository to pull comes from the first source that provides one:
1. `--repo <url>` flag (works with **no config file at all**)
2. `--config <path>` flag
3. `AGENT_LIB_CONFIG` env
4. user-level config (personal machines)
5. admin-protected platform default (fleet rollout)
| Source | Linux / macOS | Windows |
|---|---|---|
| user-level config | `$XDG_CONFIG_HOME/agent-lib/config.json` (default `~/.config/agent-lib/config.json`) | `%AppData%\agent-lib\config.json` |
| admin default | `/etc/agent-lib/config.json` | `%ProgramData%\agent-lib\config.json` |
`--repo` overrides a `repo_url` from any discovered config; `--ref` narrows it
to a branch or tag. When no config exists anywhere, the error lists every
searched location, a minimal working example, and the `--repo` shortcut.
```json
{
@@ -163,7 +179,18 @@ elsewhere. Override per run with `--config` or `AGENT_LIB_CONFIG`:
```
The token is used for basic auth only. It never appears in the lockfile, the
manifest, logs or error messages.
manifest, logs or error messages. On `--repo` runs (or when the discovered
config carries no token) `AGENT_LIB_GIT_TOKEN` / `AGENT_LIB_GIT_USER` supply
credentials instead — env never overrides a configured token.
**Personal quickstart (no fleet, no config):**
```sh
agent-lib sync --repo https://github.com/you/your-agent-content.git
```
The work repository must be a committed git repository (sync pulls it
read-only via go-git; local uncommitted state is ignored).
### Notifications
@@ -192,6 +219,7 @@ flag that drives the non-zero exit code — suitable for headless drift checks.
| Symptom | Cause / fix |
|---|---|
| `error: … no client config found. Searched (in order): …` | No config anywhere. Create one where the error suggests, or skip it: `agent-lib sync --repo <url>`. |
| `error: … include entry "x" not found upstream` | Typo, or the item was renamed/removed upstream. Fix the lockfile include list, or re-add with a corrected `--include`. |
| `error: … collides with own skills "x"` | Deployed-name collision. Add `--rename <upstream>=<deployed>` (add) or fix the rename map (update). |
| `validate` reports tree/lockfile divergence | Someone edited `external/` by hand. Re-run `vendor update <source>` to restore the pinned state. |