codex-auto-approve 0.1.1 → 0.2.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 CHANGED
@@ -1,66 +1,47 @@
1
1
  # Codex Auto Approve
2
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.
3
+ A Codex plugin that automatically allows supported permission requests when
4
+ explicitly enabled. The switch is persistent and **disabled by default**.
10
5
 
11
6
  ## Requirements
12
7
 
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
8
+ - **Node.js 22 or newer**, with `node` on `PATH`.
9
+ - A recent **Codex CLI with plugin and hook support**, with `codex` on `PATH`.
10
+ - `npm` and `npx` on `PATH` for the npm commands below.
17
11
 
18
- Add this repository as a Codex plugin marketplace, then install the plugin:
12
+ ## Install
19
13
 
20
14
  ```sh
21
- codex plugin marketplace add fuliucansheng/codex-auto-approve
22
- codex plugin add auto-approve@codex-auto-approve
15
+ npx codex-auto-approve@latest install
23
16
  ```
24
17
 
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.
18
+ The one-command installer requires **version 0.2.0 or newer**. For older
19
+ versions, use the manual alternative below. Installing the npm package alone
20
+ does not register the plugin.
30
21
 
31
- Start a new Codex conversation after installation so the skill and hook are
32
- loaded. You can inspect the installed hook with `/hooks`.
22
+ ### Manual alternative
33
23
 
34
- ## npm CLI
35
-
36
- Once the package is published to npm, install the command globally:
24
+ These are the same two commands the installer runs; they require no npm
25
+ installation or build step:
37
26
 
38
27
  ```sh
39
- npm install -g codex-auto-approve
40
- codex-auto-approve status
41
- codex-auto-approve enable
42
- codex-auto-approve disable
28
+ codex plugin marketplace add fuliucansheng/codex-auto-approve
29
+ codex plugin add auto-approve@codex-auto-approve
43
30
  ```
44
31
 
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
- ```
32
+ Both methods register a durable GitHub marketplace source, fetched from this
33
+ repository's **`main` branch**, rather than a temporary npx cache path. The npm
34
+ version selects the installer only: even a pinned npm version does not pin the
35
+ plugin version or install the plugin from the npm tarball.
52
36
 
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.
37
+ Installation **does not enable automatic approval** or change the existing
38
+ switch: a missing switch stays disabled, and an enabled switch stays enabled.
39
+ Restart Codex and start a **new conversation**, then inspect the hook with
40
+ `/hooks`.
60
41
 
61
42
  ## Use
62
43
 
63
- Invoke the bundled skill in Codex:
44
+ In Codex, select the skill by typing `$` or through `/skills`:
64
45
 
65
46
  ```text
66
47
  $auto-approve status
@@ -68,181 +49,59 @@ $auto-approve enable
68
49
  $auto-approve disable
69
50
  ```
70
51
 
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.
52
+ `status` shows the current switch, `enable` allows all supported permission
53
+ requests automatically, and `disable` restores the normal approval flow.
54
+ `$auto-approve` is a plugin skill, not a built-in slash command.
73
55
 
74
- The actions are:
56
+ You can also control the same switch from a terminal using the npm CLI:
75
57
 
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.
58
+ ```sh
59
+ npx codex-auto-approve@latest status
60
+ npx codex-auto-approve@latest enable
61
+ npx codex-auto-approve@latest disable
62
+ ```
84
63
 
85
64
  ## Update
86
65
 
66
+ Refresh the marketplace and reinstall the plugin:
67
+
87
68
  ```sh
88
69
  codex plugin marketplace upgrade codex-auto-approve
89
70
  codex plugin add auto-approve@codex-auto-approve
90
71
  ```
91
72
 
92
- Start a new Codex conversation after updating.
73
+ Start a new Codex conversation after updating. Updating the npm CLI alone does
74
+ not update the installed plugin.
93
75
 
94
76
  ## Uninstall
95
77
 
96
- Disable Auto Approve first, then remove the plugin and marketplace:
78
+ Disable automatic approval in Codex first:
97
79
 
98
80
  ```text
