trylode 0.4.2 → 0.5.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/PERMISSIONS.md CHANGED
@@ -6,13 +6,17 @@
6
6
 
7
7
  - `.mcp.json`: one `"lode"` server entry, `https://trylode.io/mcp?src=setup`. Other entries are unchanged.
8
8
  - `.cursor/mcp.json`: the same entry for Grok Build (formerly Cursor).
9
- - `CLAUDE.md` and `AGENTS.md` (each created if missing; `AGENTS.md` left out with `--no-agents-md`): one marked block with the Lode rules line, added at the end. Nothing else in the file changes.
9
+ - `.vscode/mcp.json`: the same entry for VS Code (under `"servers"`). VS Code's Copilot reads the `.mcp.json` entry above.
10
+ - `.gemini/settings.json`: the same entry for Gemini CLI (as `"httpUrl"`). Other settings are unchanged.
11
+ - `.codex/config.toml`: one marked `[mcp_servers.lode]` block with the same address, added at the end, for Codex. Codex reads this file only in a project you have marked trusted. Setup doesn't parse TOML, so it adds the block only when every other mention of `mcp_servers` is a plain `[mcp_servers.<name>]` header for another server and the file has no arrays of tables, `\u` escapes, unclosed multi-line strings or `lode` key; otherwise the file is left alone and setup prints the lines to add by hand. `remove` takes the block out only if setup recorded adding it and nothing was added under it.
12
+ - `CLAUDE.md`, `AGENTS.md` and `GEMINI.md` (each created if missing; `AGENTS.md` left out with `--no-agents-md`): one marked block with the Lode rules line, added at the end. Nothing else in the file changes. Codex and Copilot read `AGENTS.md`; Gemini CLI reads `GEMINI.md`.
10
13
  - `.cursor/rules/lode.mdc`: the rules line as a Grok Build (formerly Cursor) rule.
14
+ - Only with `--no-agents-md`: the rules line in `.github/copilot-instructions.md` (for Copilot), since Copilot would otherwise not get it.
11
15
  - `.grok/rules/lode.md`: the same rules line for Grok Build's terminal app, only when it won't be in `AGENTS.md` (with `--client cursor`, or `--no-agents-md` and no `AGENTS.md`).
12
16
  - `.claude/skills/lode-integration-check/`: a copy of the Lode Integration Check skill.
13
17
  - `.claude/lode-init.json`: a note of what was added, so `remove` can undo exactly that.
14
18
 
15
- `--no-rules` leaves the rules line out. `--client claude` or `--client cursor` writes for one client only.
19
+ `--no-rules` leaves the rules line out (the server entries are still written). `--client` writes for one client only: `claude` writes `.mcp.json`, `CLAUDE.md` and `AGENTS.md`; `cursor` writes `.cursor/mcp.json`, `.cursor/rules/lode.mdc` and `.grok/rules/lode.md`; `--client vscode` writes `.mcp.json`, `.vscode/mcp.json` and `AGENTS.md` (`.github/copilot-instructions.md` instead with `--no-agents-md`); `--client gemini` writes `.gemini/settings.json` and `GEMINI.md`; `--client codex` writes `.codex/config.toml` and `AGENTS.md`. Each also copies the skill and writes the note. Lode Gate and the other hooks are added only with `--client claude` or no `--client`.
16
20
 
17
21
  ### Only with `--gate` (Lode Gate, Claude Code only, off unless you add it)
18
22
 
@@ -46,4 +50,4 @@ Setup and remove make no network requests. The `?src=setup` code in the server a
46
50
 
47
51
  ## Removes
48
52
 
49
- `npx trylode remove --yes` takes out only the entries, blocks, rule file, skill copy and Gate hook that setup added, and deletes a file only when nothing else is left in it. `npx trylode remove --gate --yes` takes out only Lode Gate.
53
+ `npx trylode remove --yes` takes out only the entries, blocks, rule files, skill copy and Gate hook that setup added, and deletes a file only when nothing else is left in it. `npx trylode remove --gate --yes` takes out only Lode Gate.
package/README.md CHANGED
@@ -9,8 +9,8 @@ npx trylode setup --yes # adds it
9
9
 
10
10
  It adds:
11
11
 
12
- 1. **Lode's MCP server** to `.mcp.json` (Claude Code) and `.cursor/mcp.json` (Grok Build, formerly Cursor). Hosted, no sign-in or API key.
13
- 2. **The rules line** to `CLAUDE.md`, `AGENTS.md` (each created if missing; `--no-agents-md` leaves `AGENTS.md` out) and `.cursor/rules/lode.mdc` (plus `.grok/rules/lode.md` for Grok Build's terminal app when the line won't be in `AGENTS.md`). This is the step that matters most: agents reliably use a tool their instructions file tells them about.
12
+ 1. **Lode's MCP server** to `.mcp.json` (Claude Code and VS Code's Copilot), `.cursor/mcp.json` (Grok Build, formerly Cursor), `.vscode/mcp.json` (VS Code), `.gemini/settings.json` (Gemini CLI) and `.codex/config.toml` (Codex, in a trusted project). Hosted, no sign-in or API key.
13
+ 2. **The rules line** to `CLAUDE.md`, `AGENTS.md` (read by Codex and Copilot), `GEMINI.md` (each created if missing; `--no-agents-md` leaves `AGENTS.md` out) and `.cursor/rules/lode.mdc` (plus `.grok/rules/lode.md` for Grok Build's terminal app when the line won't be in `AGENTS.md`). This is the step that matters most: agents reliably use a tool their instructions file tells them about.
14
14
  3. **The Lode Integration Check skill** in `.claude/skills/`.
15
15
 
