auto-mode 0.2.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 -91
- package/dist/{classify-locally-rTUwxBZi.js → classify-locally-BcyBikYr.js} +744 -44
- package/dist/cli.js +88 -15
- package/dist/index.d.ts +33 -5
- 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,128 +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
|
-
|
|
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.
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
auto-mode replaces it. The harness calls it before a tool runs, hands it the pending call, and reads
|
|
25
|
-
back allow, deny, or nothing. It works in Claude Code, Codex, and Muse Code, and behaves the same
|
|
26
|
-
whichever model drives them.
|
|
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.
|
|
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.
|
|
52
41
|
|
|
53
|
-
|
|
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.
|
|
42
|
+
## Standing permissions
|
|
58
43
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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.
|
|
62
48
|
|
|
63
|
-
|
|
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.
|
|
64
53
|
|
|
65
|
-
|
|
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.
|
|
66
57
|
|
|
67
|
-
|
|
68
|
-
| ------------------------------------------------ | ------------------------------------------------------------ | -------------------------- |
|
|
69
|
-
| [`policy/rules.md`](./policy/rules.md) | 22 rules, 7 exceptions | Change what is blocked |
|
|
70
|
-
| [`policy/classifier.md`](./policy/classifier.md) | Threat model, consent bar, evaluation rules, output contract | Change how judgement works |
|
|
58
|
+
## Decisions and failures
|
|
71
59
|
|
|
72
|
-
|
|
73
|
-
|
|
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.
|
|
74
63
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
resembles a blocked action and is not: deleting `node_modules`, running a formatter, dropping a
|
|
79
|
-
local test database.
|
|
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.
|
|
80
67
|
|
|
81
|
-
|
|
82
|
-
`rulesPath` points at your own file and replaces the shipped one whole.
|
|
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.
|
|
68
|
+
## Commands
|
|
102
69
|
|
|
103
|
-
|
|
104
|
-
|
|
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 |
|
|
105
78
|
|
|
106
|
-
|
|
79
|
+
Existing `spark`, `claude`, and `glm` presets use the Messages API and conversation history. Select
|
|
80
|
+
`jev` explicitly to change an existing provider configuration.
|
|
107
81
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
| `auto-mode run` | Read a payload on stdin, write a verdict on stdout |
|
|
111
|
-
| `auto-mode run --explain` | Also write the reasoning to stderr |
|
|
112
|
-
| `auto-mode run --local-only` | Skip the model tier |
|
|
113
|
-
| `auto-mode print-prompt` | Print the assembled system prompt |
|
|
114
|
-
| `auto-mode init <harness>` | Print the hook entry to add |
|
|
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.
|
|
115
84
|
|
|
116
85
|
## Documentation
|
|
117
86
|
|
|
118
|
-
- [
|
|
119
|
-
contract
|
|
120
|
-
- [Configuration](./docs/guides/configuration.md)
|
|
121
|
-
|
|
122
|
-
- [Harnesses](./docs/guides/harnesses.md)
|
|
123
|
-
|
|
124
|
-
- [Writing a policy](./docs/guides/policy.md) — the rule tiers, the consent bar, and how to change
|
|
125
|
-
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.
|
|
126
93
|
|
|
127
94
|
## Licence
|
|
128
95
|
|