agent-shim 0.0.0 → 7.0.0

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 (44) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +233 -0
  3. package/dist/cli.cjs +69549 -0
  4. package/dist/index.cjs +3620 -0
  5. package/dist/index.mjs +3545 -0
  6. package/dist/types/cliError.d.ts +27 -0
  7. package/dist/types/config/classify.d.ts +49 -0
  8. package/dist/types/config/load.d.ts +42 -0
  9. package/dist/types/config/schema.d.ts +746 -0
  10. package/dist/types/config/store.d.ts +46 -0
  11. package/dist/types/frontdoor/capability.d.ts +19 -0
  12. package/dist/types/frontdoor/connect.d.ts +179 -0
  13. package/dist/types/frontdoor/ensure.d.ts +34 -0
  14. package/dist/types/frontdoor/probe.d.ts +13 -0
  15. package/dist/types/frontdoor/state.d.ts +50 -0
  16. package/dist/types/frontdoor/supervisor.d.ts +48 -0
  17. package/dist/types/frontdoor/x509.d.ts +11 -0
  18. package/dist/types/headroom/ensure.d.ts +31 -0
  19. package/dist/types/headroom/settings.d.ts +13 -0
  20. package/dist/types/headroom/source.d.ts +8 -0
  21. package/dist/types/headroom/state.d.ts +77 -0
  22. package/dist/types/headroom/supervisor.d.ts +107 -0
  23. package/dist/types/index.d.ts +21 -0
  24. package/dist/types/launcher/farm.d.ts +165 -0
  25. package/dist/types/launcher/guard.d.ts +57 -0
  26. package/dist/types/launcher/lock.d.ts +41 -0
  27. package/dist/types/launcher/ports.d.ts +135 -0
  28. package/dist/types/legacy.d.ts +24 -0
  29. package/dist/types/paths.d.ts +79 -0
  30. package/dist/types/resolve/conditions.d.ts +37 -0
  31. package/dist/types/resolve/decide.d.ts +45 -0
  32. package/dist/types/resolve/extends.d.ts +41 -0
  33. package/dist/types/resolve/flatten.d.ts +13 -0
  34. package/dist/types/resolve/match.d.ts +58 -0
  35. package/dist/types/resolve/pipeline.d.ts +30 -0
  36. package/dist/types/resolve/plan.d.ts +57 -0
  37. package/dist/types/resolve/projects.d.ts +61 -0
  38. package/dist/types/resolve/reconcile.d.ts +80 -0
  39. package/dist/types/resolve/types.d.ts +159 -0
  40. package/dist/types/resolve/walk.d.ts +85 -0
  41. package/dist/types/usage/account.d.ts +20 -0
  42. package/dist/types/usage/read.d.ts +70 -0
  43. package/dist/types/usage/schema.d.ts +318 -0
  44. package/package.json +91 -2
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 ExaDev
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,233 @@
1
+ # agent-shim
2
+
3
+ [![GitHub](https://img.shields.io/badge/GitHub-181717?logo=github&logoColor=white)](https://github.com/ExaDev/agent-shim) [![npm](https://img.shields.io/badge/npm-CB3837?logo=npm&logoColor=white)](https://www.npmjs.com/package/agent-shim) [![Release](https://img.shields.io/github/v/release/ExaDev/agent-shim)](https://github.com/ExaDev/agent-shim/releases/latest) [![CI](https://img.shields.io/github/actions/workflow/status/ExaDev/agent-shim/ci.yml?branch=main)](https://github.com/ExaDev/agent-shim/actions) [![Homebrew](https://img.shields.io/badge/Homebrew-FBB040?logo=homebrew&logoColor=white)](https://github.com/ExaDev/homebrew-agent-shim) [![Scoop](https://img.shields.io/badge/Scoop-205081?logo=data:image/svg%2Bxml%3Bbase64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTExIDJoMnY5aC0yek0xMiAyMmE3IDcgMCAwIDAgNy03SDVhNyA3IDAgMCAwIDcgN3oiIGZpbGw9IiNmZmYiLz48L3N2Zz4K&logoColor=white)](https://github.com/ExaDev/scoop-agent-shim)
4
+
5
+ A profile manager and launcher for [Claude Code](https://claude.com/claude-code) that lets one person run multiple logins from one machine while controlling — precisely, and per working directory — what gets shared between them.
6
+
7
+ [![npm downloads chart, log scale](https://shieldcn.dev/chart/npm/agent-shim.svg?bg=transparent&logo=false&yScale=log)](https://www.npmjs.com/package/agent-shim)
8
+
9
+ ## The problem
10
+
11
+ Claude Code keeps everything it knows in one place: `~/.claude`. Skills, memory, conventions, but also every conversation transcript, session file, and task list you've ever produced, across every project you've ever touched. If you want a second login (a personal account alongside a work one, say) or you want to keep one client's work cleanly separated from another's, there's no built-in way to say "share the skills and conventions, but not the history" — it's all one directory, all or nothing.
12
+
13
+ `agent-shim` solves this with two independent things:
14
+
15
+ - **An identity** is a login. It's the thing that owns credentials and daemon state, and it's what you switch between with `claude @work` or `claude @personal`.
16
+ - **A configuration profile** is a reusable, named bundle of sharing rules — what's visible, what isn't. It exists independently of any identity, and which one applies can depend entirely on which directory you're working in.
17
+
18
+ Keeping these separate matters because they answer different questions. "Which login am I using?" and "What should this login see right now?" don't have to have the same answer every time, and forcing them to share one concept (as most ad hoc setups do) means you can't express "one login, several different sharing postures depending on where I am" — which turns out to be the common case.
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ curl -fsSL https://github.com/ExaDev/agent-shim/releases/latest/download/install.sh | sh
24
+ ```
25
+
26
+ This installs `agent-shim` alone into `~/.local/bin`; your existing `claude` command is left untouched. `agent-shim run [args...]` reaches the same identity-resolve, farm-resync, spawn pipeline a `claude`-named binary would, so every feature already works with no further setup. Run `agent-shim shim enable` once for the shorter `claude @<name>` form (`shim disable` reverses it).
27
+
28
+ Also available: npm (`npm install -g agent-shim`, needs Node 22.18 or later, or 24 and above), Homebrew (`brew install ExaDev/agent-shim/agent-shim`), Scoop on Windows, a scoped GitHub Packages alias, and installing straight from the git repository with no registry at all. Each channel's exact commands, the platform support matrix, and the one architecture (macOS x64) that needs a different install path are in [docs/installation.md](docs/installation.md).
29
+
30
+ ## Renamed from claude-use
31
+
32
+ agent-shim was called `claude-use` until it was renamed. Everything written for the old name keeps working, and `agent-shim doctor` lists what still uses it:
33
+
34
+ - The `claude-use` command is installed beside `agent-shim` by every channel and runs the same program.
35
+ - `CLAUDE_USE_*` environment variables are read wherever `AGENT_SHIM_*` is; the current name wins when both are set.
36
+ - An existing `~/.claude-use` is used in place when there is no `~/.agent-shim`. Do not move it: macOS Claude Code keys each identity's Keychain login on the exact path of its configuration directory (`<root>/identities/<name>`), so relocating the root signs every identity out. A fresh installation uses `~/.agent-shim`.
37
+ - A committed `.claude-use.json` or `.claude-use.local.json` is read when the directory has no `.agent-shim.json` or `.agent-shim.local.json`; `configure` keeps writing into the legacy local file while it is the only one.
38
+ - A farm manifest written under the old name is read, and replaced by the current one on the next resync.
39
+ - npm: install `agent-shim`; the `claude-use` package is deprecated in its favour. Homebrew moves an installed `claude-use` formula to `agent-shim` on upgrade.
40
+
41
+ ## Quick start
42
+
43
+ ```bash
44
+ agent-shim identity add personal # create your first identity (a fresh login)
45
+ agent-shim run @personal # log in and start using it
46
+ ```
47
+
48
+ Want the shorter `claude @personal` instead? Run `agent-shim shim enable` once — see [Install](#install).
49
+
50
+ That's it — with no further configuration, everything in `~/.claude` that isn't credentials or daemon runtime is classified into categories (see below) and shared according to sensible defaults. Add a second identity, add configuration profiles, and add directory rules only once you actually need more control than that.
51
+
52
+ ## Concepts
53
+
54
+ `agent-shim` separates two things most ad hoc multi-account setups conflate:
55
+
56
+ - **An identity** is a login: the thing that owns credentials and daemon state, selected with `agent-shim run @<name>` or, once `agent-shim shim enable` has run, `claude @<name>`.
57
+ - **A configuration profile** is a reusable, named bundle of sharing rules, independent of any identity, resolved per working directory via directory rules or a committed `.agent-shim.json`.
58
+
59
+ A third, optional thing sits on top of identities: **a pool** is a named list of them. Select `pool:<name>` where an identity name goes (`claude @pool:subs`) and agent-shim picks the member whose unused quota is closest to expiring, skipping any that are refused right now, using the usage it already records. See [docs/configuration-model.md](docs/configuration-model.md#pools-picking-an-account-at-launch).
60
+
61
+ Every top-level entry in `~/.claude` is classified into one of five categories, shipped as a default map (`config/categories.default.json`):
62
+
63
+ | Category | Default shared? | Example entries |
64
+ |---|---|---|
65
+ | `secret` | **Never** — hardcoded, cannot be overridden by any configuration layer | `.credentials.json`, `backups` |
66
+ | `runtime` | No | `daemon*`, `.git*`, `.DS_Store`, `mcp-needs-auth-cache.json`, `shell-snapshots`, `statsig`, `telemetry`, `stats-cache.json`, `usage-data`, `ide`, `cache`, `scheduled_tasks.lock` |
67
+ | `history` | Yes | `projects`, `sessions`, `session-env`, `teams`, `tasks`, `todos`, `history.jsonl`, `transcripts`, `paste-cache`, `file-history`, `plans`, `workflows`, `jobs`, `debug`, `downloads`, `chrome` |
68
+ | `knowledge` | Yes | `skills`, `agents`, `rules`, `memory`, `commands`, `plugins`, `hooks`, `AGENTS.md`, `CLAUDE.md`, `README.md` |
69
+ | `settings` | Yes | `settings.json`, `settings.local.json` |
70
+
71
+ Sharing composes through a cascade (shipped defaults, then a user-global override, then the active configuration profile, then directory rules for `$PWD`, shallowest to deepest); a specific path override always outranks a category default regardless of which layer set it. A committed `.agent-shim.json` at a project's root makes this portable: anyone who clones the repo and runs `claude` inside it gets the same isolation rules with no local setup.
72
+
73
+ `claude` refuses to launch while `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `CLAUDE_CODE_OAUTH_TOKEN` or a `CLAUDE_CODE_USE_BEDROCK`/`VERTEX`/`FOUNDRY` variable is set in the environment, because those outrank every identity's stored credential and would make all identities authenticate as the same account. Opt in deliberately with `AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL=1` for one launch or `agent-shim identity set <name> --allow-ambient-credential`.
74
+
75
+ Providers and identities take their token from one `credential` block: an ordered list of sources (`env`, `file`, `command`, and the `op` and `keychain` presets, plus a `literal` placeholder for a local proxy), tried in turn, and a target (`bearer`, `apiKey`, or `oauthToken` for an identity). The token reaches the child's environment only; `check`, `doctor` and `--json` report the source kind and target, never the value.
76
+
77
+ The full mechanics, including the credential block, the merge algorithm, conditional sharing rules (age, size, git branch, environment), the ambient-credential launch guard, and how `~/.claude/projects/` history is pattern-matched, are in [docs/configuration-model.md](docs/configuration-model.md). Worked examples are in [docs/examples.md](docs/examples.md).
78
+
79
+ ## CLI reference
80
+
81
+ ```
82
+ agent-shim <noun> <verb> [name] [options] # nouns: identity, profile, pool, provider, rule
83
+
84
+ agent-shim identity add <name>
85
+ agent-shim identity list [--json]
86
+ agent-shim identity show <name> [--json]
87
+ agent-shim identity set <name> [--default-profile <profile> | --no-default-profile] [--[no-]allow-ambient-credential]
88
+ agent-shim identity set <name> [--credential <source>]... [--credential-target <bearer|apiKey|oauthToken>] [--no-credential]
89
+ agent-shim identity remove <name> [--yes]
90
+ agent-shim identity use <name>
91
+ agent-shim @<name> # shorthand for `identity use <name>`
92
+ agent-shim identity resolve-conflicts <name> # interactively resolve a retained superseded farm's conflicts
93
+
94
+ agent-shim profile add [name] [--extends <profile>]... [--description <text>] # interactive with no options on a terminal
95
+ agent-shim profile set <name> [--category <category>=<bool>]... [--entry <category>/<path>=<bool>]...
96
+ agent-shim profile set <name> [--extends <profile>]... [--no-extends] [--description <text> | --no-description]
97
+ agent-shim profile set <name> [--[no-]launch-skip-permissions] [--[no-]launch-remote-control] [--[no-]launch-headroom] [--[no-]launch-track-usage]
98
+ agent-shim profile set <name> [--launch-provider <provider> | --no-launch-provider]
99
+ agent-shim profile list [--json]
100
+ agent-shim profile show <name> [--json]
101
+ agent-shim profile remove <name> [--yes]
102
+ agent-shim profile use <name> # the global default configuration profile
103
+
104
+ agent-shim pool add <name> --identity <identity>...
105
+ agent-shim pool set <name> --identity <identity>...
106
+ agent-shim pool list [--json]
107
+ agent-shim pool show <name> [--json]
108
+ agent-shim pool remove <name> [--yes]
109
+ agent-shim pool use <name>
110
+ agent-shim pool pick <name> [--json]
111
+
112
+ agent-shim provider add <name> --display-name <name> (--base-url <url> | --kind codex) (--credential <source>)... [--credential-target <bearer|apiKey>] [--env KEY=VALUE]...
113
+ [--codex-default-model <model>] [--codex-model <tier=model>]... [--codex-effort <none|low|medium|high>]
114
+ agent-shim provider set <name> [--display-name <name>] ([--base-url <url>] | --kind codex) [--credential <source>]... [--credential-target <bearer|apiKey>] [--env KEY=VALUE]... [--unset-env KEY]...
115
+ [--codex-default-model <model>] [--codex-model <tier=model>]... [--codex-effort <none|low|medium|high>]
116
+ agent-shim provider list [--json]
117
+ agent-shim provider show <name> [--json]
118
+ agent-shim provider remove <name> [--yes]
119
+
120
+ agent-shim rule add <path> [--config-profile <profile>] [--identity <identity>]
121
+ agent-shim rule set <path> [--config-profile <profile> | --no-config-profile] [--identity <identity> | --no-identity]
122
+ agent-shim rule list [--json]
123
+ agent-shim rule show <path> [--json]
124
+ agent-shim rule remove <path> [--yes]
125
+
126
+ agent-shim configure [path] [--identity <identity>]
127
+ agent-shim check [path] [--identity <identity>] [--json] [--strict]
128
+ agent-shim doctor [--json]
129
+ agent-shim headroom status [--json]
130
+ agent-shim codex status [--json]
131
+ agent-shim frontdoor status [--json]
132
+ agent-shim usage [--identity <name>] [--provider <name>] [--since <duration>] [--refresh] [--json]
133
+ agent-shim account show [<identity>] [--refresh] [--json]
134
+ agent-shim completion <bash|zsh|fish>
135
+ agent-shim shim enable [--dir <path>] [--force]
136
+ agent-shim shim disable [--dir <path>] [--force]
137
+
138
+ agent-shim run [@<identity>] [launch flags] [claude arguments]
139
+ # launch flags, recognised only before a `--` terminator:
140
+ # --identity <name> --config-profile <name> --provider <name> | --no-provider
141
+ # --category <category>=<bool> --share <category>/<path> --hide <category>/<path> (each repeatable)
142
+ # --[no-]skip-permissions --[no-]remote-control --[no-]headroom --[no-]track-usage --[no-]wait
143
+ claude @<identity> ... # the same, once `agent-shim shim enable` has run
144
+ ```
145
+
146
+ Every `list`, `show`, `check`, `doctor` and `headroom status` prints text by default and JSON with `--json`. Prompts appear only when standard input is a terminal; without one, a command that needs input fails with the option that supplies it (a `remove` needs `--yes`). Failures print as `agent-shim: <message>` and exit 1, usage errors exit 2, a selected provider or identity whose credential block yields no token exits 64, and `AGENT_SHIM_DEBUG=1` adds stack traces to unexpected errors. `agent-shim completion <bash|zsh|fish>` prints a shell completion script.
147
+
148
+ `agent-shim check [path]` resolves the full cascade for a directory without touching the farm, and is the primary way to answer "why is X shared or hidden here". `agent-shim doctor` audits the whole `~/.agent-shim` config graph at once: every identity, profile, `extends` chain, provider (naming the exact replacement for a file still in the format before the credential block) and directory rule, plus whether the right `agent-shim` is the one actually on `PATH`.
149
+
150
+ The full per-setting flag and environment-variable table (global, one-off, and directory-scoped forms of every setting), and the file-precedence rules `configure` uses when writing a toggle, are in [docs/cli-reference.md](docs/cli-reference.md).
151
+
152
+ ## Architecture
153
+
154
+ One compiled binary backs both `claude` and `agent-shim`; the entrypoint dispatches on `path.basename(process.argv[1])`, so installation just needs two differently-named copies (or hardlinks) of the same executable on `PATH`.
155
+
156
+ ```
157
+ src/
158
+ cli.ts # entrypoint: dispatches on invoked name to launcher vs identity/profile-manager subcommands
159
+ launcher.ts # runLauncher: thin orchestration over launcher/*
160
+ launcher/ # argv parsing, the ambient-credential guard, identity/profile resolution, farm resync
161
+ identityManager.ts, configProfiles.ts, providers.ts, directoryRules.ts # the `identity`/`profile`/`provider`/`rule` nouns
162
+ program.ts, completion.ts # buildProgram (the whole command tree, side-effect free) and generated shell completion
163
+ configure.ts, check.ts, doctor.ts, claudeShim.ts # interactive picker, dry-run inspector, whole-tree audit, `claude` shim
164
+ resolve/ # the pure cascade resolver: flatten, decide, extends, walk, plan, reconcile
165
+ config/ # Zod schemas, cosmiconfig loading, category classification, atomic JSON store
166
+ index.ts # the library surface (see below): resolver, farm sync, headroom routing, the ambient-credential guard
167
+ schema/ # published JSON Schemas, generated by `pnpm schema`
168
+ scripts/build.mts # esbuild bundle, then `node --build-sea`
169
+ install.sh # downloads, verifies, and installs the latest release binary
170
+ ```
171
+
172
+ Every custom error extends `CliError`; `main()`'s top-level catch prints its message alone for an expected failure and a full stack trace for anything else. Config validation is Zod throughout, with `categories` a closed shape and `entries` an open, glob-capable record, since the two fields have opposite key cardinality. The resolver itself is pure: it takes filesystem, git, and environment facts as an injected parameter rather than reading them itself, which is what makes it unit-testable with fakes.
173
+
174
+ The package also publishes a library surface alongside the binary: `import { resolveDecisions, resyncFarm, startConnectServer, runFrontDoorSupervisor, runSupervisor, detectAmbientCredential } from "agent-shim"` (ESM or CJS, with type declarations). It re-exports only the pure, port-injected modules, so another tool can resolve identities, sync a farm, run the front door's CONNECT surface and supervisor and the headroom supervisor, or check the ambient-credential guard in process without the CLI installed. Nothing reachable from it imports `commander` or `@clack/prompts`, and the build fails if that stops being true. Its dependencies stay external, installed through the package's own `dependencies`.
175
+
176
+ The full source layout with per-file responsibilities, the schema design rationale, why config loading uses cosmiconfig's `load()` rather than `search()`, and the resolver's merge and materialisation mechanics are in [docs/architecture.md](docs/architecture.md).
177
+
178
+ ## Releases and builds
179
+
180
+ Commits follow [Conventional Commits](https://www.conventionalcommits.org/) (enforced by commitlint); every push to `main` runs semantic-release, which decides whether a release is warranted, bumps the version, updates `CHANGELOG.md`, and tags it. `pnpm build` bundles the CLI and then runs Node's single-executable-application step, which needs Node 25.5.0 or later with SEA support: a Homebrew-installed Node has this compiled out, so use a build from nodejs.org or a version manager instead.
181
+
182
+ macOS x64 is the one target Node core does not verify SEA against, and the resulting binary segfaults on that architecture: a known, unfixed upstream Node limitation, not a bug in this project. Homebrew and `install.sh` both work around it by installing through npm and a real Node on that one platform instead of the broken binary.
183
+
184
+ The full CI pipeline (why the six platform builds also run on every PR, the semantic-release quirks, npm OIDC trusted publishing, and the root-cause investigation behind the macOS x64 crash) is in [docs/release-process.md](docs/release-process.md).
185
+
186
+ ## Testing
187
+
188
+ The resolver's cascade and materialisation logic is pure, taking filesystem, git, and environment facts as an injected parameter, so it is unit-tested extensively with fakes rather than a real filesystem, `git`, or `~/.agent-shim`. `launcher.ts`, `check.ts`, and `doctor.ts` each get their own coverage for the real side effects the resolver's purity does not reach: symlink and materialised-directory writes, spawning the real `claude` binary, and the ambient-credential guard.
189
+
190
+ The full list of test cases, including the two-phase merge algorithm, conditional entries, farm reconciliation, and every command's own edge cases, is in [docs/testing.md](docs/testing.md).
191
+
192
+ ## Development
193
+
194
+ ```bash
195
+ pnpm install # install dependencies
196
+ pnpm typecheck # tsc --noEmit
197
+ pnpm lint # eslint . --max-warnings 0
198
+ pnpm test # vitest run
199
+ pnpm build # bundle src/cli.ts with esbuild, then node --build-sea (needs Node >= v25.5.0 with SEA support, not Homebrew's build; see docs/release-process.md)
200
+ pnpm schema # regenerate schema/*.schema.json from src/config/schema.ts; CI fails if this drifts from what's committed
201
+ ```
202
+
203
+ Run a single test file directly with `pnpm exec vitest run <path>`. Tests never touch a real identity: `vitest.config.ts` sets `AGENT_SHIM_HOME` to a throwaway directory, and a setup file refuses to run at all if that variable is unset or resolves to the real `~/.agent-shim`.
204
+
205
+ Commits are gated by Husky hooks: `commit-msg` enforces conventional-commit format, `pre-commit` runs `eslint --fix` on staged files and rejects merge/squash commits and mass deletions on `main`, and `pre-push` runs the full test suite and also rejects a push that would delete more than 100 files on the remote.
206
+
207
+ A fresh clone needs one extra step before committing anything, since git stores filter definitions in `.git/config` rather than in the repository:
208
+
209
+ ```sh
210
+ git config filter.secrets.clean 'python3 .githooks/git-filter-clean %f'
211
+ git config filter.secrets.smudge cat
212
+ ```
213
+
214
+ Without this, the secret-redaction clean filter `.gitattributes` declares resolves to nothing and content reaches the object store unredacted. Never add a `diff.secrets.textconv` pointing at the same script: it is a stream filter expecting stdin, not a path, and would hang forever under lint-staged. Full rationale for the `%f` argument, plus the test-isolation and commit-hook details above, is in [docs/development.md](docs/development.md).
215
+
216
+ ## Contributing
217
+
218
+ Issues and pull requests are welcome. Please keep the tool itself free of assumptions about any particular organisation, client, or directory layout — it should work the same for anyone. Governance details (contribution sign-off requirements, code of conduct, review process) aren't decided yet and will be added here before the repository is opened up beyond its initial maintainers.
219
+
220
+ ## References
221
+
222
+ - [docs/configuration-model.md](docs/configuration-model.md): identities, configuration profiles, category-based sharing, the cascade merge algorithm, directory rules, conditional matching, portable `.agent-shim.json`, `~/.claude/projects/` pattern matching, providers, headroom routing, and launch flags.
223
+ - [docs/cli-reference.md](docs/cli-reference.md): the full flag and environment-variable table, `configure`'s file-write precedence, and the `check`/`doctor` debugging commands.
224
+ - [docs/examples.md](docs/examples.md): worked configuration examples and a permutation reference.
225
+ - [docs/architecture.md](docs/architecture.md): the source layout file by file, error reporting design, schema rationale, and resolver mechanics.
226
+ - [docs/release-process.md](docs/release-process.md): the semantic-release pipeline, the Node SEA build, its macOS x64 limitation, and npm/GitHub Packages publishing.
227
+ - [docs/testing.md](docs/testing.md): the full list of cases the test suites cover.
228
+ - [docs/installation.md](docs/installation.md): every install channel in full, with the platform support matrix.
229
+ - [docs/development.md](docs/development.md): test isolation, commit hooks, and the secret-redaction filter rationale.
230
+
231
+ ## License
232
+
233
+ [Apache License 2.0](LICENSE).