16
16
  Optional (Claude Code only): Lode Gate. Running `npx trylode setup --gate --yes` adds a hook that runs just before the agent installs a package Lode knows (for example, `npm install resend`) and injects Lode's facts into the agent's context: required platform plan, recorded regions, and any SDK deprecation or published security advisory (each with a link and date). It never blocks an install and applies only to you, in this project (`.claude/settings.local.json`, kept out of git). When triggered, it sends only package names and a few codes to Lode—never your full command, source code, or local file paths. See [PERMISSIONS.md](PERMISSIONS.md) for details.
package/bin/cli.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  // npx trylode setup (LOD-248, Paul approved 01-12-2026): puts Lode into this project for the coding agents that read it.
3
3
  // It is the Lode Integration Check skill's reviewed `init`, packaged: it writes Lode's MCP server (address tagged
4
- // ?src=setup), the rules line (CLAUDE.md, AGENTS.md, .cursor/rules/lode.mdc) and the skill, shows the plan
4
+ // ?src=setup) for Claude Code, Grok Build (formerly Cursor), VS Code/Copilot, Gemini CLI and Codex (LOD-306), the rules
5
+ // line (CLAUDE.md, AGENTS.md, GEMINI.md, .cursor/rules/lode.mdc) and the skill, shows the plan
5
6
  // first and writes only with --yes. It sends nothing to Lode. `npx trylode remove --yes` undoes only what it added.
6
7
  // With --gate (LOD-262) it also runs the skill's reviewed `init --gate` (warn mode, .claude/settings.local.json only).
7
8
  // With --verify it runs `init --verify` the same way (the Stop hook). `npx trylode verify` runs the check itself: in CI,
@@ -9,12 +10,13 @@
9
10
  // No dependencies, no install scripts. See PERMISSIONS.md.
10
11
 