99
81
  $auto-approve disable
100
82
  ```
101
83
 
84
+ Then remove the plugin and marketplace in your terminal:
85
+
102
86
  ```sh
103
87
  codex plugin remove auto-approve@codex-auto-approve
104
88
  codex plugin marketplace remove codex-auto-approve
105
89
  ```
106
90
 
107
- ## How it works
91
+ ## Safety
108
92
 
109
- The controller stores the enabled state at:
93
+ While enabled, all supported permission requests are allowed without the normal
94
+ confirmation prompt. Review the plugin, enable it only in an environment you
95
+ trust, and disable it when finished.
110
96
 
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.
97
+ The switch is stored at `~/.local/state/codex-auto-approve/enabled.json`.
98
+ Missing, unreadable, or invalid state leaves automatic approval disabled.
99
+ The hook covers supported shell, file-edit, and MCP permission requests; some
100
+ Computer Use and app-level confirmations still require user approval. Managed
101
+ workspace policy can also limit what the plugin may approve.
245
102
 
246
103
  ## License
247
104
 
248
105
  [MIT](LICENSE)
106
+
107
+ [Contributing](https://github.com/fuliucansheng/codex-auto-approve/blob/main/docs/MAINTAINING.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-auto-approve",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-approve",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Explicitly toggle automatic approval for supported Codex permission requests.",
5
5
  "author": {
6
6
  "name": "fuliucansheng",
@@ -1,30 +1,40 @@
1
1
  # Auto Approve
2
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.
3
+ A Codex plugin that automatically allows supported permission requests when
4
+ explicitly enabled. The switch is persistent and **disabled by default**.
5
5
 
6
- ## Requirements
6
+ ## Install
7
7
 
8
- - A recent version of Codex with plugin and hook support
9
- - Node.js 22 or newer, with `node` on `PATH`
8
+ Requires **Node.js 22 or newer** and a recent **Codex CLI with plugin and hook
9
+ support**, with `node` and `codex` on `PATH`. For one-command installation,
10
+ `npm` and `npx` must also be on `PATH`:
10
11
 
11
- ## Install
12
+ ```sh
13
+ npx codex-auto-approve@latest install
14
+ ```
15
+
16
+ The installer requires **version 0.2.0 or newer**. For older versions, use
17
+ these manual commands:
12
18
 
13
19
  ```sh
14
20
  codex plugin marketplace add fuliucansheng/codex-auto-approve
15
21
  codex plugin add auto-approve@codex-auto-approve
16
22
  ```
17
23
 
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.
24
+ The manual alternative needs no npm installation or build step. Installing the
25
+ npm package alone does not register the plugin. Both methods use the durable
26
+ GitHub marketplace on **`main`**, not an npx cache path. The npm version selects
27
+ only the installer; pinning it does not pin the plugin version or install the
28
+ plugin from the npm tarball.
29
+
30
+ Installation **does not enable automatic approval** or change the existing
31
+ switch: a missing switch stays disabled, and an enabled switch stays enabled.
32
+ Restart Codex and start a **new conversation**, then inspect the hook with
33
+ `/hooks`.
23
34
 
24
- Start a new Codex conversation after installation and inspect the bundled
25
- `PermissionRequest` hook with `/hooks`.
35
+ ## Use
26
36
 
27
- ## Use inside Codex
37
+ In Codex, select the skill by typing `$` or through `/skills`:
28
38
 
29
39
  ```text
30
40
  $auto-approve status
@@ -32,32 +42,37 @@ $auto-approve enable
32
42
  $auto-approve disable
