trylode 0.4.1 → 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 +10 -5
- package/README.md +2 -2
- package/bin/cli.mjs +12 -7
- package/package.json +2 -2
- package/skill/PERMISSIONS.md +1 -1
- package/skill/SKILL.md +3 -2
- package/skill/scripts/failure-hook.mjs +1 -1
- package/skill/scripts/lode.mjs +109 -28
package/PERMISSIONS.md
CHANGED
|
@@ -5,13 +5,18 @@
|
|
|
5
5
|
## Writes (only with `--yes`; without it, nothing is written)
|
|
6
6
|
|
|
7
7
|
- `.mcp.json`: one `"lode"` server entry, `https://trylode.io/mcp?src=setup`. Other entries are unchanged.
|
|
8
|
-
- `.cursor/mcp.json`: the same entry for Cursor.
|
|
9
|
-
-
|
|
10
|
-
- `.
|
|
8
|
+
- `.cursor/mcp.json`: the same entry for Grok Build (formerly Cursor).
|
|
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`.
|
|
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.
|
|
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`).
|
|
11
16
|
- `.claude/skills/lode-integration-check/`: a copy of the Lode Integration Check skill.
|
|
12
17
|
- `.claude/lode-init.json`: a note of what was added, so `remove` can undo exactly that.
|
|
13
18
|
|
|
14
|
-
`--no-rules` leaves the rules line out. `--client claude`
|
|
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`.
|
|
15
20
|
|
|
16
21
|
### Only with `--gate` (Lode Gate, Claude Code only, off unless you add it)
|
|
17
22
|
|
|
@@ -45,4 +50,4 @@ Setup and remove make no network requests. The `?src=setup` code in the server a
|
|
|
45
50
|
|
|
46
51
|
## Removes
|
|
47
52
|
|
|
48
|
-
`npx trylode remove --yes` takes out only the entries, blocks, rule
|
|
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
|
|
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`. 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),
|
|
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,11 +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
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
17
20
|
.claude/skills/lode-integration-check/: the Lode Integration Check skill
|
|
18
21
|
--gate Also enables Lode Gate for Claude Code in .claude/settings.local.json (user-local, not shared).
|
|
19
22
|
Injects Lode's facts into the agent's context before installing a known package; never blocks.
|
|
@@ -52,8 +55,10 @@ for (let i = 1; i < argv.length; i++) {
|
|
|
52
55
|
else if (a === '--gate') gate = true;
|
|
53
56
|
else if (a === '--triage') triage = true;
|
|
54
57
|
else if (a === '--verify') verify = true;
|
|
55
|
-
else if (a === '--client' && ['claude', 'cursor', 'all'].includes(argv[i + 1])) { client = argv[i + 1];
|
|
58
|
+
else if (a === '--client' && ['claude', 'cursor', 'vscode', 'gemini', 'codex', 'all'].includes(argv[i + 1])) { client = argv[i + 1]; i++; }
|
|
56
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);
|
|
57
62
|
const yes = flags.includes('--yes') ? ['--yes'] : [];
|
|
58
63
|
// A refusal (nothing changed because a file looked wrong) exits 2, so a script calling setup notices.
|
|
59
64
|
const OK = /^(Done|Removed):|would (change|write) these files|already set up|already on in this project|Nothing to remove/;
|
|
@@ -64,7 +69,7 @@ async function steps() {
|
|
|
64
69
|
if (cmd === 'setup') {
|
|
65
70
|
const first = await run(['init', '--src', 'setup', ...flags]);
|
|
66
71
|
if (!OK.test(first)) return { out: [first], ok: false };
|
|
67
|
-
if (client
|
|
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 };
|
|
68
73
|
if (gate || triage || verify) {
|
|
69
74
|
const out = [first]; let ok = true;
|
|
70
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.
|
|
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
|
}
|
package/skill/PERMISSIONS.md
CHANGED
|
@@ -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` | 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 `
|
|
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 |
|
package/skill/SKILL.md
CHANGED
|
@@ -249,9 +249,10 @@ node scripts/lode.mjs init [--client claude|cursor|all]
|
|
|
249
249
|
```
|
|
250
250
|
|
|
251
251
|
It shows the files it would change: one `lode` entry in `.mcp.json` (Claude Code) and/or
|
|
252
|
-
`.cursor/mcp.json` (Cursor), a copy of this skill in `.claude/skills/`, and the Lode rules line (so the
|
|
252
|
+
`.cursor/mcp.json` (Grok Build, formerly Cursor), a copy of this skill in `.claude/skills/`, and the Lode rules line (so the
|
|
253
253
|
agent checks Lode before it adds an integration) at the end of `CLAUDE.md` and `AGENTS.md` (each created if
|
|
254
|
-
missing), and as `.cursor/rules/lode.mdc
|
|
254
|
+
missing), and as `.cursor/rules/lode.mdc` (plus `.grok/rules/lode.md` for Grok Build's terminal app when
|
|
255
|
+
the line won't be in `AGENTS.md`). Add `--no-rules` to leave the rules line out, or `--no-agents-md`
|
|
255
256
|
to leave out `AGENTS.md`. It writes nothing until the
|
|
256
257
|
user agrees and you run it again with `--yes`. It runs only in a project folder, never through links, leaves
|
|
257
258
|
any config file it can't parse alone (it tells you the entry to add by hand), changes no other entry or text, adds no
|
|
@@ -84,7 +84,7 @@ export function loadSignals() {
|
|
|
84
84
|
|
|
85
85
|
// ---- Step 2: the hook (PostToolUseFailure). Sends only app, platform, symptom code and status number, never the
|
|
86
86
|
// output text, the command, paths, versions or the session id. Asks once per app, platform and symptom in a session.
|
|
87
|
-
const VERSION = '2026.12.
|
|
87
|
+
const VERSION = '2026.12.4'; // the skill's version: kept equal to SKILL_VERSION in lode.mjs by a test
|
|
88
88
|
// The hook ships inside the skill, so it identifies as the skill: the server already counts `lode-skill` and leaves
|
|
89
89
|
// `lode-skill-test` (Lode's own tests) out of every figure. Only Lode's tests may point it at this machine.
|
|
90
90
|
const BASE = (() => { const u = process.env.LODE_GATE_URL || ''; return /^http:\/\/(127\.0\.0\.1|localhost)(:\d+)?$/.test(u) ? u : 'https://trylode.io'; })();
|
package/skill/scripts/lode.mjs
CHANGED
|
@@ -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,
|
|
@@ -56,7 +56,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
56
56
|
const BASE = (process.env.LODE_BASE || 'https://trylode.io').replace(/\/$/, '');
|
|
57
57
|
// The skill's version (year.month.day of its last change; a test makes every change bump it), sent in the user agent
|
|
58
58
|
// so Lode can count which copies agents run. Copies before 03-12-2026 all sent 0.1.
|
|
59
|
-
export const SKILL_VERSION = '2026.12.
|
|
59
|
+
export const SKILL_VERSION = '2026.12.4';
|
|
60
60
|
const UA = process.env.LODE_UA || `lode-skill/${SKILL_VERSION} (+https://trylode.io/agents/)`;
|
|
61
61
|
|
|
62
62
|
export const NAMES = { xero: 'Xero', 'quickbooks-online': 'QuickBooks Online', hubspot: 'HubSpot', shopify: 'Shopify', stripe: 'Stripe', supabase: 'Supabase', vercel: 'Vercel', netlify: 'Netlify', n8n: 'n8n', lovable: 'Lovable', replit: 'Replit', linear: 'Linear', github: 'GitHub', langchain: 'LangChain', cursor: 'Grok Build', cloudflare: 'Cloudflare' };
|
|
@@ -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 (
|
|
1192
|
-
if (
|
|
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.
|
|
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 "
|
|
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 "
|
|
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.
|
|
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.
|
|
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
|
-
|
|
1255
|
-
|
|
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,17 +1283,74 @@ 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:
|
|
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:
|
|
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
|
}
|
|
1290
|
+
// LOD-306 (Paul, 04-12-2026): Grok Build's terminal app (grok) does not read .mdc rules; it reads *.md in
|
|
1291
|
+
// .grok/rules/ and AGENTS.md (docs.grok.com/build/agents-window/rules.md, read 04-12-2026). So when the rules line
|
|
1292
|
+
// won't be in AGENTS.md after this run (--client cursor, or --no-agents-md with no AGENTS.md), init also writes
|
|
1293
|
+
// .grok/rules/lode.md: the same block, as the whole file. Created only if missing; removed only if unchanged and the
|
|
1294
|
+
// marker (.claude/lode-init.json, grok_rules) says init created it.
|
|
1295
|
+
if (remove || client === 'all' || client === 'cursor') {
|
|
1296
|
+
const grokRel = path.join('.grok', 'rules', 'lode.md');
|
|
1297
|
+
const isOurs = (x) => KNOWN_BLOCKS.some((b) => x === b || x === crlf(b));
|
|
1298
|
+
let covered = plan.some((p) => p.do === 'rules-add' && p.file === 'AGENTS.md');
|
|
1299
|
+
if (!remove && !covered) {
|
|
1300
|
+
const a = readRules('AGENTS.md');
|
|
1301
|
+
covered = !a.bad && a.text != null && (a.text.includes(RULE) || a.text.includes(RULE_V1));
|
|
1302
|
+
}
|
|
1303
|
+
const g = readRules(grokRel);
|
|
1304
|
+
const exists = (() => { try { return !!fs.lstatSync(path.join(cwd, grokRel)); } catch { return false; } })();
|
|
1305
|
+
if (g.bad) { if (exists || (!remove && !covered)) refused.push(`${grokRel}: ${g.bad}`); }
|
|
1306
|
+
else if (remove) { if (g.text != null && isOurs(g.text) && marker.grok_rules === true) plan.push({ do: 'rules-remove', file: grokRel, f: path.join(cwd, grokRel), text: g.text, st: g.st, kind: 'grok' }); }
|
|
1307
|
+
else if (!covered) {
|
|
1308
|
+
if (g.text == null) plan.push({ do: 'rules-add', file: grokRel, f: path.join(cwd, grokRel), text: null, kind: 'grok' });
|
|
1309
|
+
else if (!isOurs(g.text)) refused.push(`${grokRel}: isn't the rule file lode init writes, so it was left alone.`);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
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
|
+
}
|
|
1273
1345
|
}
|
|
1274
1346
|
const refusedText = refused.length ? `\nNot changed:\n${refused.map((r) => ` ${r}`).join('\n')}` : '';
|
|
1275
1347
|
if (!plan.length) return (remove ? 'Nothing to remove that lode init added.' : 'Lode is already set up in this project.') + refusedText;
|
|
1276
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)'}`
|
|
1277
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)`
|
|
1278
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'}`
|
|
1279
|
-
: p.do === 'rules-remove' ? ` ${p.file}: remove the Lode rules ${p.kind === '
|
|
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)' : ''}`
|
|
1280
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)`
|
|
1281
1355
|
: ` ${p.file}/: delete the skill files lode init copied, if unchanged`);
|
|
1282
1356
|
if (!remove) lines.push(` ${markerRel}: a small note of what lode init added, so --remove undoes only that`);
|
|
@@ -1287,20 +1361,21 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
|
|
|
1287
1361
|
fs.writeFileSync(p.f, p.eol ? out.replace(/\n/g, '\r\n') : out);
|
|
1288
1362
|
// Check afterwards that every other entry is exactly as it was
|
|
1289
1363
|
const back = JSON.parse(fs.readFileSync(p.f, 'utf8'));
|
|
1290
|
-
for (const k of Object.keys(p.cur)) if (k !==
|
|
1291
|
-
for (const k of Object.keys(p.cur.
|
|
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`);
|
|
1292
1366
|
};
|
|
1293
1367
|
// The rules line: a new file is created with O_EXCL (never follows a link, never overwrites); an existing file is
|
|
1294
1368
|
// opened without following a link, must still be the very file that was read (same inode, size and time), and is
|
|
1295
1369
|
// only appended to; --remove writes back the text that was read minus the exact block, or deletes a file left empty.
|
|
1296
1370
|
const failed = [];
|
|
1371
|
+
const content = (kind) => (kind === 'mdc' ? RULES_MDC : kind === 'toml' ? codexBlock(serverUrl) : RULES_BLOCK);
|
|
1297
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; };
|
|
1298
1373
|
const rulesWrite = (p) => {
|
|
1299
1374
|
if (!safe(p.file)) throw new Error('a link appeared');
|
|
1300
1375
|
if (p.text == null) {
|
|
1301
1376
|
fs.mkdirSync(path.dirname(p.f), { recursive: true });
|
|
1302
1377
|
if (!safe(p.file)) throw new Error('a link appeared');
|
|
1303
|
-
fs.writeFileSync(p.f, p.kind
|
|
1378
|
+
fs.writeFileSync(p.f, content(p.kind), { flag: 'wx' });
|
|
1304
1379
|
return;
|
|
1305
1380
|
}
|
|
1306
1381
|
if (p.do === 'rules-add') {
|
|
@@ -1308,12 +1383,12 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
|
|
|
1308
1383
|
const fd = fs.openSync(p.f, fs.constants.O_WRONLY | fs.constants.O_APPEND | NOFOLLOW);
|
|
1309
1384
|
try {
|
|
1310
1385
|
if (!unchanged(fd, p.st)) throw new Error('changed while lode init ran');
|
|
1311
|
-
fs.writeSync(fd, `${p.text.endsWith('\n') ? '' : eol}${eol}${eol === '\n' ?
|
|
1386
|
+
fs.writeSync(fd, `${p.text.endsWith('\n') ? '' : eol}${eol}${eol === '\n' ? content(p.kind) : crlf(content(p.kind))}`);
|
|
1312
1387
|
} finally { fs.closeSync(fd); }
|
|
1313
1388
|
return;
|
|
1314
1389
|
}
|
|
1315
1390
|
let next = '';
|
|
1316
|
-
if (p.kind === 'md') {
|
|
1391
|
+
if (p.kind === 'md' || p.kind === 'toml') {
|
|
1317
1392
|
const lead = ['\r\n\r\n', '\n\n'].find((l) => p.text.includes(l + p.block));
|
|
1318
1393
|
next = lead ? p.text.replace(lead + p.block, lead.slice(0, lead.length / 2)) : p.text.replace(p.block, '');
|
|
1319
1394
|
}
|
|
@@ -1329,17 +1404,23 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
|
|
|
1329
1404
|
for (const p of plan) {
|
|
1330
1405
|
if (p.do === 'add') {
|
|
1331
1406
|
fs.mkdirSync(path.dirname(p.f), { recursive: true });
|
|
1332
|
-
write(p, { ...p.cur,
|
|
1333
|
-
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 } : {}) }];
|
|
1334
1409
|
}
|
|
1335
1410
|
if (p.do === 'remove') {
|
|
1336
|
-
const next = { ...p.cur,
|
|
1337
|
-
if (p.
|
|
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);
|
|
1338
1414
|
marker.added = (marker.added || []).filter((a) => a.file !== p.file);
|
|
1339
1415
|
}
|
|
1340
1416
|
if (p.do === 'rules-add' || p.do === 'rules-remove') {
|
|
1341
1417
|
// A failure here is reported, never thrown, so the marker for the steps already done is still written
|
|
1342
|
-
try {
|
|
1418
|
+
try {
|
|
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 }] : [])];
|
|
1421
|
+
// Security review 04-12-2026: the .grok file is removed only when the marker says init created it
|
|
1422
|
+
if (p.kind === 'grok') { if (p.do === 'rules-add') marker.grok_rules = true; else delete marker.grok_rules; }
|
|
1423
|
+
} catch (e) { failed.push(` ${p.file}: not changed (${e.code || e.message}).`); }
|
|
1343
1424
|
}
|
|
1344
1425
|
if (p.do === 'copy-skill') {
|
|
1345
1426
|
marker.skill_files = {};
|
|
@@ -1365,7 +1446,7 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
|
|
|
1365
1446
|
marker.skill_files = {};
|
|
1366
1447
|
}
|
|
1367
1448
|
}
|
|
1368
|
-
if ((marker.added || []).length || Object.keys(marker.skill_files || {}).length || Object.values(HOOK_KINDS).some((k) => marker[k.key] || Object.keys(marker[k.filesKey] || {}).length)) { fs.mkdirSync(path.dirname(markerFile), { recursive: true }); fs.writeFileSync(markerFile, JSON.stringify(marker, null, 2) + '\n'); }
|
|
1449
|
+
if ((marker.added || []).length || Object.keys(marker.skill_files || {}).length || marker.grok_rules === true || Object.values(HOOK_KINDS).some((k) => marker[k.key] || Object.keys(marker[k.filesKey] || {}).length)) { fs.mkdirSync(path.dirname(markerFile), { recursive: true }); fs.writeFileSync(markerFile, JSON.stringify(marker, null, 2) + '\n'); }
|
|
1369
1450
|
else { try { fs.rmSync(markerFile); } catch { /* none */ } }
|
|
1370
1451
|
return `${remove ? 'Removed' : 'Done'}:\n${lines.join('\n')}${refusedText}${failed.length ? `\nFailed:\n${failed.join('\n')}` : ''}\n${remove ? '' : 'Commit these files so teammates and sub-agents in this project have Lode. Undo with: ' + runCmd(true) + ' --yes\n'}Nothing was sent to Lode.`;
|
|
1371
1452
|
}
|
|
@@ -1580,7 +1661,7 @@ export async function main(argv) {
|
|
|
1580
1661
|
}
|
|
1581
1662
|
if (cmd === 'init') {
|
|
1582
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') };
|
|
1583
|
-
const client =
|
|
1664
|
+
const client = INIT_CLIENTS.includes(opts.client) ? opts.client : 'all';
|
|
1584
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 });
|
|
1585
1666
|
}
|
|
1586
1667
|
if (cmd === 'watch') {
|
|
@@ -1599,7 +1680,7 @@ export async function main(argv) {
|
|
|
1599
1680
|
return v.format(res, failOn);
|
|
1600
1681
|
}
|
|
1601
1682
|
if (cmd === 'platforms') return `Lode covers: ${Object.keys(PLATFORMS).join(', ')}. Facts are source-linked and dated; see https://trylode.io/methodology/`;
|
|
1602
|
-
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';
|
|
1603
1684
|
}
|
|
1604
1685
|
|
|
1605
1686
|
// Run only when this very file is the entry point (security review 01-12-2026: endsWith('lode.mjs') also matched trylode.mjs).
|