Skip to content

Commit d302f14

Browse files
committed
chore: codex
1 parent 9c0bb50 commit d302f14

File tree

9 files changed

+130
-89
lines changed

9 files changed

+130
-89
lines changed

conf/claude-local-marketplace/skills/recent-history/SKILL.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ description: "This skill should be used when retrieving recent chat history, in
77

88
## Step 1: Prepare the history file
99

10-
This command should run in current project root dir.
10+
If there is <last-session> in your system prompt, just use it, then go to Step 2.
11+
Otherwise, run this command which should run in current project root dir.
1112

1213
```bash
1314
bunx repomix --header-text "file path parent dir: .claude/sessions/" --quiet --no-dot-ignore --no-gitignore --no-git-sort-by-changes --no-file-summary --no-directory-structure .claude/sessions/ -o .claude/sessions/history.xml >/dev/null 2>&1 && echo "history exist" || echo "no history file"
@@ -17,6 +18,8 @@ If the command output is "no history file", just quit, because there are no sess
1718

1819
## Step 2: Query history (sessions are ordered old→new in the file)
1920

21+
If user intended meant for last session and our <last-session> context is sufficient, just focus on <last-session>
22+
2023
### Quick Overview: List all sessions with line numbers
2124

2225
```bash

conf/llm/docs/coding-rules.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
- **Reuse:** Prefer existing utilities/components via explicit interfaces—do not break abstraction boundaries.
2727
- **Precedent:** Follow prior implementations for new features unless told otherwise.
2828
- **Structured Plan:** For each step, specify target files and exact required changes.
29-
- **Boundaries:** Keep business logic isolated from UI. Place demo/mock code at the top layer. Don't modify production code just for debugging.
29+
- **Boundaries:** Keep business logic isolated from UI. Place demo/mock code at the top layer. Don't modify production code just for debugging.
30+
- **Separation of concerns:** Bad: Use other layer's implement details in current layer that current layer should not know or care about. Good: current layer use it's own knowledge based implement details, dependant layers can depends on that to derive implement details.
3031
- **Abstraction:** Only use explicitly exposed abstractions from the immediate downstream layer—avoid private APIs, even for reuse.
3132
- **Fail Fast:** Let bugs surface; do not mask errors with `try-catch` or optional chaining.
3233
- **Comment Intent:** Use `FIXME`, `TODO`, and `NOTE` to flag issues, explain logic, document changes, and note trade-offs.
@@ -35,6 +36,7 @@
3536
- **Avoid introduce implement complexity:** No backward compatibility layers, feature flags, or toggles unless explicitly requested.
3637
- **No external data based design:** Avoid designs relying on external data, for example, use external api data to determine program logic or control flow, it will broke when external data changes.
3738
- **Avoid outdated dependency:** Use the latest stable version of dependencies unless there is a specific reason to use an older version. This is important to avoid big refactor later.
39+
- **No Weak Test:**: Disallow tests that are meaningless to implemented code, or that do not effectively validate the intended functionality. Bad: Test to verify "id should not start with number", the test simply construct a string without number and assert with that, does not involve any implemented code.
3840

3941
When editing code: (1) state your assumptions, (2) create/run minimal tests if possible, (3) generate diffs ready for review, (4) follow repository style.
4042

nix/hm/ai/claude/assets/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# More instructions
44

55
- At the start, list a high-level checklist (3–7 bullets) of conceptual steps—omit implementation details, don't confuse this with Todo tools, you can use the checklist method when working on a todo item.
6-
- Use `recent-history` Skill if you need more context of what user are talking about at the start. you can delegate this to general subagent to summarize recent conversation.
6+
- Read <last-session> or Use `recent-history` Skill if you need more context of what user are talking about at the start. you can delegate this to general subagent to summarize recent conversation.
77
- Do not use the Plan tools, just plan without the Plan tools, propsose your plan to user directly and wait for confirmation.
88
- **Critical**: When construct "Prompt" for subagents or Task tool, explicitly give instructions about subagent role and limitation on what can not do based on their definition, for example, "do not run install command and edit files", "Only search for file and code snippet location, do not run debug commands" when using the Explore subagent.
99

nix/hm/ai/claude/hooks/session_summary.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ def main():
7979
sys.exit(0)
8080

8181
# Return as additional context for new session
82-
context = f"""<history-summary>
82+
context = f"""<last-session>
8383
84-
{summary}</history-summary>"""
84+
{summary}</last-session>"""
8585

8686
# Create a visible system message
8787
system_msg = f"History context loaded"

