Skip to content

Commit 87c4012

Browse files
committed
docs: describe external runtime setup
1 parent dcaefe4 commit 87c4012

3 files changed

Lines changed: 67 additions & 33 deletions

File tree

README.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ upward as concise summaries; raw test and inspection logs stay outside
3737
conversational context. The root gives brief user-facing updates such as
3838
`L1 2/5 — Validate release metadata: in review`.
3939

40-
Context-mode is used to transport evidence.
40+
Context-mode transports evidence; it does not spawn agents.
4141

4242
## 🎮 Quick setup
4343

@@ -70,12 +70,16 @@ different marketplace snapshot configured, the script continues from that
7070
snapshot automatically and preserves its arguments.
7171

7272
The script defaults `CODEX_HOME` to `~/.codex-gestalt`, installs both plugins,
73-
prepares context-mode, generates `org-plan-reviewer` and `org-plan-executor`,
74-
and removes the retired `org-plan-supervisor`. It does not create, validate, or
75-
rewrite `config.toml`; `codex plugin add` only records the installed plugins.
73+
and prepares context-mode under `~/.gestalt`. Setup generates `org-plan-reviewer` and `org-plan-executor`,
74+
then removes the obsolete
75+
`~/.codex-gestalt/agents/org-plan-supervisor.toml`. It does not create,
76+
validate, or rewrite `config.toml`; `codex plugin add` only records the installed
77+
plugins.
7678
Current Codex already defaults the V1 agent depth to one and enables stable
7779
lifecycle hooks. The former `features.plugin_hooks` flag has been removed, so
78-
Gestalt needs no configuration override.
80+
Gestalt needs no configuration override. On an older installation, remove an
81+
`agents.max_depth = 2` override; setup does not create, validate, or rewrite
82+
Codex configuration.
7983

8084
Start or restart Codex with that home, verify the effective installation, and
8185
run `ctx-doctor` in a new session:
@@ -89,14 +93,29 @@ codex
8993
### Runtime preparation details
9094

9195
Run `./gestalt-setup.sh` again after a marketplace upgrade. Use
92-
`./gestalt-setup.sh --prepare-only` to prepare a source checkout without
96+
`./gestalt-setup.sh --prepare-only` to install the external runtime without
9397
installing plugins or changing the isolated Codex home, and `--force` to replace
94-
an invalid prepared runtime. Set `CODEX_HOME` explicitly only to test or install
95-
an additional isolated Gestalt profile.
98+
an invalid prepared runtime. Runtime versions are isolated by operating system,
99+
CPU architecture, and Node ABI under
100+
`${GESTALT_HOME:-$HOME/.gestalt}/runtime/context-mode/`. Set `CODEX_HOME`
101+
explicitly only to test or install an additional isolated Gestalt profile.
102+
Use `./gestalt-setup.sh --force` to rebuild and atomically replace that runtime.
103+
104+
Marketplace installation does not execute setup automatically. On an existing
105+
installation, upgrade the marketplace and rerun its setup script:
106+
107+
```sh
108+
export CODEX_HOME="$HOME/.codex-gestalt"
109+
codex plugin marketplace upgrade dyne-gestalt-agents
110+
"$CODEX_HOME/.tmp/marketplaces/dyne-gestalt-agents/gestalt-setup.sh"
111+
```
96112

97113
Do not add duplicate MCP or hook configuration. If startup still fails after
98114
forced preparation, confirm that another context-mode marketplace variant is
99-
not also enabled.
115+
not also enabled. `CONTEXT_MODE_NOT_PREPARED` identifies a missing, incompatible,
116+
or damaged external runtime; rerun setup with `--force` and restart Codex. MCP
117+
and hook startup are side-effect free: only setup installs, builds, or repairs
118+
the external runtime.
100119

101120
## 🧪 Testing (only for developers of this repo)
102121

USAGE.md

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ and the `context-mode` runtime plugin.
88
Context-mode requires Node.js 22.5 or newer, npm, network access during setup,
99
and the native toolchain needed by `better-sqlite3` (`python3`, `make`, and a
1010
C/C++ compiler). A working Bun installation is used for dependencies when
11-
available.
11+
available. Set `CONTEXT_MODE_PACKAGE_MANAGER=npm` or `bun` to override automatic
12+
selection during setup.
1213