11
12
  const USAGE = `Usage:
12
- npx trylode setup [--yes] [--client claude|cursor|all] [--no-rules] [--no-agents-md] [--gate] [--triage] [--verify]
13
+ npx trylode setup [--yes] [--client claude|cursor|vscode|gemini|codex|all] [--no-rules] [--no-agents-md] [--gate] [--triage] [--verify]
13
14
  Shows what it would add to this project, and adds it with --yes:
14
- .mcp.json and .cursor/mcp.json: one "lode" server entry (other entries unchanged)
15
- CLAUDE.md, AGENTS.md, .cursor/rules/lode.mdc: the Lode rules line (each created if missing;
16
- --no-agents-md leaves AGENTS.md out); .grok/rules/lode.md for Grok Build's terminal app
17
- when the line won't be in AGENTS.md
15
+ .mcp.json, .cursor/mcp.json, .vscode/mcp.json, .gemini/settings.json: one "lode" server entry
16
+ (other entries unchanged); .codex/config.toml: one [mcp_servers.lode] block at the end
17
+ CLAUDE.md, AGENTS.md, GEMINI.md, .cursor/rules/lode.mdc: the Lode rules line (each created if missing;
18
+ --no-agents-md leaves AGENTS.md out and writes .github/copilot-instructions.md instead);
19
+ .grok/rules/lode.md for Grok Build's terminal app when the line won't be in AGENTS.md
18
20
  .claude/skills/lode-integration-check/: the Lode Integration Check skill
19
21
  --gate Also enables Lode Gate for Claude Code in .claude/settings.local.json (user-local, not shared).
20
22
  Injects Lode's facts into the agent's context before installing a known package; never blocks.
@@ -53,8 +55,10 @@ for (let i = 1; i < argv.length; i++) {
53
55
  else if (a === '--gate') gate = true;
54
56
  else if (a === '--triage') triage = true;
55
57
  else if (a === '--verify') verify = true;
56
- else if (a === '--client' && ['claude', 'cursor', 'all'].includes(argv[i + 1])) { client = argv[i + 1]; flags.push(a, argv[i + 1]); i++; }
58
+ else if (a === '--client' && ['claude', 'cursor', 'vscode', 'gemini', 'codex', 'all'].includes(argv[i + 1])) { client = argv[i + 1]; i++; }
57
59
  }
60
+ // Only the --client kept here is passed on, so the files and the hooks always follow the same client (review 04-12-2026)
61
+ if (client !== 'all') flags.push('--client', client);
58
62
  const yes = flags.includes('--yes') ? ['--yes'] : [];
59
63
  // A refusal (nothing changed because a file looked wrong) exits 2, so a script calling setup notices.
60
64
  const OK = /^(Done|Removed):|would (change|write) these files|already set up|already on in this project|Nothing to remove/;
@@ -65,7 +69,7 @@ async function steps() {
65
69
  if (cmd === 'setup') {
66
70
  const first = await run(['init', '--src', 'setup', ...flags]);
67
71
  if (!OK.test(first)) return { out: [first], ok: false };
68
- if (client === 'cursor') return { out: [first, ...(gate || triage || verify ? ['Lode Gate, the failure hook and the verify hook are for Claude Code only, so they were ignored with --client cursor.'] : [])], ok: true };
72
+ if (client !== 'claude' && client !== 'all') return { out: [first, ...(gate || triage || verify ? [`Lode Gate, the failure hook and the verify hook are for Claude Code only, so they were ignored with --client ${client}.`] : [])], ok: true };
69
73
  if (gate || triage || verify) {
70
74
  const out = [first]; let ok = true;
71
75
  for (const [on, f] of [[gate, '--gate'], [triage, '--triage'], [verify, '--verify']]) if (on) { const g = await run(['init', f, '--src', 'setup', ...yes]); out.push(g); ok = ok && OK.test(g); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trylode",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "One command puts Lode in your project: the MCP server, the rules line and the skill, so your coding agent checks integration facts before it adds a third-party service.",
5
5
  "type": "module",
6
6
  "bin": { "trylode": "bin/cli.mjs" },
@@ -9,5 +9,5 @@
9
9
  "license": "MIT",
10
10
  "homepage": "https://trylode.io/agents/",
11
11
  "repository": { "type": "git", "url": "git+https://github.com/lode-hq/lode-mcp.git", "directory": "npm/trylode" },
12
- "keywords": ["lode", "mcp", "agents", "claude-code", "cursor", "integrations", "agents-md"]
12
+ "keywords": ["lode", "mcp", "agents", "claude-code", "cursor", "integrations", "agents-md", "codex", "gemini-cli", "copilot", "vscode"]
13
13
  }
@@ -16,7 +16,7 @@ secrets. Privacy policy: https://trylode.io/privacy/
16
16
  | `stack` | `package.json`, `requirements.txt`, `pyproject.toml`, `Gemfile`, `go.mod`, variable NAMES in `.env.example`, `vercel.json`, `netlify.toml`, `supabase/config.toml` | with `--share`: the app and platform codes found, the framework | nothing |
17
17
  | `triage` | nothing | the app, platform, one fixed symptom code, the HTTP status if given (only its class is kept) and the `--object` code if given (sent only when it is one of the platform's object codes, otherwise not sent); with `--share`: the outcome code and the `--switched-to` app | nothing |
18
18
  | `watch` (`watch`, `watch changes`, `watch stop`) | `lode-integrations.json`, `.lode/watch.json` and an existing `.gitignore` (never through links; a file not in the expected shape is refused) | `watch`: only with `--share`, the Lode ids of the integrations still kept in `lode-integrations.json` (at most 50); Lode makes a fresh random watch code, unless `--project-code` asks it to use the file's own project code; the watch code and token on later updates. `watch changes` and `watch stop`: the watch code and the token only. Lode keeps the list of ids until the watch is stopped; `stop` deletes it | `watch --share`: `.lode/watch.json` (mode 0600: the watch code and the secret token Lode returns once; the `.lode` folder is made if missing) and, only when a `.gitignore` already exists, one appended `.lode/` line; `watch stop` removes the token file |
19
- | `init` | `.mcp.json`, `.cursor/mcp.json`, `.claude/lode-init.json`, `CLAUDE.md`, `AGENTS.md`, `.cursor/rules/lode.mdc`, `.grok/rules/lode.md` | nothing | only with `--yes`, only inside a project folder and never through links: one `lode` entry in those MCP files, a copy of this skill in `.claude/skills/`, the Lode rules line as one marked block at the end of `CLAUDE.md` and `AGENTS.md` (each created if missing; `AGENTS.md` left out with `--no-agents-md`) and as `.cursor/rules/lode.mdc` (left out with `--no-rules`), and as `.grok/rules/lode.md` for Grok Build's terminal app only when the line won't be in `AGENTS.md` (with `--client cursor`, or `--no-agents-md` and no `AGENTS.md`), and a note of what was added in `.claude/lode-init.json`; a file it can't parse is left alone; `init --remove --yes` undoes only what init added (the rules block only when unchanged); with `--src setup` (used by `npx trylode setup`) the entry's address is `https://trylode.io/mcp?src=setup`, and `--remove` recognises either address |
19
+ | `init` | `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`, `.gemini/settings.json`, `.codex/config.toml`, `.claude/lode-init.json`, `CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, `.cursor/rules/lode.mdc`, `.grok/rules/lode.md` (only when the rules line won't be in `AGENTS.md`), and with `--no-agents-md` `.github/copilot-instructions.md` | nothing | only with `--yes`, only inside a project folder and never through links: one `lode` entry in those MCP files (`--client claude`, `cursor`, `vscode`, `gemini` or `codex` picks one client; in `.codex/config.toml` it is one marked `[mcp_servers.lode]` block added at the end, and a file that already names a `lode` server or has an inline `mcp_servers` table is left alone), a copy of this skill in `.claude/skills/`, the Lode rules line as one marked block at the end of `CLAUDE.md`, `AGENTS.md` and `GEMINI.md` (each created if missing; `AGENTS.md` left out with `--no-agents-md`, which writes the line to `.github/copilot-instructions.md` instead; `.grok/rules/lode.md` gets it whenever it won't be in `AGENTS.md`, and is removed only if unchanged and the note says init created it) and as `.cursor/rules/lode.mdc` (left out with `--no-rules`), and a note of what was added in `.claude/lode-init.json`; a file it can't parse is left alone; `init --remove --yes` undoes only what init added (the rules block only when unchanged); with `--src setup` (used by `npx trylode setup`) the entry's address is `https://trylode.io/mcp?src=setup`, and `--remove` recognises either address |
20
20
  | `init --gate` (Lode Gate, opt-in) | `.claude/settings.local.json` (or `.claude/settings.json` with `--shared`), `.claude/lode-init.json`, `.claude/.gitignore`, the Gate files already in `.claude/skills/lode-integration-check/` | nothing | only with `--yes`, only inside a project folder and never through links: one PreToolUse hook entry in that settings file (by default only for you: Claude Code keeps `settings.local.json` out of git; `--shared` gives it to everyone who opens the project), a copy of this skill with `gate.mjs` and `gate-packages.json` in `.claude/skills/` (it never overwrites a file, and refuses if Gate files already there differ from its own), two lines at the end of `.claude/.gitignore` inside a git repository (a comment and `settings.local.json`, so the hook file is never committed; `--remove` takes out exactly those two), and a note in `.claude/lode-init.json`; `init --gate --remove --yes` deletes only the files it copied, unchanged, from its fixed list |
21
21
  | Gate hook (`scripts/gate.mjs`, runs before each shell command once switched on) | the shell command Claude is about to run and the session id (on your machine only; the id is used only to name the temp file below), the project folder (`CLAUDE_PROJECT_DIR`, else the working folder), whether `vercel.json`, `.vercel/project.json`, `netlify.toml`, `supabase/config.toml`, `wrangler.toml`, `wrangler.json` or `wrangler.jsonc` exist there (names only, never contents), `gate-packages.json`, and `LODE_GATE_LOG` | only when the command installs a package on Lode's list: those package names, the package manager, the platform codes found, the mode and a random code for the Claude Code session; never the command, versions, paths, file contents or the session id; with `LODE_GATE_LOG=0` Lode keeps nothing except the daily rate-limit count | a random session code in your temp folder (tidied after a day) |
