feat(client): deliver items only to clients with a matching label
- Add internal/labels: parse and validate the optional work-repo file
agent-lib.labels.json (version 1; unlabeled items go to every client;
names match across types)
- Add "labels" to the client config: absent = no filtering, [] = unlabeled
items only; labels from the admin default config are pinned and cannot be
overridden by user, env or flag configs; a broken admin config aborts
- Filter in prepare() before planning; deselected items follow the
upstream-deletion rules (unmodified removed, modified kept + warn,
--force removes) with reason "not selected for this client's labels"
- Abort sync before any change when the labels file does not validate;
names that match no item only warn on the client
- Report the active selection in sync output and status (--json: labels
object with client, source, labels_file, not_selected, unknown_names)
- validate checks the labels file, including that every name resolves to
an own, vendored or MCP item
- Document in README ("Client labels"), fleet handoff and the proposal;
revise the "client-side selection" non-goal
- Tests: labels parser, config precedence, planner deselection, e2e for
filter/remove/keep-modified/abort/unknown names, validate
Refs: agent_lib-fh4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
39952ceb02
commit
59735c3b24
16 files changed
+904
-38
No files matched your search
@@ -45,6 +45,7 @@ agents/<id>.md own OpenCode agents
|
||||
mcp/<id>.yaml own MCP fragments (never deployed by the binary)
|
||||
external/<source>/<type>/ vendored content, mirrors the same four types
|
||||
agent-lib.lock.json lockfile v2 — pins every source
|
||||
agent-lib.labels.json optional — restricts items to labeled clients
|
||||
```
|
||||
|
||||
This layout is **exactly** what OpenCode natively consumes — agent-lib is
|
||||
@@ -291,6 +292,62 @@ 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).
|
||||
|
||||
### Client labels
|
||||
|
||||
Not every client needs every item. Restrict items to clients that carry a
|
||||
matching label with an optional `agent-lib.labels.json` at the work
|
||||
repository root:
|
||||
|
||||
```json
|
||||
{
|
||||
"version": 1,
|
||||
"labels": {
|
||||
"sales": ["crm-agent", "quote-writer"],
|
||||
"finance": ["officecli-financial-model", "crm-agent"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- **Unlabeled items go to every client.** Only restricted items appear in
|
||||
the file; a new item needs no entry to reach everyone.
|
||||
- Entries are deployed item names (after renames) and match across types —
|
||||
one entry covers a skill and a command of the same name. MCP fragment
|
||||
names are allowed too (fleet tooling can scope MCP from the same file;
|
||||
the binary never deploys MCP).
|
||||
- An item under several labels reaches clients with any of them.
|
||||
- Labels match `^[a-z0-9][a-z0-9-]*$`; lists must be non-empty; unknown
|
||||
keys and unknown versions are errors.
|
||||
|
||||
Clients opt in through `labels` in their config:
|
||||
|
||||
| `labels` | Delivered |
|
||||
|---|---|
|
||||
| absent | everything — no filtering (default, backward compatible) |
|
||||
| `[]` | unlabeled items only |
|
||||
| `["sales", "lead"]` | unlabeled items plus items labeled `sales` or `lead` |
|
||||
|
||||
**Admin-pinned:** when the admin default config exists and sets `labels`,
|
||||
that value applies no matter which config supplied `repo_url` — a user-level
|
||||
config, `AGENT_LIB_CONFIG` or `--config` can neither widen nor drop it. An
|
||||
admin config that exists but cannot be parsed aborts the run.
|
||||
|
||||
Sync filters before planning. An item that is no longer selected follows
|
||||
the upstream-deletion rules: unmodified copies are removed, locally modified
|
||||
copies are kept with a warning (`--force` removes them); the reason reads
|
||||
"not selected for this client's labels". A labels file that does not
|
||||
validate **aborts the sync before any change** — it never falls back to
|
||||
delivering everything. Names that match no item only warn on the client;
|
||||
`agent-lib validate` treats them as errors on the curator side.
|
||||
|
||||
`sync` and `status` print the active selection
|
||||
(`labels: sales (admin) — 12 item(s) not selected`); `status --json` adds a
|
||||
`labels` object with `client`, `source`, `labels_file`, `not_selected` and
|
||||
`unknown_names`.
|
||||
|
||||
Labels are a relevance filter, **not access control**: every client still
|
||||
fetches the whole revision into its cache. Keep confidential material in a
|
||||
separately authenticated repository.
|
||||
|
||||
### Notifications
|
||||
|
||||
On Windows, a toast fires when (and only when) a sync kept local
|
||||
@@ -347,7 +404,10 @@ In scope: vendoring with selection/renames into any git work repository;
|
||||
OpenCode-only deployment with three-state protection; toast notifications;
|
||||
goreleaser/GitHub release pipeline.
|
||||
|
||||
Not in scope: client-side selection or profiles, additional targets (Pi,
|
||||
Client-side selection is limited to label filtering (see Client labels) —
|
||||
no per-client profiles, overrides or inheritance.
|
||||
|
||||
Not in scope: additional targets (Pi,
|
||||
Hermes, Crush, Amp), MCP merge/vault (fleet-controller concern), binary
|
||||
self-update, git submodule sources, migration tooling from the Python-era
|
||||
lockfile.
|
||||
Reference in new issue
Block a user