Skip to content

Commit 381da15

Browse files
committed
feat(codex): install session-start hook
Add a Codex installer and doctor command that manage Lumen MCP registration, shared skills, the Codex hooks feature flag, and a user-level SessionStart hook for proactive index warmup. Keep the installer aligned with the upstream v0.0.40 launcher split by using scripts/run on POSIX and scripts/run.cmd on Windows, while still detecting legacy scripts/run.sh hook entries for cleanup.
1 parent e310ed0 commit 381da15

8 files changed

Lines changed: 2572 additions & 42 deletions

File tree

.codex/INSTALL.md

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Installing Lumen for Codex
22

33
Enable Lumen in Codex with native skill discovery plus a registered MCP
4-
server.
4+
server and Codex startup hooks.
55

66
## Prerequisites
77

@@ -16,56 +16,77 @@ server.
1616
git clone https://github.com/ory/lumen.git "$CODEX_HOME/lumen"
1717
```
1818

19-
2. Create the skills symlink:
19+
2. Run the Codex installer:
2020
```bash
21-
mkdir -p "$HOME/.agents/skills"
22-
ln -s "$CODEX_HOME/lumen/skills" "$HOME/.agents/skills/lumen"
21+
"$CODEX_HOME/lumen/scripts/run" codex install
2322
```
2423

25-
3. Register the MCP server:
26-
```bash
27-
codex mcp add lumen -- "$CODEX_HOME/lumen/scripts/run" stdio
28-
```
24+
3. Restart Codex.
2925

30-
4. Restart Codex.
26+
The installer enables Codex hooks in `config.toml`, registers the `lumen` MCP
27+
server, links or copies the shared Lumen skills into Codex's user skill
28+
directory, and installs a user-level Codex `SessionStart` hook. That hook runs
29+
on startup, resume, and clear events and reuses Lumen's background indexer to
30+
proactively warm the project index.
3131

3232
## Windows (PowerShell)
3333

3434
```powershell
3535
$codexHome = if ($env:CODEX_HOME) { $env:CODEX_HOME } else { Join-Path $env:USERPROFILE ".codex" }
3636
git clone https://github.com/ory/lumen.git "$codexHome\lumen"
37-
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.agents\skills" | Out-Null
38-
cmd /c mklink /J "$env:USERPROFILE\.agents\skills\lumen" "$codexHome\lumen\skills"
39-
codex mcp add lumen -- "$codexHome\lumen\scripts\run.cmd" stdio
37+
cmd /c "$codexHome\lumen\scripts\run.cmd" codex install
4038
```
4139

40+
Restart Codex after the installer completes.
41+
4242
## Migrating from the old repo-local plugin
4343

4444
If you previously used the repo-local Codex marketplace package:
4545

4646
1. Remove the old plugin from Codex's plugin UI.
47-
2. Register the MCP server with `codex mcp add` as above.
48-
3. Create the `~/.agents/skills/lumen` symlink.
49-
4. Restart Codex.
47+
2. Run `"$CODEX_HOME/lumen/scripts/run" codex install`.
48+
3. Restart Codex.
49+
50+
If you previously hand-edited Codex MCP or hook configuration, remove stale
51+
manual entries after confirming the installer-managed configuration works. The
52+
installer owns the user-level Codex MCP registration, skill link or copy, and
53+
`hooks.json` `SessionStart` entry for Lumen.
5054

5155
## Verify
5256

5357
```bash
58+
"${CODEX_HOME:-$HOME/.codex}/lumen/scripts/run" codex doctor
5459
codex mcp get lumen
55-
ls -la "$HOME/.agents/skills/lumen"
5660
```
5761

5862
## Updating
5963

6064
```bash
6165
cd "${CODEX_HOME:-$HOME/.codex}/lumen" && git pull
66+
"${CODEX_HOME:-$HOME/.codex}/lumen/scripts/run" codex install
6267
```
6368

6469
## Uninstalling
6570

6671
```bash
6772
codex mcp remove lumen
68-
rm "$HOME/.agents/skills/lumen"
73+
skills="$HOME/.agents/skills/lumen"
74+
if [ -L "$skills" ]; then
75+
target="$(readlink "$skills")"
76+
case "$target" in
77+
*/lumen/skills) rm "$skills" ;;
78+
*) echo "Refusing to remove non-Lumen skills link: $skills -> $target" >&2 ;;
79+
esac
80+
elif [ -f "$skills/.lumen-skills-source" ]; then
81+
rm -rf "$skills"
82+
else
83+
echo "No installer-managed Lumen skills path found at $skills" >&2
84+
fi
6985
```
7086

71-
Optionally delete the clone: `rm -rf "${CODEX_HOME:-$HOME/.codex}/lumen"`.
87+
Remove the Lumen `SessionStart` group from
88+
`${CODEX_HOME:-$HOME/.codex}/hooks.json` if you want to remove the startup hook
89+
as well. If you no longer use any Codex hooks, you can also remove
90+
`codex_hooks = true` from the `[features]` table in
91+
`${CODEX_HOME:-$HOME/.codex}/config.toml`. Optionally delete the clone:
92+
`rm -rf "${CODEX_HOME:-$HOME/.codex}/lumen"`.

README.md

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ _Claude Code asking about the
8181
[OpenCode](https://opencode.ai/)
8282

8383
**Note:** Installation differs by platform. Claude Code is installed from a
84-
plugin marketplace. Codex uses a local MCP server plus native skill discovery.
85-
OpenCode installs from npm. Cursor packaging is shipped in this repository and
86-
is ready for Cursor's plugin distribution workflow.
84+
plugin marketplace. Codex uses an installer that configures MCP, shared skills,
85+
and a user-level startup hook. OpenCode installs from npm. Cursor packaging is
86+
shipped in this repository and is ready for Cursor's plugin distribution
87+
workflow.
8788

8889
**Install:**
8990

@@ -113,29 +114,20 @@ skill or the Lumen `semantic_search` tool.
113114

114115
**Codex**
115116

116-
Quick install:
117+
Follow the Codex install guide:
117118

118-
```text
119-
Fetch and follow instructions from https://raw.githubusercontent.com/ory/lumen/refs/heads/main/.codex/INSTALL.md
120-
```
121-
122-
Manual install:
123-
124-
```bash
125-
CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
126-
git clone https://github.com/ory/lumen.git "$CODEX_HOME/lumen"
127-
mkdir -p "$HOME/.agents/skills"
128-
ln -s "$CODEX_HOME/lumen/skills" "$HOME/.agents/skills/lumen"
129-
codex mcp add lumen -- "$CODEX_HOME/lumen/scripts/run" stdio
130-
```
119+
[.codex/INSTALL.md](.codex/INSTALL.md)
131120

132-
Detailed docs: [.codex/INSTALL.md](.codex/INSTALL.md)
121+
The installer enables Codex hooks, registers the Lumen MCP server, links or
122+
copies the shared Lumen skills, and installs a user-level Codex `SessionStart`
123+
hook. The hook runs on startup, resume, and clear events and reuses Lumen's
124+
background indexer for proactive project index warmup.
133125

134126
Verify with:
135127

136128
```bash
129+
"${CODEX_HOME:-$HOME/.codex}/lumen/scripts/run" codex doctor
137130
codex mcp get lumen
138-
ls -la "$HOME/.agents/skills/lumen"
139131
```
140132

141133
**OpenCode**
@@ -161,7 +153,8 @@ opencode mcp list
161153
- **Claude Code** - update through Claude's plugin marketplace
162154
- **Cursor** - refresh or reinstall the bundled plugin through Cursor after
163155
updating this repository or the published package
164-
- **Codex** - `cd "${CODEX_HOME:-$HOME/.codex}/lumen" && git pull`
156+
- **Codex** - `cd "${CODEX_HOME:-$HOME/.codex}/lumen" && git pull`, then
157+
rerun `./scripts/run codex install`
165158
- **OpenCode** - update the version pin in `opencode.json` (e.g.
166159
`@ory/lumen-opencode@0.0.29`) and restart OpenCode
167160

@@ -172,8 +165,9 @@ On first Claude Code or Cursor session start, Lumen:
172165
2. Indexes your project in the background using Merkle tree change detection
173166
3. Registers a `semantic_search` MCP tool that the host can use automatically
174167

175-
In Codex and OpenCode, the same binary download and index seeding happen on the
176-
first `semantic_search` call.
168+
In Codex, the installed `SessionStart` hook warms the index on startup, resume,
169+
and clear events. In OpenCode, index seeding happens on the first
170+
`semantic_search` call.
177171

178172
Two shared skills are also available: `doctor` (health check) and `reindex`
179173
(forced re-indexing). Claude exposes them as `/lumen:doctor` and

0 commit comments

Comments
 (0)