trylode 0.5.1 → 0.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trylode",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
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" },
@@ -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`, `.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 |
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 lines (check integrations with Lode; record integration decisions in `docs/adr/`) 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; run again, it updates a rules block or rule file that exactly matches one an earlier init writes (`.grok/rules/lode.md` only when the note says init created it) to the current one; `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 |
@@ -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.4'; // the skill's version: kept equal to SKILL_VERSION in lode.mjs by a test
87
+ const VERSION = '2026.12.6'; // 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'; })();
@@ -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.4';
59
+ export const SKILL_VERSION = '2026.12.6';
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' };
@@ -1172,13 +1172,16 @@ const SETUP_URL = 'https://trylode.io/mcp?src=setup';
1172
1172
  // blocks and rule files written with v1 are still recognised, so they count as set up and init --remove still takes them out.
1173
1173
  export const RULE_V1 = "Before you add, recommend or install a third-party integration or SDK, check it with the Lode MCP server (https://trylode.io/mcp?src=rules): call check_stack for the apps this project already uses, or find_integrations or get_integration for the one you are adding. Quote Lode's facts with their dates. If Lode has no record, say it is not documented by Lode, not that it is unsupported.";
1174
1174
  export const RULE = "Before you add, recommend or install a third-party integration or SDK, or decide to build that capability yourself (email, auth, payments, background jobs, rate limiting and similar), check it with the Lode MCP server (https://trylode.io/mcp?src=rules): call check_stack for the apps this project already uses, then find_integrations for the options or get_integration for the one you are adding. Quote Lode's facts with their dates. If Lode has no record, say it is not documented by Lode, not that it is unsupported.";
1175
- const rulesBlock = (rule) => `<!-- lode:rules (added by lode init; node lode.mjs init --remove --yes takes it out) -->\n## Integrations\n${rule}\n<!-- /lode:rules -->\n`;
1176
- const rulesMdc = (rule) => `---\ndescription: Check third-party integrations with Lode before adding them\nalwaysApply: true\n---\n${rule}\n`;
1177
- export const RULES_BLOCK = rulesBlock(RULE);
1178
- export const RULES_MDC = rulesMdc(RULE);
1175
+ // LOD-315 (Paul approved the line 04-12-2026; harness 05-12-2026: with it 2 of 2 agent picks saved a decision record, without it 0 of 3):
1176
+ // blocks and rule files from 2026.12.5 add the decision-record line after the rule. Earlier ones are still recognised.
1177
+ export const RULE_DECISION = 'Integration decisions are recorded in docs/adr/. Before adding, changing or removing an integration, check it with Lode and write a new record.';
1178
+ const rulesBlock = (rule, extra) => `<!-- lode:rules (added by lode init; node lode.mjs init --remove --yes takes it out) -->\n## Integrations\n${rule}\n${extra ? `${extra}\n` : ''}<!-- /lode:rules -->\n`;
1179
+ const rulesMdc = (rule, extra) => `---\ndescription: Check third-party integrations with Lode before adding them\nalwaysApply: true\n---\n${rule}\n${extra ? `${extra}\n` : ''}`;
1180
+ export const RULES_BLOCK = rulesBlock(RULE, RULE_DECISION);
1181
+ export const RULES_MDC = rulesMdc(RULE, RULE_DECISION);
1179
1182
  // Every block and rule file a released init has written, newest first.
1180
- export const KNOWN_BLOCKS = [RULES_BLOCK, rulesBlock(RULE_V1)];
1181
- export const KNOWN_MDCS = [RULES_MDC, rulesMdc(RULE_V1)];
1183
+ export const KNOWN_BLOCKS = [RULES_BLOCK, rulesBlock(RULE), rulesBlock(RULE_V1)];
1184
+ export const KNOWN_MDCS = [RULES_MDC, rulesMdc(RULE), rulesMdc(RULE_V1)];
1182
1185
  // LOD-306: the Codex server block (.codex/config.toml), for either address init writes.
1183
1186
  export const codexBlock = (u) => `# lode:mcp (added by lode init; npx trylode remove --yes takes it out)\n[mcp_servers.lode]\nurl = "${u}"\n`;
1184
1187
  export const KNOWN_TOMLS = [SETUP_URL, LODE_URL].map(codexBlock);
@@ -1325,10 +1328,15 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
1325
1328
  if (lookalike) { refused.push(`${t.file}: has a lode:rules block that isn't the one lode init writes, so it was left alone.`); continue; }
1326
1329
  if (remove) { if (block) plan.push({ do: 'rules-remove', file: t.file, f, text, st: r.st, kind: 'md', block }); continue; }
1327
1330
  if (text == null && !t.create) continue;
1331
+ // LOD-315 (Paul, 05-12-2026): an exact earlier Lode block is updated in place to the current one; nothing else changes
1332
+ if (block && block !== RULES_BLOCK && block !== crlf(RULES_BLOCK)) { plan.push({ do: 'rules-upgrade', file: t.file, f, text, st: r.st, kind: 'md', next: text.replace(block, () => (block.includes('\r\n') ? crlf(RULES_BLOCK) : RULES_BLOCK)) }); continue; }
1328
1333
  if (text != null && (block || text.includes(RULE) || text.includes(RULE_V1))) continue;