22
22
  | `init --triage` (the failure hook, opt-in) | the same files as `init --gate`, for the failure hook's own entry | nothing | only with `--yes`, under the same rules as `init --gate`: one `PostToolUseFailure` hook entry in `.claude/settings.local.json` (or `.claude/settings.json` with `--shared`), `failure-hook.mjs` and `failure-signals.json` copied with this skill, the same `.claude/.gitignore` lines and a note in `.claude/lode-init.json`; `init --triage --remove --yes` undoes only that |
@@ -25,7 +25,7 @@
25
25
  // why an integration fails: Lode's sourced facts for that kind of failure
26
26
  // node lode.mjs watch [--share] [--project-code] ask Lode to watch the kept integrations in lode-integrations.json (only with --share)
27
27
  // node lode.mjs watch changes [--since d] what changed in Lode for the watched integrations; watch stop deletes the watch
28
- // node lode.mjs init [--client claude|cursor|all] [--yes] [--remove]
28
+ // node lode.mjs init [--client claude|cursor|vscode|gemini|codex|all] [--yes] [--remove]
29
29
  // add Lode to this project so every teammate and sub-agent has it (shows the files first)
30
30
  //
31
31
  // What Lode receives: the app, platform and options in each request (for find and request: the needs,
@@ -1135,6 +1135,10 @@ export const RULES_MDC = rulesMdc(RULE);
1135
1135
  // Every block and rule file a released init has written, newest first.
1136
1136
  export const KNOWN_BLOCKS = [RULES_BLOCK, rulesBlock(RULE_V1)];
1137
1137
  export const KNOWN_MDCS = [RULES_MDC, rulesMdc(RULE_V1)];
1138
+ // LOD-306: the Codex server block (.codex/config.toml), for either address init writes.
1139
+ export const codexBlock = (u) => `# lode:mcp (added by lode init; npx trylode remove --yes takes it out)\n[mcp_servers.lode]\nurl = "${u}"\n`;
1140
+ export const KNOWN_TOMLS = [SETUP_URL, LODE_URL].map(codexBlock);
1141
+ export const INIT_CLIENTS = ['claude', 'cursor', 'vscode', 'gemini', 'codex', 'all'];
1138
1142
  async function initCmd({ client = 'all', yes = false, remove = false, gate = false, triage = false, verify = false, gateMode = 'warn', gateShared = false, rules = true, agentsMd = true, src = null } = {}) {
1139
1143
  const serverUrl = src === 'setup' ? SETUP_URL : LODE_URL;
1140
1144
  // The command the user or agent should run next: npx trylode's own when called through it (security review
@@ -1187,9 +1191,16 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
1187
1191
  const count = (v) => (v && typeof v === 'object' ? (Array.isArray(v) ? v.reduce((a, x) => a + count(x), 0) : Object.entries(v).reduce((a, [, x]) => a + 1 + count(x), 0)) : 0);
1188
1192
  return keyCount === count(JSON.parse(text));
1189
1193
  };
1194
+ // LOD-306 (Paul, 03-12-2026): VS Code/Copilot, Gemini CLI and Codex too. Each location and format is from the
1195
+ // client's own docs (docs/specs/trylode-more-agents.md): VS Code's Copilot harness reads the workspace-root .mcp.json
1196
+ // (mcpServers) and its older Local harness .vscode/mcp.json (servers); Gemini CLI reads .gemini/settings.json
1197
+ // (mcpServers, httpUrl for streamable HTTP); Codex reads .codex/config.toml in a trusted project (handled below).
1198
+ const on = (...c) => client === 'all' || c.includes(client);
1190
1199
  const targets = [];
1191
- if (client === 'all' || client === 'claude') targets.push({ file: '.mcp.json', entry: { type: 'http', url: serverUrl }, alts: [LODE_URL, SETUP_URL].map((u) => ({ type: 'http', url: u })) });
1192
- if (client === 'all' || client === 'cursor') targets.push({ file: path.join('.cursor', 'mcp.json'), entry: { url: serverUrl }, alts: [LODE_URL, SETUP_URL].map((u) => ({ url: u })) });
1200
+ if (on('claude', 'vscode')) targets.push({ file: '.mcp.json', key: 'mcpServers', entry: { type: 'http', url: serverUrl }, alts: [LODE_URL, SETUP_URL].map((u) => ({ type: 'http', url: u })) });
1201
+ if (on('cursor')) targets.push({ file: path.join('.cursor', 'mcp.json'), key: 'mcpServers', entry: { url: serverUrl }, alts: [LODE_URL, SETUP_URL].map((u) => ({ url: u })) });
1202
+ if (on('vscode')) targets.push({ file: path.join('.vscode', 'mcp.json'), key: 'servers', entry: { type: 'http', url: serverUrl }, alts: [LODE_URL, SETUP_URL].map((u) => ({ type: 'http', url: u })) });
1203
+ if (on('gemini')) targets.push({ file: path.join('.gemini', 'settings.json'), key: 'mcpServers', entry: { httpUrl: serverUrl }, alts: [LODE_URL, SETUP_URL].map((u) => ({ httpUrl: u })) });
1193
1204
  const here = path.dirname(url.fileURLToPath(import.meta.url));
1194
1205
  const skillSrc = path.resolve(here, '..');
1195
1206
  const skillRel = path.join('.claude', 'skills', 'lode-integration-check');
@@ -1206,18 +1217,18 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
1206
1217
  text = rd.text;
