codex-auto-approve 0.1.1
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/.agents/plugins/marketplace.json +20 -0
- package/LICENSE +21 -0
- package/README.md +248 -0
- package/package.json +50 -0
- package/plugins/auto-approve/.codex-plugin/plugin.json +34 -0
- package/plugins/auto-approve/README.md +63 -0
- package/plugins/auto-approve/hooks/hooks.json +16 -0
- package/plugins/auto-approve/package.json +9 -0
- package/plugins/auto-approve/scripts/auto_approve.js +98 -0
- package/plugins/auto-approve/skills/auto-approve/SKILL.md +17 -0
- package/plugins/auto-approve/skills/auto-approve/agents/openai.yaml +6 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "codex-auto-approve",
|
|
3
|
+
"interface": {
|
|
4
|
+
"displayName": "Codex Auto Approve"
|
|
5
|
+
},
|
|
6
|
+
"plugins": [
|
|
7
|
+
{
|
|
8
|
+
"name": "auto-approve",
|
|
9
|
+
"source": {
|
|
10
|
+
"source": "local",
|
|
11
|
+
"path": "./plugins/auto-approve"
|
|
12
|
+
},
|
|
13
|
+
"policy": {
|
|
14
|
+
"installation": "AVAILABLE",
|
|
15
|
+
"authentication": "ON_INSTALL"
|
|
16
|
+
},
|
|
17
|
+
"category": "Productivity"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 fuliucansheng
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# Codex Auto Approve
|
|
2
|
+
|
|
3
|
+
A small Codex plugin that can automatically allow supported permission
|
|
4
|
+
requests. The switch is explicit, persistent, and **disabled by default**.
|
|
5
|
+
|
|
6
|
+
> [!WARNING]
|
|
7
|
+
> Enabling Auto Approve lets Codex proceed without asking you for every
|
|
8
|
+
> supported permission request. Review the plugin and only enable it in an
|
|
9
|
+
> environment you trust. Disable it as soon as you no longer need it.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- A recent version of Codex with plugin and hook support
|
|
14
|
+
- Node.js 22 or newer, with `node` on `PATH`
|
|
15
|
+
|
|
16
|
+
## Install the Codex plugin
|
|
17
|
+
|
|
18
|
+
Add this repository as a Codex plugin marketplace, then install the plugin:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
codex plugin marketplace add fuliucansheng/codex-auto-approve
|
|
22
|
+
codex plugin add auto-approve@codex-auto-approve
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The marketplace ships the prebuilt `scripts/auto_approve.js` controller inside
|
|
26
|
+
the plugin. Installation needs only Node.js: no `npm install`, build step,
|
|
27
|
+
`tsx`, or `ts-node` is needed. The plugin has no production dependencies, and
|
|
28
|
+
its local `package.json` keeps the JavaScript runnable regardless of a parent
|
|
29
|
+
package's module type.
|
|
30
|
+
|
|
31
|
+
Start a new Codex conversation after installation so the skill and hook are
|
|
32
|
+
loaded. You can inspect the installed hook with `/hooks`.
|
|
33
|
+
|
|
34
|
+
## npm CLI
|
|
35
|
+
|
|
36
|
+
Once the package is published to npm, install the command globally:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npm install -g codex-auto-approve
|
|
40
|
+
codex-auto-approve status
|
|
41
|
+
codex-auto-approve enable
|
|
42
|
+
codex-auto-approve disable
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Or run without a global installation:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npx --yes codex-auto-approve status
|
|
49
|
+
npx --yes codex-auto-approve enable
|
|
50
|
+
npx --yes codex-auto-approve disable
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Node.js 22 or newer is required. The npm package includes prebuilt JavaScript
|
|
54
|
+
and has no production dependencies or consumer build step. Installing the CLI
|
|
55
|
+
alone **does not register Codex hooks or skills**; use the marketplace
|
|
56
|
+
installation above for integration with Codex. Both interfaces control the
|
|
57
|
+
same local switch. The tarball also preserves the root
|
|
58
|
+
`.agents/plugins/marketplace.json` descriptor and the complete
|
|
59
|
+
`plugins/auto-approve` directory layout for marketplace use.
|
|
60
|
+
|
|
61
|
+
## Use
|
|
62
|
+
|
|
63
|
+
Invoke the bundled skill in Codex:
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
$auto-approve status
|
|
67
|
+
$auto-approve enable
|
|
68
|
+
$auto-approve disable
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Type `$` in the composer to select the skill, or find it through `/skills`.
|
|
72
|
+
`$auto-approve` is a plugin skill mention, not a built-in slash command.
|
|
73
|
+
|
|
74
|
+
The actions are:
|
|
75
|
+
|
|
76
|
+
- `status`: show whether automatic approval is enabled.
|
|
77
|
+
- `enable`: automatically allow all supported `PermissionRequest` events.
|
|
78
|
+
- `disable`: return to the normal Codex approval flow.
|
|
79
|
+
|
|
80
|
+
The skill runs the bundled Node.js controller. `status` exits with code 0 when
|
|
81
|
+
enabled and 1 when disabled. Successful `enable` and `disable` actions exit 0;
|
|
82
|
+
invalid arguments exit 2 and write usage to stderr. Filesystem errors during
|
|
83
|
+
enable or disable exit 1 and write an error to stderr.
|
|
84
|
+
|
|
85
|
+
## Update
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
codex plugin marketplace upgrade codex-auto-approve
|
|
89
|
+
codex plugin add auto-approve@codex-auto-approve
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Start a new Codex conversation after updating.
|
|
93
|
+
|
|
94
|
+
## Uninstall
|
|
95
|
+
|
|
96
|
+
Disable Auto Approve first, then remove the plugin and marketplace:
|
|
97
|
+
|
|
98
|
+
```text
|
|
99
|
+
$auto-approve disable
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
codex plugin remove auto-approve@codex-auto-approve
|
|
104
|
+
codex plugin marketplace remove codex-auto-approve
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## How it works
|
|
108
|
+
|
|
109
|
+
The controller stores the enabled state at:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
~/.local/state/codex-auto-approve/enabled.json
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Only an object containing `"enabled": true` enables the bundled
|
|
116
|
+
`PermissionRequest` hook, which returns an `allow` decision. Existing
|
|
117
|
+
`enabled.json` files remain compatible. Missing, unreadable, malformed, or
|
|
118
|
+
non-object state fails closed, as do other enabled values such as `"true"` or
|
|
119
|
+
`1`. Invalid hook input silently does nothing. Status and hook calls never
|
|
120
|
+
create or repair state; only an explicit enable action writes the switch.
|
|
121
|
+
|
|
122
|
+
On filesystems supporting POSIX modes, newly created state directories use
|
|
123
|
+
`0700` and the state file uses `0600`. Disable removes only `enabled.json` and
|
|
124
|
+
is safe to repeat.
|
|
125
|
+
|
|
126
|
+
The hook only covers permission requests exposed to Codex lifecycle hooks,
|
|
127
|
+
including supported shell, file-edit, and MCP tool requests. Some Computer Use
|
|
128
|
+
and app-level confirmations are always shown directly to the user and cannot
|
|
129
|
+
be auto-approved by this plugin. Managed workspace policy can also limit what
|
|
130
|
+
the plugin is allowed to approve.
|
|
131
|
+
|
|
132
|
+
## Local development
|
|
133
|
+
|
|
134
|
+
[src/auto_approve.ts](src/auto_approve.ts) is the canonical source. `tsc`
|
|
135
|
+
compiles it to the checked-in
|
|
136
|
+
[plugins/auto-approve/scripts/auto_approve.js](plugins/auto-approve/scripts/auto_approve.js).
|
|
137
|
+
Include the regenerated JavaScript with every source change so marketplace
|
|
138
|
+
copies remain ready to run. The root development dependencies are only the
|
|
139
|
+
TypeScript compiler and Node type definitions.
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
npm ci
|
|
143
|
+
npm run build
|
|
144
|
+
npm run typecheck
|
|
145
|
+
npm test
|
|
146
|
+
git diff --check
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Tests use Node's built-in test/assert modules and execute the compiled CLI in
|
|
150
|
+
child processes, including a standalone copy of the plugin in a path with
|
|
151
|
+
spaces. The test runner and every controller invocation use isolated temporary
|
|
152
|
+
`HOME` and `USERPROFILE` directories. Build before testing source changes;
|
|
153
|
+
`npm test` checks the shipped JavaScript and runs real `npm pack`, offline
|
|
154
|
+
installation into a separate temporary global prefix, executable CLI and
|
|
155
|
+
standalone plugin smoke tests, and credential-free `npm publish --dry-run`.
|
|
156
|
+
Package tests check exact tarball contents, metadata, executable mode, version
|
|
157
|
+
parity, and absence of source, developer scripts, and runtime dependencies.
|
|
158
|
+
Only `prepack` rebuilds (`npm run build`); it never runs tests, avoiding recursion.
|
|
159
|
+
Package tests use empty temporary npm configs and a separate cache as well as
|
|
160
|
+
an isolated home. Release validator behavior tests cover matching versions,
|
|
161
|
+
mismatches, malformed tags, and rejection of prereleases.
|
|
162
|
+
|
|
163
|
+
CI runs these checks on Node.js 22 and 24 on Linux and macOS and rejects drift
|
|
164
|
+
between the source and checked-in JavaScript. POSIX mode checks skip on
|
|
165
|
+
Windows; permission-denial checks also skip when run as root.
|
|
166
|
+
|
|
167
|
+
## npm releases
|
|
168
|
+
|
|
169
|
+
Publishing requires a maintainer with permission to publish the npm package
|
|
170
|
+
and manage this repository's GitHub Actions settings. Configure trusted
|
|
171
|
+
publishing or the first-publication bootstrap described below before releasing.
|
|
172
|
+
The npm installation commands above require a successful publication first.
|
|
173
|
+
|
|
174
|
+
The [publish workflow](.github/workflows/publish-npm.yml) runs **only** when a
|
|
175
|
+
GitHub release is published. It skips releases marked as prereleases and
|
|
176
|
+
requires a stable, canonical `vX.Y.Z` tag. Prerelease versions and build metadata
|
|
177
|
+
do not publish, even if the GitHub release is incorrectly marked stable. PRs
|
|
178
|
+
and ordinary branch pushes never trigger npm publication.
|
|
179
|
+
|
|
180
|
+
Keep these versions identical when preparing a release (currently `0.1.1`):
|
|
181
|
+
|
|
182
|
+
- Root `package.json`
|
|
183
|
+
- `package-lock.json`: top-level `version` and `packages[""].version`
|
|
184
|
+
- `plugins/auto-approve/package.json`
|
|
185
|
+
- `plugins/auto-approve/.codex-plugin/plugin.json`
|
|
186
|
+
|
|
187
|
+
After updating the manifests, refresh the lockfile with
|
|
188
|
+
`npm install --package-lock-only`, then run:
|
|
189
|
+
|
|
190
|
+
```sh
|
|
191
|
+
npm ci
|
|
192
|
+
npm run build
|
|
193
|
+
npm run typecheck
|
|
194
|
+
npm test
|
|
195
|
+
npm run validate:release -- v0.1.1
|
|
196
|
+
git diff --exit-code -- plugins/auto-approve/scripts/auto_approve.js
|
|
197
|
+
git diff --check
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Use the intended version in the validation command for future releases.
|
|
201
|
+
Include regenerated JavaScript with source changes. After reviewing and merging
|
|
202
|
+
the release changes, tag that exact commit with the matching `vX.Y.Z` and
|
|
203
|
+
publish a stable GitHub release for that tag. npm versions are immutable;
|
|
204
|
+
fixes after publication require a new version and tag.
|
|
205
|
+
|
|
206
|
+
The workflow checks out the exact release tag, verifies all version fields,
|
|
207
|
+
installs dependencies, builds, typechecks, tests, and rejects generated artifact
|
|
208
|
+
drift. Tests retain their installed and inspected archive using
|
|
209
|
+
`NPM_TEST_PACK_DESTINATION`; the publish step sends that same tarball with
|
|
210
|
+
`--access public --provenance`. Release publish jobs are serialized.
|
|
211
|
+
|
|
212
|
+
### Trusted publishing and first-publication bootstrap
|
|
213
|
+
|
|
214
|
+
Publishing uses a GitHub-hosted Ubuntu runner with Node.js 24 and explicitly
|
|
215
|
+
pinned npm 11.6.2. npm trusted publishing requires npm **11.5.1 or newer** and
|
|
216
|
+
Node.js **22.14.0 or newer**; this is separate from the CLI's Node.js 22 runtime
|
|
217
|
+
minimum. The workflow grants only `contents: read` and `id-token: write`.
|
|
218
|
+
|
|
219
|
+
Once the package exists, open its npm settings and add a **GitHub Actions**
|
|
220
|
+
Trusted Publisher with these exact fields:
|
|
221
|
+
|
|
222
|
+
| Field | Value |
|
|
223
|
+
| --- | --- |
|
|
224
|
+
| Organization or user | `fuliucansheng` |
|
|
225
|
+
| Repository | `codex-auto-approve` |
|
|
226
|
+
| Workflow filename | `publish-npm.yml` |
|
|
227
|
+
| Environment | Leave blank (the workflow has no environment) |
|
|
228
|
+
| Allowed actions (if shown) | Allow direct publishing with `npm publish` |
|
|
229
|
+
|
|
230
|
+
No npm token is needed after that mapping is configured. The workflow uses npm
|
|
231
|
+
OIDC automatically when `secrets.NPM_TOKEN` is absent. As recommended by the
|
|
232
|
+
[npm trusted publishing documentation](https://docs.npmjs.com/trusted-publishers/),
|
|
233
|
+
the release workflow does not restore or save dependency caches.
|
|
234
|
+
|
|
235
|
+
For the first publication, the package does not yet have settings for a trusted
|
|
236
|
+
publisher. An authorized maintainer can create a short-lived granular npm token
|
|
237
|
+
with permission to create/publish this package (and bypass 2FA for automation),
|
|
238
|
+
then add it as the repository Actions secret **`NPM_TOKEN`**. The same workflow
|
|
239
|
+
uses it only in the publish step as an optional bootstrap fallback. After the
|
|
240
|
+
first successful stable release, configure the Trusted Publisher mapping,
|
|
241
|
+
remove the repository secret, and revoke the bootstrap token. Subsequent
|
|
242
|
+
releases use OIDC. Do not put tokens in repository files. These setup steps
|
|
243
|
+
must be performed by a maintainer; a dry run verifies packaging, not registry
|
|
244
|
+
authorization or successful publication.
|
|
245
|
+
|
|
246
|
+
## License
|
|
247
|
+
|
|
248
|
+
[MIT](LICENSE)
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "codex-auto-approve",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=22"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc -p tsconfig.json",
|
|
10
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
11
|
+
"test": "node scripts/test.mjs",
|
|
12
|
+
"prepack": "npm run build",
|
|
13
|
+
"validate:release": "node scripts/validate-release-version.mjs"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^22.18.0",
|
|
17
|
+
"typescript": "~5.9.3"
|
|
18
|
+
},
|
|
19
|
+
"description": "Explicitly toggle automatic approval for supported Codex permission requests.",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/fuliucansheng/codex-auto-approve.git"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/fuliucansheng/codex-auto-approve#readme",
|
|
26
|
+
"keywords": [
|
|
27
|
+
"codex",
|
|
28
|
+
"plugin",
|
|
29
|
+
"permissions",
|
|
30
|
+
"automation"
|
|
31
|
+
],
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public",
|
|
34
|
+
"registry": "https://registry.npmjs.org/"
|
|
35
|
+
},
|
|
36
|
+
"bin": {
|
|
37
|
+
"codex-auto-approve": "plugins/auto-approve/scripts/auto_approve.js"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"LICENSE",
|
|
41
|
+
"README.md",
|
|
42
|
+
".agents/plugins/marketplace.json",
|
|
43
|
+
"plugins/auto-approve/README.md",
|
|
44
|
+
"plugins/auto-approve/package.json",
|
|
45
|
+
"plugins/auto-approve/.codex-plugin/plugin.json",
|
|
46
|
+
"plugins/auto-approve/hooks/hooks.json",
|
|
47
|
+
"plugins/auto-approve/skills/",
|
|
48
|
+
"plugins/auto-approve/scripts/auto_approve.js"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "auto-approve",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Explicitly toggle automatic approval for supported Codex permission requests.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "fuliucansheng",
|
|
7
|
+
"email": "fuliucansheng@gmail.com",
|
|
8
|
+
"url": "https://github.com/fuliucansheng"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/fuliucansheng/codex-auto-approve#readme",
|
|
11
|
+
"repository": "https://github.com/fuliucansheng/codex-auto-approve",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"codex",
|
|
15
|
+
"plugin",
|
|
16
|
+
"permissions",
|
|
17
|
+
"automation"
|
|
18
|
+
],
|
|
19
|
+
"skills": "./skills/",
|
|
20
|
+
"interface": {
|
|
21
|
+
"displayName": "Auto Approve",
|
|
22
|
+
"shortDescription": "Toggle automatic approvals from Codex.",
|
|
23
|
+
"longDescription": "Auto Approve allows supported Codex PermissionRequest events only while its explicit local switch is enabled. Control it inside Codex with the bundled $auto-approve skill.",
|
|
24
|
+
"developerName": "fuliucansheng",
|
|
25
|
+
"category": "Productivity",
|
|
26
|
+
"capabilities": [
|
|
27
|
+
"Approve"
|
|
28
|
+
],
|
|
29
|
+
"websiteURL": "https://github.com/fuliucansheng/codex-auto-approve",
|
|
30
|
+
"defaultPrompt": [
|
|
31
|
+
"Use $auto-approve status to show the current automatic approval status."
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Auto Approve
|
|
2
|
+
|
|
3
|
+
Auto Approve is a Codex plugin that automatically allows supported permission
|
|
4
|
+
requests only while you have explicitly enabled it. It is disabled by default.
|
|
5
|
+
|
|
6
|
+
## Requirements
|
|
7
|
+
|
|
8
|
+
- A recent version of Codex with plugin and hook support
|
|
9
|
+
- Node.js 22 or newer, with `node` on `PATH`
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
codex plugin marketplace add fuliucansheng/codex-auto-approve
|
|
15
|
+
codex plugin add auto-approve@codex-auto-approve
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The plugin includes the prebuilt `scripts/auto_approve.js` controller and has
|
|
19
|
+
no production dependencies. Marketplace installations run directly with
|
|
20
|
+
Node.js; no `npm install`, build step, `tsx`, or `ts-node` is needed. Keep the
|
|
21
|
+
entire plugin directory, including its local `package.json`, so it also works
|
|
22
|
+
under a parent package configured as an ES module.
|
|
23
|
+
|
|
24
|
+
Start a new Codex conversation after installation and inspect the bundled
|
|
25
|
+
`PermissionRequest` hook with `/hooks`.
|
|
26
|
+
|
|
27
|
+
## Use inside Codex
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
$auto-approve status
|
|
31
|
+
$auto-approve enable
|
|
32
|
+
$auto-approve disable
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Type `$` to select the skill, or select it through `/skills`. This is a plugin
|
|
36
|
+
skill rather than a new built-in slash command.
|
|
37
|
+
|
|
38
|
+
> [!WARNING]
|
|
39
|
+
> While enabled, all supported permission requests are allowed without the
|
|
40
|
+
> normal confirmation prompt. Only enable it in an environment you trust.
|
|
41
|
+
|
|
42
|
+
The hook covers permission requests exposed to Codex lifecycle hooks,
|
|
43
|
+
including supported shell, file-edit, and MCP tool requests. Some Computer Use
|
|
44
|
+
and app-level confirmations cannot be auto-approved by this plugin.
|
|
45
|
+
|
|
46
|
+
The switch remains at `~/.local/state/codex-auto-approve/enabled.json` and is
|
|
47
|
+
compatible with existing state files. Only the boolean `true` in an object's
|
|
48
|
+
`enabled` field enables approval. Missing, unreadable, malformed, or non-object
|
|
49
|
+
state fails closed; malformed or non-object hook input silently does nothing.
|
|
50
|
+
Only explicit enable writes state, and disable is safe to repeat. On POSIX
|
|
51
|
+
filesystems, new state directories use `0700` and the file uses `0600`.
|
|
52
|
+
|
|
53
|
+
`status` exits 0 when enabled and 1 when disabled. Successful enable/disable
|
|
54
|
+
actions exit 0, filesystem write failures exit 1, and invalid arguments exit 2.
|
|
55
|
+
|
|
56
|
+
## Development
|
|
57
|
+
|
|
58
|
+
In a repository clone, edit `src/auto_approve.ts`, then run `npm ci`,
|
|
59
|
+
`npm run build`, `npm run typecheck`, and `npm test` from the repository root.
|
|
60
|
+
Include the regenerated `plugins/auto-approve/scripts/auto_approve.js` with
|
|
61
|
+
source changes. Tests execute the compiled controller with isolated temporary
|
|
62
|
+
`HOME` and `USERPROFILE` directories. CI checks Node.js 22/24 on Linux/macOS
|
|
63
|
+
and verifies that the checked-in JavaScript matches the TypeScript source.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Allow permission requests only while the user-controlled switch is enabled.",
|
|
3
|
+
"hooks": {
|
|
4
|
+
"PermissionRequest": [
|
|
5
|
+
{
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "node \"${PLUGIN_ROOT}/scripts/auto_approve.js\" hook",
|
|
10
|
+
"timeout": 5
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
// Source: src/auto_approve.ts. Rebuild with npm run build; do not edit the JS.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_os_1 = require("node:os");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const node_util_1 = require("node:util");
|
|
9
|
+
const stateDirectory = (0, node_path_1.join)((0, node_os_1.homedir)(), '.local', 'state', 'codex-auto-approve');
|
|
10
|
+
const stateFile = (0, node_path_1.join)(stateDirectory, 'enabled.json');
|
|
11
|
+
// Reject invalid UTF-8 and preserve a BOM so JSON.parse rejects it too.
|
|
12
|
+
const decoder = new node_util_1.TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
|
|
13
|
+
function readObject(source) {
|
|
14
|
+
try {
|
|
15
|
+
const payload = JSON.parse(decoder.decode((0, node_fs_1.readFileSync)(source)));
|
|
16
|
+
if (typeof payload === 'object' && payload !== null && !Array.isArray(payload)) {
|
|
17
|
+
return payload;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// Missing, unreadable, and malformed input must never authorize anything.
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
function isEnabled() {
|
|
26
|
+
return readObject(stateFile)?.enabled === true;
|
|
27
|
+
}
|
|
28
|
+
function enable() {
|
|
29
|
+
(0, node_fs_1.mkdirSync)(stateDirectory, { recursive: true, mode: 0o700 });
|
|
30
|
+
(0, node_fs_1.writeFileSync)(stateFile, '{"enabled":true}\n', { mode: 0o600 });
|
|
31
|
+
(0, node_fs_1.chmodSync)(stateFile, 0o600);
|
|
32
|
+
console.log('Auto Approve: enabled (all supported permission requests are allowed).');
|
|
33
|
+
}
|
|
34
|
+
function disable() {
|
|
35
|
+
try {
|
|
36
|
+
(0, node_fs_1.unlinkSync)(stateFile);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT')) {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
console.log('Auto Approve: disabled (Codex will request approval normally).');
|
|
44
|
+
}
|
|
45
|
+
function status() {
|
|
46
|
+
const enabled = isEnabled();
|
|
47
|
+
console.log(`Auto Approve: ${enabled ? 'enabled' : 'disabled'}`);
|
|
48
|
+
return enabled ? 0 : 1;
|
|
49
|
+
}
|
|
50
|
+
function runHook() {
|
|
51
|
+
const event = readObject(0);
|
|
52
|
+
if (event?.hook_event_name !== 'PermissionRequest' || !isEnabled()) {
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
(0, node_fs_1.writeFileSync)(1, JSON.stringify({
|
|
57
|
+
hookSpecificOutput: {
|
|
58
|
+
hookEventName: 'PermissionRequest',
|
|
59
|
+
decision: { behavior: 'allow' },
|
|
60
|
+
},
|
|
61
|
+
}) + '\n');
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// A closed or unwritable output stream must also leave the hook silent.
|
|
65
|
+
}
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
function usage() {
|
|
69
|
+
console.error('Usage: auto_approve.js {enable|disable|status}');
|
|
70
|
+
return 2;
|
|
71
|
+
}
|
|
72
|
+
function main() {
|
|
73
|
+
if (process.argv.length !== 3)
|
|
74
|
+
return usage();
|
|
75
|
+
const command = process.argv[2];
|
|
76
|
+
try {
|
|
77
|
+
switch (command) {
|
|
78
|
+
case 'enable':
|
|
79
|
+
enable();
|
|
80
|
+
return 0;
|
|
81
|
+
case 'disable':
|
|
82
|
+
disable();
|
|
83
|
+
return 0;
|
|
84
|
+
case 'status':
|
|
85
|
+
return status();
|
|
86
|
+
case 'hook':
|
|
87
|
+
return runHook();
|
|
88
|
+
default:
|
|
89
|
+
return usage();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
94
|
+
console.error(`Auto Approve: ${command} failed: ${message}`);
|
|
95
|
+
return 1;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
process.exitCode = main();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: auto-approve
|
|
3
|
+
description: Control the installed Auto Approve plugin by enabling, disabling, or inspecting automatic approval of supported Codex permission requests. Use when the user explicitly invokes $auto-approve with enable, disable, or status.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Auto Approve Control
|
|
7
|
+
|
|
8
|
+
Control the plugin's persistent local switch with its bundled controller.
|
|
9
|
+
Requires Node.js 22 or newer on `PATH`. The JavaScript controller is prebuilt;
|
|
10
|
+
no dependency installation or build step is needed.
|
|
11
|
+
|
|
12
|
+
1. Read the requested action immediately following the skill mention. Accept only `enable`, `disable`, or `status`. If no action is present, use `status`.
|
|
13
|
+
2. Resolve `../../scripts/auto_approve.js` from the directory containing this `SKILL.md`; do not resolve it from the session working directory.
|
|
14
|
+
3. Run `node "<resolved-controller-path>" <action>` once.
|
|
15
|
+
4. Report the controller's output exactly and briefly explain the resulting state.
|
|
16
|
+
|
|
17
|
+
Treat an explicit `$auto-approve enable` invocation as authorization to enable the switch without an additional confirmation. Never infer `enable` from vague wording, never substitute it for `status`, and never edit the state file directly. If the action is unsupported, do not run the controller; show the accepted syntax instead.
|