1329
1334
  plan.push({ do: 'rules-add', file: t.file, f, text, st: r.st, kind: 'md' });
1330
1335
  } else if (text == null) { if (!remove) plan.push({ do: 'rules-add', file: t.file, f, text, kind: t.kind }); }
1331
- 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 }); }
1336
+ else if (KNOWN_MDCS.some((m) => text === m || text === crlf(m))) {
1337
+ if (remove) plan.push({ do: 'rules-remove', file: t.file, f, text, st: r.st, kind: t.kind });
1338
+ else if (text !== RULES_MDC && text !== crlf(RULES_MDC)) plan.push({ do: 'rules-upgrade', file: t.file, f, text, st: r.st, kind: t.kind, next: text.includes('\r\n') ? crlf(RULES_MDC) : RULES_MDC });
1339
+ }
1332
1340
  else refused.push(`${t.file}: isn't the rule file lode init writes, so it was left alone.`);
1333
1341
  }
1334
1342
  // LOD-306 (Paul, 04-12-2026): Grok Build's terminal app (grok) does not read .mdc rules; it reads *.md in
@@ -1351,6 +1359,7 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
1351
1359
  else if (!covered) {
1352
1360
  if (g.text == null) plan.push({ do: 'rules-add', file: grokRel, f: path.join(cwd, grokRel), text: null, kind: 'grok' });
1353
1361
  else if (!isOurs(g.text)) refused.push(`${grokRel}: isn't the rule file lode init writes, so it was left alone.`);
1362
+ else if (marker.grok_rules === true && g.text !== RULES_BLOCK && g.text !== crlf(RULES_BLOCK)) plan.push({ do: 'rules-upgrade', file: grokRel, f: path.join(cwd, grokRel), text: g.text, st: g.st, kind: 'grok', next: g.text.includes('\r\n') ? crlf(RULES_BLOCK) : RULES_BLOCK });
1354
1363
  }
1355
1364
  }
1356
1365
  }
@@ -1393,7 +1402,8 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
1393
1402
  : 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' : ''}`
1394
1403
  : 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)`
1395
1404
  : p.do === 'rules-remove' && p.kind === 'toml' ? ` ${p.file}: remove the "lode" server lode init added (nothing else in the file changes)`
1396
- : 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'}`
1405
+ : p.do === 'rules-add' ? ` ${p.file}: ${p.text == null ? 'create it with' : 'add, at the end,'} the Lode rules lines (the agent checks Lode before it adds an integration, and writes a decision record in docs/adr/)${p.text == null ? '' : '; nothing else in the file changes'}`
1406
+ : p.do === 'rules-upgrade' ? ` ${p.file}: update the Lode rules ${p.kind === 'md' ? 'block' : 'file'} an earlier lode init added to the current one, which adds the decision-record line${p.kind === 'md' ? ' (nothing else in the file changes)' : ''}`
1397
1407
  : 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)' : ''}`
1398
1408
  : 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)`
1399
1409
  : ` ${p.file}/: delete the skill files lode init copied, if unchanged`);
@@ -1430,7 +1440,8 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
1430
1440
  return;
1431
1441
  }
1432
1442
  let next = '';
1433
- if (p.kind === 'md' || p.kind === 'toml') {
1443
+ if (p.do === 'rules-upgrade') next = p.next;
1444
+ else if (p.kind === 'md' || p.kind === 'toml') {
1434
1445
  const lead = ['\r\n\r\n', '\n\n'].find((l) => p.text.includes(l + p.block));
1435
1446
  next = lead ? p.text.replace(lead + p.block, lead.slice(0, lead.length / 2)) : p.text.replace(p.block, '');
1436
1447
  }
@@ -1454,13 +1465,13 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
1454
1465
  if (p.created && !Object.keys(next[p.key] ?? {}).length && Object.keys(next).length === 1) fs.rmSync(p.f); else write(p, next);
1455
1466
  marker.added = (marker.added || []).filter((a) => a.file !== p.file);
1456
1467
  }
1457
- if (p.do === 'rules-add' || p.do === 'rules-remove') {
1468
+ if (p.do === 'rules-add' || p.do === 'rules-remove' || p.do === 'rules-upgrade') {
1458
1469
  // A failure here is reported, never thrown, so the marker for the steps already done is still written
1459
1470
  try {
1460
1471
  rulesWrite(p);
1461
1472
  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 }] : [])];
1462
1473
  // Security review 04-12-2026: the .grok file is removed only when the marker says init created it
1463
- if (p.kind === 'grok') { if (p.do === 'rules-add') marker.grok_rules = true; else delete marker.grok_rules; }
1474
+ if (p.kind === 'grok') { if (p.do === 'rules-add') marker.grok_rules = true; else if (p.do === 'rules-remove') delete marker.grok_rules; }
1464
1475
  } catch (e) { failed.push(` ${p.file}: not changed (${e.code || e.message}).`); }
1465
1476
  }
1466
1477
  if (p.do === 'copy-skill') {