1207
1218
  if (text != null) {
1208
1219
  try { cur = JSON.parse(text); } catch { cur = undefined; }
1209
- if (!cur || typeof cur !== 'object' || Array.isArray(cur) || (cur.mcpServers != null && (typeof cur.mcpServers !== 'object' || Array.isArray(cur.mcpServers)))) {
1210
- refused.push(`${t.file}: not plain JSON that lode init can safely edit (comments, trailing commas or another shape). Add this entry by hand under "mcpServers": "lode": ${JSON.stringify(t.entry)}`); continue;
1220
+ if (!cur || typeof cur !== 'object' || Array.isArray(cur) || (cur[t.key] != null && (typeof cur[t.key] !== 'object' || Array.isArray(cur[t.key])))) {
1221
+ refused.push(`${t.file}: not plain JSON that lode init can safely edit (comments, trailing commas or another shape). Add this entry by hand under "${t.key}": "lode": ${JSON.stringify(t.entry)}`); continue;
1211
1222
  }
1212
- if (!lossless(text)) { refused.push(`${t.file}: writing it back would change other entries (a number that can't be kept exactly, or a repeated key). Add this entry by hand under "mcpServers": "lode": ${JSON.stringify(t.entry)}`); continue; }
1223
+ if (!lossless(text)) { refused.push(`${t.file}: writing it back would change other entries (a number that can't be kept exactly, or a repeated key). Add this entry by hand under "${t.key}": "lode": ${JSON.stringify(t.entry)}`); continue; }
1213
1224
  }
1214
1225
  const indent = (text?.match(/\n([ \t]+)"/) || [])[1] || 2;
1215
- const has = cur.mcpServers && Object.prototype.hasOwnProperty.call(cur.mcpServers, 'lode');
1226
+ const has = cur[t.key] && Object.prototype.hasOwnProperty.call(cur[t.key], 'lode');
1216
1227
  const ours = (marker.added || []).find((a) => a.file === t.file);
1217
1228
  if (remove) {
1218
- if (has && (t.alts.some((a) => same(cur.mcpServers.lode, a)) || (ours && same(cur.mcpServers.lode, ours.entry)))) plan.push({ do: 'remove', file: t.file, f, cur, indent, created: !!ours?.created, st: rd.st, eol: /\r\n/.test(text ?? '') });
1229
+ if (has && (t.alts.some((a) => same(cur[t.key].lode, a)) || (ours && same(cur[t.key].lode, ours.entry)))) plan.push({ do: 'remove', file: t.file, key: t.key, keyCreated: ours?.key_created === true, f, cur, indent, created: !!ours?.created, st: rd.st, eol: /\r\n/.test(text ?? '') });
1219
1230
  else if (has) refused.push(`${t.file}: its "lode" entry isn't the one lode init adds, so it was left alone.`);
1220
- } else if (!has) plan.push({ do: 'add', file: t.file, f, cur, indent, entry: t.entry, created: text == null, st: rd.st, eol: /\r\n/.test(text ?? '') });
1231
+ } else if (!has) plan.push({ do: 'add', file: t.file, key: t.key, f, cur, indent, entry: t.entry, created: text == null, st: rd.st, eol: /\r\n/.test(text ?? '') });
1221
1232
  }
1222
1233
  const skillThere = fs.existsSync(path.join(skillDst, 'SKILL.md'));
1223
1234
  if (!safe(skillRel)) refused.push(`${skillRel}: it or a folder above it is a link, so lode init won't touch it.`);
@@ -1251,8 +1262,14 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
1251
1262
  };
1252
1263
  if (rules || remove) {
1253
1264
  const ruleTargets = [];
1254
- if (remove || client === 'all' || client === 'claude') ruleTargets.push({ file: 'CLAUDE.md', kind: 'md', create: true }, { file: 'AGENTS.md', kind: 'md', create: agentsMd });
1255
- if (remove || client === 'all' || client === 'cursor') ruleTargets.push({ file: path.join('.cursor', 'rules', 'lode.mdc'), kind: 'mdc', create: true });
1265
+ const want = (...c) => remove || on(...c);
1266
+ // LOD-306: Codex and Copilot read AGENTS.md; Gemini CLI reads GEMINI.md by default. Copilot's own file gets the
1267
+ // line only when AGENTS.md is left out (--no-agents-md), so no agent reads it twice. Grok's terminal rules: below.
1268
+ if (want('claude')) ruleTargets.push({ file: 'CLAUDE.md', kind: 'md', create: true });
1269
+ if (want('claude', 'vscode', 'codex')) ruleTargets.push({ file: 'AGENTS.md', kind: 'md', create: agentsMd });
1270
+ if (want('cursor')) ruleTargets.push({ file: path.join('.cursor', 'rules', 'lode.mdc'), kind: 'mdc', create: true });
1271
+ if (want('vscode') && (remove || !agentsMd)) ruleTargets.push({ file: path.join('.github', 'copilot-instructions.md'), kind: 'md', create: true });
1272
+ if (want('gemini')) ruleTargets.push({ file: 'GEMINI.md', kind: 'md', create: true });
1256
1273
  for (const t of ruleTargets) {
1257
1274
  const f = path.join(cwd, t.file);
1258
1275
  const r = readRules(t.file);
@@ -1266,8 +1283,8 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
1266
1283
  if (text == null && !t.create) continue;
1267
1284
  if (text != null && (block || text.includes(RULE) || text.includes(RULE_V1))) continue;
1268
1285
  plan.push({ do: 'rules-add', file: t.file, f, text, st: r.st, kind: 'md' });
1269
- } else if (text == null) { if (!remove) plan.push({ do: 'rules-add', file: t.file, f, text, kind: 'mdc' }); }
1270
- else if (KNOWN_MDCS.some((m) => text === m || text === crlf(m))) { if (remove) plan.push({ do: 'rules-remove', file: t.file, f, text, st: r.st, kind: 'mdc' }); }
1286
+ } else if (text == null) { if (!remove) plan.push({ do: 'rules-add', file: t.file, f, text, kind: t.kind }); }
1287
+ else if (KNOWN_MDCS.some((m) => text === m || text === crlf(m))) { if (remove) plan.push({ do: 'rules-remove', file: t.file, f, text, st: r.st, kind: t.kind }); }
1271
1288
  else refused.push(`${t.file}: isn't the rule file lode init writes, so it was left alone.`);