33
43
  ```
34
44
 
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.
45
+ `status` shows the current switch, `enable` allows supported requests
46
+ automatically, and `disable` restores the normal approval flow. This is a
47
+ plugin skill, not a built-in slash command. For terminal controls, see the
48
+ [root README](https://github.com/fuliucansheng/codex-auto-approve#use).
37
49
 
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.
50
+ ## Update and uninstall
41
51
 
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.
52
+ To update, run these commands and start a new Codex conversation:
53
+
54
+ ```sh
55
+ codex plugin marketplace upgrade codex-auto-approve
56
+ codex plugin add auto-approve@codex-auto-approve
57
+ ```
58
+
59
+ Updating the npm CLI alone does not update the installed plugin.
60
+
61
+ To uninstall, run `$auto-approve disable` in Codex first, then in your terminal:
62
+
63
+ ```sh
64
+ codex plugin remove auto-approve@codex-auto-approve
65
+ codex plugin marketplace remove codex-auto-approve
66
+ ```
45
67
 
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`.
68
+ ## Safety
52
69
 
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.
70
+ While enabled, all supported permission requests are allowed without the normal
71
+ confirmation prompt. Enable only in an environment you trust and disable when
72
+ finished. Some Computer Use and app-level confirmations still require user
73
+ approval, and managed workspace policy may limit what the plugin can approve.
55
74
 
56
- ## Development
75
+ The switch is stored at `~/.local/state/codex-auto-approve/enabled.json`.
76
+ Missing, unreadable, or invalid state leaves automatic approval disabled.
57
77
 
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.
78
+ [Contributing](https://github.com/fuliucansheng/codex-auto-approve/blob/main/docs/MAINTAINING.md)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-plugin-auto-approve",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "private": true,
5
5
  "type": "commonjs",
6
6
  "engines": {
@@ -2,6 +2,7 @@
2
2
  "use strict";
3
3
  // Source: src/auto_approve.ts. Rebuild with npm run build; do not edit the JS.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
+ const node_child_process_1 = require("node:child_process");
5
6
  const node_fs_1 = require("node:fs");
6
7
  const node_os_1 = require("node:os");
7
8
  const node_path_1 = require("node:path");
@@ -47,6 +48,33 @@ function status() {
47
48
  console.log(`Auto Approve: ${enabled ? 'enabled' : 'disabled'}`);
48
49
  return enabled ? 0 : 1;
49
50
  }
51
+ function install() {
52
+ // Keep the marketplace source durable; an npx cache path can disappear.
53
+ const commands = [
54
+ ['plugin', 'marketplace', 'add', 'fuliucansheng/codex-auto-approve'],
55
+ ['plugin', 'add', 'auto-approve@codex-auto-approve'],
56
+ ];
57
+ for (const args of commands) {
58
+ const result = (0, node_child_process_1.spawnSync)('codex', args, { stdio: 'inherit' });
59
+ if (result.error) {
60
+ if ('code' in result.error && result.error.code === 'ENOENT') {
61
+ throw new Error('codex executable not found. Install the Codex CLI with plugin support and ensure codex is on PATH, then retry.');
62
+ }
63
+ throw result.error;
64
+ }
65
+ if (result.signal) {
66
+ throw new Error(`codex ${args.join(' ')} terminated by signal ${result.signal}`);
67
+ }
68
+ if (result.status === null) {
69
+ throw new Error(`codex ${args.join(' ')} exited without a status`);
70
+ }
71
+ if (result.status !== 0)
72
+ return result.status;
73
+ }
74
+ console.log('Auto Approve: plugin installed. Automatic approval state is unchanged.');
75
+ console.log('Restart Codex and start a new conversation to load the plugin.');
76
+ return 0;
77
+ }
50
78
  function runHook() {
51
79
  const event = readObject(0);
52
80
  if (event?.hook_event_name !== 'PermissionRequest' || !isEnabled()) {
@@ -66,7 +94,7 @@ function runHook() {
66
94
  return 0;
67
95
  }
68
96
  function usage() {
69
- console.error('Usage: auto_approve.js {enable|disable|status}');
97
+ console.error('Usage: codex-auto-approve {install|enable|disable|status}');
70
98
  return 2;
71
99
  }
72
100
  function main() {
@@ -75,6 +103,8 @@ function main() {
75
103
  const command = process.argv[2];
76
104
  try {
77
105
  switch (command) {
106
+ case 'install':
107
+ return install();
78
108
  case 'enable':
79
109
  enable();
80
110
  return 0;