auto-mode 0.3.0 → 0.4.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.
- package/README.md +58 -95
- package/dist/{classify-locally-BRMllwcd.js → classify-locally-BcyBikYr.js} +721 -37
- package/dist/cli.js +66 -12
- package/dist/index.d.ts +31 -3
- package/dist/index.js +1 -1
- package/mods/auto-mode/.claude-plugin/plugin.json +14 -0
- package/mods/auto-mode/hooks/build-prompt-context.claude-check.ts +94 -0
- package/mods/auto-mode/hooks/build-prompt-context.ts +37 -0
- package/mods/auto-mode/hooks/hooks.json +1 -0
- package/mods/auto-mode/hooks/parse-decision.ts +51 -0
- package/mods/auto-mode/hooks/register.claude-check.ts +1016 -0
- package/mods/auto-mode/hooks/register.ts +154 -0
- package/mods/auto-mode/hooks/testing.d.ts +37 -0
- package/mods/auto-mode/hooks/types.ts +117 -0
- package/mods/auto-mode/tsconfig.json +12 -0
- package/package.json +7 -4
- package/policy/decision.md +31 -0
package/README.md
CHANGED
|
@@ -1,132 +1,95 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<h1>auto-mode</h1>
|
|
3
|
-
|
|
4
3
|
<p>
|
|
5
4
|
<a href="https://www.npmjs.com/package/auto-mode"><img src="https://img.shields.io/npm/v/auto-mode" alt="npm version"></a>
|
|
6
5
|
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license"></a>
|
|
7
6
|
</p>
|
|
8
|
-
|
|
9
|
-
<p>
|
|
10
|
-
<a href="./docs/README.md">Documentation</a> •
|
|
11
|
-
<a href="./docs/guides/configuration.md">Configuration</a> •
|
|
12
|
-
<a href="./policy/rules.md">The rules</a> •
|
|
13
|
-
<a href="./docs/architecture/overview.md">Architecture</a>
|
|
14
|
-
</p>
|
|
15
7
|
</div>
|
|
16
8
|
|
|
17
|
-
**auto-mode**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Claude Code's built-in auto mode judges actions only for Claude. Point Claude Code at another model
|
|
21
|
-
through an Anthropic-compatible gateway — GLM, Kimi, Muse Spark — and that judging stops. Every
|
|
22
|
-
shell command, file write, and push needs your approval again.
|
|
9
|
+
**auto-mode** judges coding-agent tool calls through a permission hook. It returns allow, deny, or
|
|
10
|
+
no verdict to Claude Code, Codex, and Muse Code. Local rules settle read-only actions and build
|
|
11
|
+
cleanup; Jev evaluates the remaining actions against a written policy.
|
|
23
12
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
The Jev request includes the policy, your configured environment and permissions, the complete
|
|
14
|
+
proposed action, and the last direct user message. It excludes the rest of the session. Configure
|
|
15
|
+
standing permissions upfront; earlier conversational grants and restrictions are unavailable to the
|
|
16
|
+
classifier.
|
|
27
17
|
|
|
28
18
|
## Install
|
|
29
19
|
|
|
30
20
|
```sh
|
|
31
21
|
npm i -g auto-mode
|
|
32
|
-
auto-mode init claude
|
|
22
|
+
auto-mode init claude --event permission-request
|
|
33
23
|
```
|
|
34
24
|
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
Paste the printed hook entry into the file it identifies. `init` prints configuration and never
|
|
26
|
+
writes into a harness's settings. [Harnesses](./docs/guides/harnesses.md) covers registration for
|
|
27
|
+
each harness.
|
|
37
28
|
|
|
38
|
-
|
|
29
|
+
Create the classifier configuration:
|
|
39
30
|
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"preset": "jev",
|
|
34
|
+
"provider": { "apiKeyEnv": "TYPESAFE_API_KEY" }
|
|
35
|
+
}
|
|
45
36
|
```
|
|
46
37
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Two tiers.
|
|
52
|
-
|
|
53
|
-
1. **Local rules.** Deterministic matching, no network call, under a millisecond. Answers allow or
|
|
54
|
-
escalate, never deny. Reads, listings, `git status`, and deleting build output are settled here
|
|
55
|
-
and never reach the model.
|
|
56
|
-
2. **The model.** Everything else goes to a small reasoning model with the policy as its system
|
|
57
|
-
prompt. A hard case takes 13 to 24 seconds.
|
|
38
|
+
Save it as `~/.config/auto-mode/config.json` and export your TypeSafe API key. Hooks that run with a
|
|
39
|
+
scrubbed environment need `provider.apiKeyCommand` instead.
|
|
40
|
+
[Configuration](./docs/guides/configuration.md) covers credentials and provider overrides.
|
|
58
41
|
|
|
59
|
-
|
|
60
|
-
action. A wrong deny stops work you asked for, and the rules that deny are prose that needs a
|
|
61
|
-
reader.
|
|
42
|
+
## Standing permissions
|
|
62
43
|
|
|
63
|
-
|
|
44
|
+
Jev imports explicit entries from `autoMode.environment`, `autoMode.allow`, `autoMode.soft_deny`,
|
|
45
|
+
and `autoMode.hard_deny` in your user Claude settings. It imports no credential values or shell
|
|
46
|
+
permission patterns. `$defaults` refers to auto-mode's shipped policy; it does not expand Claude's
|
|
47
|
+
built-in classifier rules.
|
|
64
48
|
|
|
65
|
-
|
|
49
|
+
Configured allows clear soft blocks. Hard blocks take priority over all allows and conversational
|
|
50
|
+
consent. [False-positive clarification](./docs/guides/policy.md#false-positive-clarification) can
|
|
51
|
+
clear Policy Tampering and Audit Tampering. The last direct user message can supply the exact action
|
|
52
|
+
and target that a soft block needs; replies such as “go ahead” cannot supply an unseen proposal.
|
|
66
53
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
| [`policy/classifier.md`](./policy/classifier.md) | Threat model, consent bar, evaluation rules, output contract | Change how judgement works |
|
|
54
|
+
Read [the policy](./policy/rules.md) before you enable the hook.
|
|
55
|
+
[Writing a policy](./docs/guides/policy.md) covers the precedence and the limits of an action-only
|
|
56
|
+
assessment.
|
|
71
57
|
|
|
72
|
-
|
|
73
|
-
the whole of `rules.md`. `auto-mode print-prompt` writes the result, which is what the model reads.
|
|
58
|
+
## Decisions and failures
|
|
74
59
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
resembles a blocked action and is not: deleting `node_modules`, running a formatter, dropping a
|
|
79
|
-
local test database.
|
|
60
|
+
Jev evaluates each named rule with a typed choice. auto-mode returns a denial for a confident block,
|
|
61
|
+
approval when every rule confidently allows the action, and manual approval for uncertain decisions.
|
|
62
|
+
The confidence threshold is configurable and needs evaluation against your actions.
|
|
80
63
|
|
|
81
|
-
|
|
82
|
-
`
|
|
83
|
-
|
|
84
|
-
## Harnesses
|
|
85
|
-
|
|
86
|
-
All three were verified end to end: the hook denied a real tool call and the harness stopped it.
|
|
87
|
-
|
|
88
|
-
| Harness | Match every tool | Also needed |
|
|
89
|
-
| ----------- | ----------------- | --------------------------------------- |
|
|
90
|
-
| Claude Code | `"matcher": ".*"` | — |
|
|
91
|
-
| Codex | omit `matcher` | `hooks = true`, and trust the hook once |
|
|
92
|
-
| Muse Code | `"matcher": ""` | no `timeout_ms` key |
|
|
93
|
-
|
|
94
|
-
Each difference stops the hook running if you get it wrong, and none of them reports an error.
|
|
95
|
-
`init` prints the right one. Details in [Harnesses](./docs/guides/harnesses.md).
|
|
96
|
-
|
|
97
|
-
## Writing nothing is an answer
|
|
98
|
-
|
|
99
|
-
It means auto-mode has no opinion, and the harness does what it would have done alone. That is the
|
|
100
|
-
output for an unknown harness, an event that is not a tool gate, malformed input, a missing key, and
|
|
101
|
-
a model that times out.
|
|
102
|
-
|
|
103
|
-
auto-mode can therefore only narrow what your harness already allows. It never removes a gate that
|
|
104
|
-
was there. Set `onFailure` to `deny` to fail closed instead.
|
|
64
|
+
A missing key, failed API call, malformed response, or oversized request follows `onFailure`. The
|
|
65
|
+
default `defer` writes no verdict and leaves the harness to decide; `deny` fails closed. Failures
|
|
66
|
+
write a diagnostic to stderr. auto-mode never truncates a Jev action to make it fit.
|
|
105
67
|
|
|
106
68
|
## Commands
|
|
107
69
|
|
|
108
|
-
| Command |
|
|
109
|
-
| ---------------------------- |
|
|
110
|
-
| `auto-mode run` | Read a payload
|
|
111
|
-
| `auto-mode run --explain` |
|
|
112
|
-
| `auto-mode run --local-only` | Skip the model tier
|
|
113
|
-
| `auto-mode
|
|
114
|
-
| `auto-mode
|
|
70
|
+
| Command | Effect |
|
|
71
|
+
| ---------------------------- | ----------------------------------------- |
|
|
72
|
+
| `auto-mode run` | Read a hook payload and write a verdict |
|
|
73
|
+
| `auto-mode run --explain` | Write decision details to stderr |
|
|
74
|
+
| `auto-mode run --local-only` | Skip the model tier |
|
|
75
|
+
| `auto-mode run --jev-only` | Require Jev with a 5-second API timeout |
|
|
76
|
+
| `auto-mode print-prompt` | Print the selected provider's base policy |
|
|
77
|
+
| `auto-mode init <harness>` | Print a hook entry |
|
|
78
|
+
|
|
79
|
+
Existing `spark`, `claude`, and `glm` presets use the Messages API and conversation history. Select
|
|
80
|
+
`jev` explicitly to change an existing provider configuration.
|
|
115
81
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
[harness guide](./docs/guides/harnesses.md#which-event) covers the choice.
|
|
82
|
+
The optional [Claude permission mod](./docs/guides/claude-mod.md) evaluates ask decisions before the
|
|
83
|
+
permission dialog. It preserves existing allow and deny decisions and has a bounded child process.
|
|
119
84
|
|
|
120
85
|
## Documentation
|
|
121
86
|
|
|
122
|
-
- [
|
|
123
|
-
contract
|
|
124
|
-
- [Configuration](./docs/guides/configuration.md)
|
|
125
|
-
|
|
126
|
-
- [Harnesses](./docs/guides/harnesses.md)
|
|
127
|
-
|
|
128
|
-
- [Writing a policy](./docs/guides/policy.md) — the rule tiers, the consent bar, and how to change
|
|
129
|
-
or replace the shipped rules.
|
|
87
|
+
- [Architecture](./docs/architecture/overview.md) covers the request, decision combination, and wire
|
|
88
|
+
contract.
|
|
89
|
+
- [Configuration](./docs/guides/configuration.md) covers every setting and the imported Claude
|
|
90
|
+
rules.
|
|
91
|
+
- [Harnesses](./docs/guides/harnesses.md) covers registration and hook trust.
|
|
92
|
+
- [Writing a policy](./docs/guides/policy.md) covers rule edits and evaluation.
|
|
130
93
|
|
|
131
94
|
## Licence
|
|
132
95
|
|