nix/hm/ai/codex/default.nix

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
}:
77
let
88
proxyConfig = import ../../../lib/proxy.nix { inherit lib pkgs; };
9+
mcp = import ../../../modules/ai/mcp.nix { inherit pkgs lib config; };
910
codex_home = "${config.xdg.configHome}/codex";
11+
codexMcpToml = builtins.readFile (
12+
(pkgs.formats.toml { }).generate "codex-mcp.toml" { mcp_servers = mcp.clients.codex; }
13+
);
1014
# codex_config_file = "${codex_home}/config.toml";
1115
# like commands in other agents
1216
# prompts_dir = "${codex_home}/prompts";
@@ -30,15 +34,34 @@ in
3034
source = ./instructions;
3135
recursive = true;
3236
};
37+
"codex/skills" = {
38+
source = ../../../../conf/claude-local-marketplace/skills;
39+
recursive = true;
40+
};
3341
# toml
34-
"codex/config.toml".text = ''
35-
model = "gpt-5"
36-
model_provider = "litellm"
42+
"codex/config-generated.toml".text = ''
43+
model = "gpt-5.2-medium"
44+
model_provider = "packy"
3745
approval_policy = "untrusted"
38-
model_reasoning_effort = "low"
46+
model_reasoning_effort = "medium"
3947
# the AGENTS.md contains instructions for using codex mcp, do not use it
4048
# experimental_instructions_file = "${config.xdg.configHome}/AGENTS.md"
41-
sandbox_mode = "read-only"
49+
project_doc_fallback_filenames = ["CLAUDE.md"]
50+
sandbox_mode = "workspace-write"
51+
52+
[features]
53+
tui2 = true
54+
skills = true
55+
unified_exec = true
56+
apply_patch_freeform = true
57+
view_image_tool = false
58+
ghost_commit = false
59+
60+
[model_providers.packy]
61+
name = "packy"
62+
wire_api = "responses"
63+
base_url = "https://www.packyapi.com/v1"
64+
env_key = "PACKYCODE_CODEX_API_KEY"
4265
4366
[model_providers.litellm]
4467
name = "litellm"
@@ -104,31 +127,17 @@ in
104127
hide_agent_reasoning = true
105128
model_verbosity = "low"
106129
107-
[profiles.sage_slow]
108-
model = "glm-4.6"
109-
model_provider = "zhipuai-coding-plan"
110-
sandbox_mode = "read-only"
111-
experimental_instructions_file = "${codex_home}/instructions/sage-role.md"
112-
approval_policy = "never"
113-
model_reasoning_effort = "medium"
114-
model_reasoning_summary = "concise"
115-
hide_agent_reasoning = true
116-
model_verbosity = "low"
117-
118-
[profiles.sage]
119-
model = "kimi-k2-turbo-preview"
120-
model_provider = "moonshot"
121-
sandbox_mode = "read-only"
122-
experimental_instructions_file = "${codex_home}/instructions/sage-role.md"
123-
approval_policy = "never"
124-
model_reasoning_effort = "low"
125-
model_reasoning_summary = "concise"
126-
hide_agent_reasoning = true
127-
model_verbosity = "medium"
128-
129130
[tui]
130131
# notifications = [ "agent-turn-complete", "approval-requested" ]
131132
notifications = true
133+
animations = false
134+
scroll_events_per_tick = 3
135+
scroll_wheel_lines = 3
136+
scroll_mode = "auto"
137+
138+
[sandbox_workspace_write]
139+
network_access = true
140+
writable_roots = ["${config.home.homeDirectory}/workspace/work"]
132141
133142
[shell_environment_policy]
134143
inherit = "core"
@@ -140,26 +149,18 @@ in
140149
set = { HTTP_PROXY = "${proxyConfig.proxies.http}", HTTPS_PROXY = "${proxyConfig.proxies.https}" }
141150
142151
## MCP
143-
[mcp_servers.chromedev]
144-
command = "bunx"
145-
args = ["chrome-devtools-mcp@latest", "--browser-url=http://127.0.0.1:9222"]
146-
147-
# [mcp_servers.context7]
148-
# command = "bunx"
149-
# args = ["@upstash/context7-mcp"]
150-
151-
# [mcp_servers.mermaid]
152-
# command = "bunx"
153-
# args = ["@devstefancho/mermaid-mcp"]
154-
155-
# [mcp_servers.sequentialthinking]
156-
# command = "bunx"
157-
# args = ["@modelcontextprotocol/server-sequential-thinking"]
158-
159-
# [mcp_servers.github]
160-
# command = "github-mcp-server"
161-
# args = ["stdio", "--dynamic-toolsets"]
162-
# env = { GITHUB_PERSONAL_ACCESS_TOKEN = "${pkgs.nix-priv.keys.github.accessToken}" }
152+
${codexMcpToml}
153+
'';
154+
};
155+
156+
home.activation = {
157+
setupCodexConfig = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
158+
CODEX_HOME="${codex_home}"
159+
160+
cp -f ${codex_home}/config-generated.toml "${codex_home}/config.toml"
161+
chmod u+w "${codex_home}/config.toml"
162+
163+
cat ${../../../../conf/llm/docs/coding-rules.md} > ${codex_home}/AGENTS.md
163164
'';
164165
};
165166
}