1272
1289
  }
1273
1290
  // LOD-306 (Paul, 04-12-2026): Grok Build's terminal app (grok) does not read .mdc rules; it reads *.md in
@@ -1293,10 +1310,45 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
1293
1310
  }
1294
1311
  }
1295
1312
  }
1313
+ // LOD-306: Codex's project config is TOML, which init doesn't parse. It only ever creates the file with the fixed
1314
+ // block, appends that block to an existing file that has no Lode server and no inline mcp_servers table (a table
1315
+ // header appended there would be invalid), or takes out exactly that block. Anything else is left alone, with the
1316
+ // lines to add by hand. Codex reads it only in a project the user has marked trusted.
1317
+ if (on('codex')) {
1318
+ const rel = path.join('.codex', 'config.toml');
1319
+ const r = readRules(rel);
1320
+ if (r.bad) { if (!remove || (() => { try { return !!fs.lstatSync(path.join(cwd, rel)); } catch { return false; } })()) refused.push(`${rel}: ${r.bad}`); }
1321
+ else {
1322
+ const text = r.text;
1323
+ // Security review 04-12-2026: the block counts only at the start of a line, outside any multi-line string, and
1324
+ // with nothing but blank or comment lines between it and the next table header (or the end), so taking it out
1325
+ // can't move a line the user added under it onto another table. Remove only a block init recorded in its note.
1326
+ const odd = (t) => ((t.match(/"""/g) || []).length % 2) || ((t.match(/'''/g) || []).length % 2);
1327
+ const at = (b) => { const i = text.indexOf(b); if (i < 0 || (i > 0 && text[i - 1] !== '\n') || odd(text.slice(0, i))) return -1; return /^(?:[ \t]*(?:#[^\r\n]*)?\r?\n)*(?:[ \t]*(?:#[^\r\n]*)?$|[ \t]*\[)/.test(text.slice(i + b.length)) ? i : -1; };
1328
+ const block = text == null ? null : KNOWN_TOMLS.flatMap((b) => [crlf(b), b]).find((b) => at(b) >= 0);
1329
+ const rest = block ? text.replace(block, '') : (text ?? '');
1330
+ // TOML isn't parsed, so anything unusual is refused (the user gets the lines to add by hand): every mention of
1331
+ // mcp_servers must be a plain [mcp_servers.<name>] header for a server other than lode; no arrays of tables, no
1332
+ // \\u escapes, no unclosed multi-line string, no key named lode, no other copy of the marker.
1333
+ const plainHeader = /^[ \t]*\[mcp_servers\.(?!lode[ \t.\]])[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*\][ \t]*(?:#[^\r\n]*)?$/;
1334
+ const clash = rest.split(/\r?\n/).some((l) => l.includes('mcp_servers') && !plainHeader.test(l)) || rest.includes('[[') || rest.includes('\\u') || rest.includes('\\U') || odd(rest) || /^[ \t]*["']?lode["']?[ \t]*[.=]/m.test(rest) || rest.includes('lode:mcp');
1335
+ const byHand = `Add these lines by hand if you want Lode in Codex:\n${codexBlock(serverUrl)}`;
1336
+ const noted = (marker.added || []).find((a) => a.file === rel);
1337
+ if (remove) {
1338
+ if (block && noted) plan.push({ do: 'rules-remove', file: rel, f: path.join(cwd, rel), text, st: r.st, kind: 'toml', block });
1339
+ else if (noted || (text != null && text.includes('lode:mcp'))) refused.push(`${rel}: the "lode" block isn't where lode init put it, or lines were added under it, so it was left alone. Remove [mcp_servers.lode] by hand.`);
1340
+ } else if (!block) {
1341
+ if (clash) refused.push(`${rel}: has a "lode" server, an mcp_servers entry or TOML that lode init can't safely add to, so it was left alone. ${byHand}`);
1342
+ else plan.push({ do: 'rules-add', file: rel, f: path.join(cwd, rel), text, st: r.st, kind: 'toml' });
1343
+ }
1344
+ }
1345
+ }
1296
1346
  const refusedText = refused.length ? `\nNot changed:\n${refused.map((r) => ` ${r}`).join('\n')}` : '';
1297
1347
  if (!plan.length) return (remove ? 'Nothing to remove that lode init added.' : 'Lode is already set up in this project.') + refusedText;
1298
1348
  const lines = plan.map((p) => p.do === 'add' ? ` ${p.file}: ${p.created ? 'create it with' : 'add'} one entry "lode" -> ${serverUrl}${p.created ? '' : ' (other entries unchanged)'}`
1299
1349
  : p.do === 'remove' ? ` ${p.file}: remove the "lode" entry lode init added (other entries unchanged)${p.created ? '; delete the file if nothing else is left in it' : ''}`
1350
+ : p.do === 'rules-add' && p.kind === 'toml' ? ` ${p.file}: ${p.text == null ? 'create it with' : 'add, at the end,'} one server "lode" -> ${serverUrl}${p.text == null ? '' : '; nothing else in the file changes'} (Codex reads it in a trusted project)`
1351
+ : p.do === 'rules-remove' && p.kind === 'toml' ? ` ${p.file}: remove the "lode" server lode init added (nothing else in the file changes)`
1300
1352
  : p.do === 'rules-add' ? ` ${p.file}: ${p.text == null ? 'create it with' : 'add, at the end,'} the Lode rules line (the agent checks Lode before it adds an integration)${p.text == null ? '' : '; nothing else in the file changes'}`
1301
1353
  : p.do === 'rules-remove' ? ` ${p.file}: remove the Lode rules ${p.kind === 'md' ? 'line' : 'file'} lode init added${p.kind === 'md' ? ' (nothing else in the file changes)' : ''}`
1302
1354
  : p.do === 'copy-skill' ? ` ${p.file}/: copy the Lode Integration Check skill (SKILL.md, PERMISSIONS.md, scripts/lode.mjs; no dependencies, nothing runs on install)`
@@ -1309,20 +1361,21 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
1309
1361
  fs.writeFileSync(p.f, p.eol ? out.replace(/\n/g, '\r\n') : out);
1310
1362
  // Check afterwards that every other entry is exactly as it was
1311
1363
  const back = JSON.parse(fs.readFileSync(p.f, 'utf8'));
1312
- for (const k of Object.keys(p.cur)) if (k !== 'mcpServers' && !same(back[k], p.cur[k])) throw new Error(`${p.file} changed unexpectedly`);
1313
- for (const k of Object.keys(p.cur.mcpServers || {})) if (k !== 'lode' && !same(back.mcpServers?.[k], p.cur.mcpServers[k])) throw new Error(`${p.file} changed unexpectedly`);
1364
+ for (const k of Object.keys(p.cur)) if (k !== p.key && !same(back[k], p.cur[k])) throw new Error(`${p.file} changed unexpectedly`);
1365
+ for (const k of Object.keys(p.cur[p.key] || {})) if (k !== 'lode' && !same(back[p.key]?.[k], p.cur[p.key][k])) throw new Error(`${p.file} changed unexpectedly`);
1314
1366
  };
1315
1367
  // The rules line: a new file is created with O_EXCL (never follows a link, never overwrites); an existing file is
1316
1368
  // opened without following a link, must still be the very file that was read (same inode, size and time), and is
1317
1369
  // only appended to; --remove writes back the text that was read minus the exact block, or deletes a file left empty.
1318
1370
  const failed = [];
1371
+ const content = (kind) => (kind === 'mdc' ? RULES_MDC : kind === 'toml' ? codexBlock(serverUrl) : RULES_BLOCK);
1319
1372
  const unchanged = (fd, st) => { const s = fs.fstatSync(fd); return s.isFile() && s.ino === st.ino && s.dev === st.dev && s.size === st.size && s.mtimeMs === st.mtimeMs; };
1320
1373
  const rulesWrite = (p) => {
1321
1374
  if (!safe(p.file)) throw new Error('a link appeared');
1322
1375
  if (p.text == null) {
1323
1376
  fs.mkdirSync(path.dirname(p.f), { recursive: true });
1324
1377
  if (!safe(p.file)) throw new Error('a link appeared');
1325
- fs.writeFileSync(p.f, p.kind === 'mdc' ? RULES_MDC : RULES_BLOCK, { flag: 'wx' });
1378
+ fs.writeFileSync(p.f, content(p.kind), { flag: 'wx' });
1326
1379
  return;
1327
1380
  }
1328
1381
  if (p.do === 'rules-add') {
@@ -1330,12 +1383,12 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
1330
1383
  const fd = fs.openSync(p.f, fs.constants.O_WRONLY | fs.constants.O_APPEND | NOFOLLOW);
1331
1384
  try {
1332
1385
  if (!unchanged(fd, p.st)) throw new Error('changed while lode init ran');
1333
- fs.writeSync(fd, `${p.text.endsWith('\n') ? '' : eol}${eol}${eol === '\n' ? RULES_BLOCK : crlf(RULES_BLOCK)}`);
1386
+ fs.writeSync(fd, `${p.text.endsWith('\n') ? '' : eol}${eol}${eol === '\n' ? content(p.kind) : crlf(content(p.kind))}`);
1334
1387
  } finally { fs.closeSync(fd); }
1335
1388
  return;
1336
1389
  }
1337
1390
  let next = '';
1338
- if (p.kind === 'md') {
1391
+ if (p.kind === 'md' || p.kind === 'toml') {
1339
1392
  const lead = ['\r\n\r\n', '\n\n'].find((l) => p.text.includes(l + p.block));
1340
1393
  next = lead ? p.text.replace(lead + p.block, lead.slice(0, lead.length / 2)) : p.text.replace(p.block, '');
1341
1394
  }
@@ -1351,18 +1404,20 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
1351
1404
  for (const p of plan) {
1352
1405
  if (p.do === 'add') {
1353
1406
  fs.mkdirSync(path.dirname(p.f), { recursive: true });
1354
- write(p, { ...p.cur, mcpServers: { ...(p.cur.mcpServers || {}), lode: p.entry } });
1355
- marker.added = [...(marker.added || []).filter((a) => a.file !== p.file), { file: p.file, created: p.created, entry: p.entry }];
1407
+ write(p, { ...p.cur, [p.key]: { ...(p.cur[p.key] || {}), lode: p.entry } });
1408
+ marker.added = [...(marker.added || []).filter((a) => a.file !== p.file), { file: p.file, created: p.created, entry: p.entry, ...(p.cur[p.key] == null && !p.created ? { key_created: true } : {}) }];
1356
1409
  }
1357
1410
  if (p.do === 'remove') {
1358
- const next = { ...p.cur, mcpServers: { ...p.cur.mcpServers } }; delete next.mcpServers.lode;
1359
- if (p.created && !Object.keys(next.mcpServers).length && Object.keys(next).length === 1) fs.rmSync(p.f); else write(p, next);
1411
+ const next = { ...p.cur, [p.key]: { ...p.cur[p.key] } }; delete next[p.key].lode;
1412
+ if (p.keyCreated && !Object.keys(next[p.key]).length) delete next[p.key];
1413
+ if (p.created && !Object.keys(next[p.key] ?? {}).length && Object.keys(next).length === 1) fs.rmSync(p.f); else write(p, next);
1360
1414
  marker.added = (marker.added || []).filter((a) => a.file !== p.file);
1361
1415
  }
1362
1416
  if (p.do === 'rules-add' || p.do === 'rules-remove') {
1363
1417
  // A failure here is reported, never thrown, so the marker for the steps already done is still written
1364
1418
  try {
1365
1419
  rulesWrite(p);
1420
+ if (p.kind === 'toml') marker.added = [...(marker.added || []).filter((a) => a.file !== p.file), ...(p.do === 'rules-add' ? [{ file: p.file, created: p.text == null, toml: true }] : [])];
1366
1421
  // Security review 04-12-2026: the .grok file is removed only when the marker says init created it
1367
1422
  if (p.kind === 'grok') { if (p.do === 'rules-add') marker.grok_rules = true; else delete marker.grok_rules; }
1368
1423
  } catch (e) { failed.push(` ${p.file}: not changed (${e.code || e.message}).`); }
@@ -1606,7 +1661,7 @@ export async function main(argv) {
1606
1661
  }
1607
1662
  if (cmd === 'init') {
1608
1663
  const opts = { client: flag('--client'), yes: flag('--yes'), remove: flag('--remove'), gate: flag('--gate'), triage: flag('--triage'), verify: flag('--verify'), mode: flag('--mode'), shared: flag('--shared'), noRules: flag('--no-rules'), noAgentsMd: flag('--no-agents-md'), src: flag('--src') };
1609
- const client = ['claude', 'cursor', 'all'].includes(opts.client) ? opts.client : 'all';
1664
+ const client = INIT_CLIENTS.includes(opts.client) ? opts.client : 'all';
1610
1665
  return initCmd({ client, yes: opts.yes === true, remove: opts.remove === true, gate: opts.gate === true, triage: opts.gate !== true && opts.triage === true, verify: opts.gate !== true && opts.triage !== true && opts.verify === true, gateMode: opts.mode === 'ask' ? 'ask' : 'warn', gateShared: opts.shared === true, rules: opts.noRules !== true, agentsMd: opts.noAgentsMd !== true, src: opts.src === 'setup' ? 'setup' : null });
1611
1666
  }
1612
1667
  if (cmd === 'watch') {
@@ -1625,7 +1680,7 @@ export async function main(argv) {
1625
1680
  return v.format(res, failOn);
1626
1681
  }
1627
1682
  if (cmd === 'platforms') return `Lode covers: ${Object.keys(PLATFORMS).join(', ')}. Facts are source-linked and dated; see https://trylode.io/methodology/`;
1628
- return 'Usage:\n node lode.mjs check <app> [platform]\n node lode.mjs triage <app> <platform> --symptom <code> [--status 429] [--object o]\n node lode.mjs init [--client claude|cursor|all] [--no-rules] [--yes] [--remove]\n node lode.mjs init --gate [--mode ask] [--shared] [--yes] [--remove]\n node lode.mjs init --triage [--shared] [--yes] [--remove]\n node lode.mjs init --verify [--shared] [--yes] [--remove]\n node lode.mjs verify [--fail-on act|any|code,code] [--since YYYY-MM-DD]\n node lode.mjs find <platform> [--category c] [--needs a,b] [--region XX] [--stack a,b] [--framework f]\n node lode.mjs list <platform> [--category <c>] [--all]\n node lode.mjs chose <app|none> <platform> [--considered "A,B"] [--reason code] [--share]\n node lode.mjs outcome <app> <platform> <integrated|failed|abandoned|not-tried> [--failure-reason code] [--share]\n node lode.mjs request <app> <platform> [--needs a,b] [--region XX]\n node lode.mjs overlap <platform> --apps "A,B,C" [--region XX] [--share]\n node lode.mjs recheck [--share]\n node lode.mjs drop <app> <platform> [--reason code] [--switched-to <app>] [--share]\n node lode.mjs adr <platform> --considered "A,B" --chose B [--reason code] [--status s] [--constraint a,b] [--workaround a,b] [--share]\n node lode.mjs adr --update <file> [--status s] [--constraint a,b] [--workaround a,b] [--share]\n node lode.mjs stack [--framework f] [--share]\n node lode.mjs watch [--share] [--project-code] | watch changes [--since d] | watch stop\n node lode.mjs platforms';
1683
+ return 'Usage:\n node lode.mjs check <app> [platform]\n node lode.mjs triage <app> <platform> --symptom <code> [--status 429] [--object o]\n node lode.mjs init [--client claude|cursor|vscode|gemini|codex|all] [--no-rules] [--yes] [--remove]\n node lode.mjs init --gate [--mode ask] [--shared] [--yes] [--remove]\n node lode.mjs init --triage [--shared] [--yes] [--remove]\n node lode.mjs init --verify [--shared] [--yes] [--remove]\n node lode.mjs verify [--fail-on act|any|code,code] [--since YYYY-MM-DD]\n node lode.mjs find <platform> [--category c] [--needs a,b] [--region XX] [--stack a,b] [--framework f]\n node lode.mjs list <platform> [--category <c>] [--all]\n node lode.mjs chose <app|none> <platform> [--considered "A,B"] [--reason code] [--share]\n node lode.mjs outcome <app> <platform> <integrated|failed|abandoned|not-tried> [--failure-reason code] [--share]\n node lode.mjs request <app> <platform> [--needs a,b] [--region XX]\n node lode.mjs overlap <platform> --apps "A,B,C" [--region XX] [--share]\n node lode.mjs recheck [--share]\n node lode.mjs drop <app> <platform> [--reason code] [--switched-to <app>] [--share]\n node lode.mjs adr <platform> --considered "A,B" --chose B [--reason code] [--status s] [--constraint a,b] [--workaround a,b] [--share]\n node lode.mjs adr --update <file> [--status s] [--constraint a,b] [--workaround a,b] [--share]\n node lode.mjs stack [--framework f] [--share]\n node lode.mjs watch [--share] [--project-code] | watch changes [--since d] | watch stop\n node lode.mjs platforms';
1629
1684
  }
1630
1685
 
1631
1686
  // Run only when this very file is the entry point (security review 01-12-2026: endsWith('lode.mjs') also matched trylode.mjs).