1314
```sh
1415
export CODEX_HOME="$HOME/.codex-gestalt"
@@ -22,15 +23,16 @@ When setup is launched from another checkout, it automatically continues from
2223
the marketplace snapshot configured in `~/.codex-gestalt`.
2324

2425
Marketplace installation does not run the setup script automatically. The
25-
script installs both plugins, prepares the exact installed context-mode cache,
26-
verifies its artifact manifest, generates the reviewer and executor profiles,
27-
and removes the retired supervisor profile. It does not create, validate, or
28-
rewrite `config.toml`. Run setup again after a marketplace upgrade.
26+
script installs both plugins, prepares a stable context-mode runtime under
27+
`${GESTALT_HOME:-$HOME/.gestalt}`, verifies its artifact manifest, generates the
28+
reviewer and executor profiles, and removes the retired supervisor profile. It
29+
does not create, validate, or rewrite `config.toml`. Run setup again after a
30+
marketplace upgrade.
2931

3032
Useful modes:
3133

3234
```sh
33-
./gestalt-setup.sh --prepare-only # prepare this source tree only
35+
./gestalt-setup.sh --prepare-only # install only the external runtime
3436
./gestalt-setup.sh --force # reinstall dependencies and rebuild
3537
./gestalt-setup.sh --dry-run # print mutations without running them
3638
```
@@ -110,35 +112,44 @@ registry, or writes generated files. Startup follows this path:
110112

111113
```text
112114
Codex MCP start
113-
-> start.mjs
115+
-> start.mjs in the replaceable Codex plugin cache
116+
-> resolve version + platform + architecture + Node ABI
114117
-> runtime-preflight.mjs (read only)
115-
-> server.bundle.mjs
118+
-> ~/.gestalt/runtime/context-mode/<version>/<target>/server.bundle.mjs
116119
```
117120

118121
`runtime-preflight.mjs` verifies the package version and SHA-256 artifact
119-
manifest. An incomplete cache exits with code 78,
122+
manifest, including the native `better-sqlite3` binding. An incomplete external
123+
runtime exits with code 78,
120124
`CONTEXT_MODE_NOT_PREPARED`, the invalid paths, and the setup command.
121125

122126
Preparation is explicit:
123127

124128
```text
125129
gestalt-setup.sh
126-
-> codex plugin add
127-
-> prepare-runtime.mjs in the installed cache
130+
-> install-runtime.mjs
131+
-> copy source into a versioned external staging directory
128132
-> locked dependency install
129133
-> TypeScript check and bundle build
130134
-> bundle assertions
131135
-> versioned SHA-256 manifest
136+
-> atomic publication under ~/.gestalt
137+
-> codex plugin add
132138
```
133139

134-
The setup lock only prevents concurrent preparation from corrupting the cache;
135-
MCP and hook startup do not acquire it. The manifest covers the server, CLI,
136-
and hook bundles plus runtime dependency metadata.
140+
Runtime directories use the package version and
141+
`<platform>-<architecture>-node-<modules ABI>` as their identity. They survive
142+
Codex plugin-cache replacement and can be shared by profiles running the same
143+
Node ABI. `GESTALT_HOME` must be absolute when set. The setup lock prevents
144+
concurrent installers from publishing a partial runtime; MCP and hook startup
145+
are read-only and do not acquire it. Codex hooks use a cache-local launcher that
146+
loads their implementations from the same external runtime.
137147

138148
`package.json` is a private dependency and build manifest. Codex marketplace
139149
installation does not use npm publication metadata or npm lifecycle scripts.
140150
The repository-level setup script is the required pre-flight because Codex has
141-
no marketplace install-build hook and generated bundles are not committed.
151+
no marketplace install-build hook, generated bundles are not committed, and
152+
Codex may rematerialize its plugin cache when a session starts.
142153

143154
The context-mode plugin exposes only its Codex MCP and hook surfaces. Hooks use
144155
Codex's auto-discovered `hooks/hooks.json` path, so the plugin manifest does not
@@ -159,7 +170,7 @@ Startup coverage verifies that:
159170
write path;
160171
2. an incomplete runtime fails quickly with the stable diagnostic;
161172
3. explicit preparation is concurrency-safe and produces a valid MCP
162-
`initialize` and `tools/list` exchange;
173+
`initialize` and `tools/list` exchange after the plugin cache is recreated;
163174
4. Codex hooks do not invoke preparation;
164175
5. plugin manifests, runtime artifacts, skill metadata, and skill discovery
165176
remain consistent.

plugins/context-mode/README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,30 @@ From the `dyne-gestalt-agents` marketplace checkout, run:
2222
./gestalt-setup.sh
2323
```
2424

25-
The setup command installs both marketplace plugins, installs locked
26-
context-mode dependencies in the installed cache, type-checks the TypeScript,
27-
builds the runtime bundles, and writes a SHA-256 preparation manifest. It
25+
The setup command installs both marketplace plugins and creates a versioned
26+
runtime under `${GESTALT_HOME:-$HOME/.gestalt}`. It installs locked dependencies,
27+
type-checks the TypeScript, builds the runtime bundles, verifies the native
28+
SQLite binding, and writes a SHA-256 preparation manifest. It
2829
requires Node.js 22.5 or newer, npm, network access, and a native toolchain for
29-
`better-sqlite3`.
30+
`better-sqlite3`. Set `CONTEXT_MODE_PACKAGE_MANAGER=npm` or `bun` to override
31+
automatic dependency-installer selection.
3032

31-
Run setup again after an upgrade. Use `--prepare-only` for the source checkout,
33+
Run setup again after an upgrade. Use `--prepare-only` for only the external runtime,
3234
`--force` to rebuild, or `--dry-run` to inspect mutations.
3335

3436
## Startup contract
3537

3638
Codex starts `node ./start.mjs`. The launcher only:
3739

3840
1. records the project directory and selects the Codex platform;
39-
2. verifies the prepared artifact manifest;
40-
3. imports `server.bundle.mjs`.
41+
2. resolves the external runtime from its version and the current Node ABI;
42+
3. verifies the prepared artifact manifest;
43+
4. imports the external `server.bundle.mjs`.
4144

4245
It never installs, compiles, repairs, or rewrites files. An incomplete runtime
4346
exits with code 78 and `CONTEXT_MODE_NOT_PREPARED` so the failure is immediate
44-
instead of timing out during the MCP handshake.
47+
instead of timing out during the MCP handshake. Codex may replace its plugin
48+
cache without affecting the prepared runtime.
4549

4650
The plugin manifest registers `.mcp.json`, while Codex discovers lifecycle
4751
hooks from the conventional `hooks/hooks.json` path. Do not add duplicate MCP

0 commit comments

Comments
 (0)