nix/hm/ai/codex/instructions/sage-role.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

nix/hm/ai/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
./legacy.nix
1111
./claude
1212
./codex
13-
./forge
13+
# ./forge
1414
# ./windsurf
1515
# ./cline
1616
./droid

nix/lib/mcp-clients.nix

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,67 @@
1010
...
1111
}:
1212
{
13+
# codex (openai/codex) config format:
14+
# - STDIO servers: { command, args?, env?, env_vars?, cwd?, ... }
15+
# - Streamable HTTP servers: { url, bearer_token_env_var?, http_headers?, env_http_headers?, ... }
16+
codex =
17+
serverAttrs:
18+
let
19+
passthru =
20+
lib.optionalAttrs (serverAttrs ? enabled) { inherit (serverAttrs) enabled; }
21+
// lib.optionalAttrs (serverAttrs ? startup_timeout_sec) {
22+
inherit (serverAttrs) startup_timeout_sec;
23+
}
24+
// lib.optionalAttrs (serverAttrs ? tool_timeout_sec) {
25+
inherit (serverAttrs) tool_timeout_sec;
26+
}
27+
// lib.optionalAttrs (serverAttrs ? enabled_tools) { inherit (serverAttrs) enabled_tools; }
28+
// lib.optionalAttrs (serverAttrs ? disabled_tools) { inherit (serverAttrs) disabled_tools; }
29+
// lib.optionalAttrs (serverAttrs ? cwd) { inherit (serverAttrs) cwd; };
30+
31+
mkStdio =
32+
base:
33+
base
34+
// lib.optionalAttrs (serverAttrs ? environment && serverAttrs.environment != { }) {
35+
env = serverAttrs.environment;
36+
}
37+
// lib.optionalAttrs (serverAttrs ? env_vars && serverAttrs.env_vars != [ ]) {
38+
inherit (serverAttrs) env_vars;
39+
}
40+
// passthru;
41+
in
42+
if serverAttrs.type == "local" then
43+
mkStdio {
44+
inherit (serverAttrs) command;
45+
args = serverAttrs.args or [ ];
46+
}
47+
else if serverAttrs.type == "sse" then
48+
mkStdio {
49+
command = "bunx";
50+
args = [
51+
"mcp-remote"
52+
serverAttrs.url
53+
"--allow-http"
54+
"--header"
55+
"Authorization: ${serverAttrs.headers.Authorization}"
56+
];
57+
}
58+
else
59+
{
60+
inherit (serverAttrs) url;
61+
}
62+
// lib.optionalAttrs (serverAttrs ? bearer_token_env_var) {
63+
inherit (serverAttrs) bearer_token_env_var;
64+
}
65+
// lib.optionalAttrs (serverAttrs ? http_headers) { inherit (serverAttrs) http_headers; }
66+
// lib.optionalAttrs (serverAttrs ? env_http_headers) {
67+
inherit (serverAttrs) env_http_headers;
68+
}
69+
// lib.optionalAttrs (serverAttrs ? headers && serverAttrs.headers != { }) {
70+
http_headers = serverAttrs.headers;
71+
}
72+
// passthru;
73+
1374
opencode =
1475
let
1576
typeMap = {

nix/modules/ai/mcp.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ rec {
181181
};
182182

183183
clients = {
184+
codex = mapWithClientMk clientMk.codex (
185+
pick mcpServers [
186+
"chromedev"
187+
"context7"
188+
"mermaid"
189+
"github"
190+
"exa"
191+
"mastergo"
192+
]
193+
);
184194
opencode = mapWithClientMk clientMk.opencode (
185195
pick mcpServers [
186196
"kg"

0 commit comments

Comments
 (0)