Skip to content

Commit d50d8a1

Browse files
authored
Wrap Codex to disable the trust prompt (#86)
1 parent 15b709b commit d50d8a1

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

bin/codex.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import json
2+
import os
3+
import sys
4+
from pathlib import Path
5+
6+
7+
def main() -> None:
8+
project = json.dumps(str(Path.cwd()))
9+
# https://github.com/openai/codex/issues/14599#issuecomment-4091089485
10+
config = f'projects={{{project}={{trust_level="untrusted"}}}}'
11+
os.execvp("codex", ["codex", "-c", config, *sys.argv[1:]])
12+
13+
14+
if __name__ == "__main__":
15+
main()

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

util.nix

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ rec {
1717
packages = [
1818
pkgs.btop
1919
pkgs.cloc
20-
pkgs.codex
2120
pkgs.gh
2221
pkgs.git
2322
pkgs.nix-index
@@ -29,6 +28,14 @@ rec {
2928
name = "samestep";
3029
paths = [
3130
(pkgs.writeTextDir "template.nix" (builtins.readFile ./template.nix))
31+
(pkgs.writers.writePython3Bin "codex" {
32+
makeWrapperArgs = [
33+
"--prefix"
34+
"PATH"
35+
":"
36+
(lib.makeBinPath [ pkgs.codex ])
37+
];
38+
} ./bin/codex.py)
3239
(pkgs.writers.writePython3Bin "flake" { } ./bin/flake.py)
3340
(pkgs.writers.writePython3Bin "ghcode" { } ./bin/ghcode.py)
3441
(pkgs.writers.writePython3Bin "scratch" { } ./bin/scratch.py)
@@ -118,9 +125,5 @@ rec {
118125
};
119126

120127
assertions = [
121-
{
122-
assertion = lib.versionOlder pkgs.codex.version "0.113.0";
123-
message = "Codex 0.113.0 introduced unwanted prompts: https://github.com/openai/codex/issues/14345";
124-
}
125128
];
126129
}

0 commit comments

Comments
 (0)