trylode 0.5.3 → 0.5.4
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 +2 -1
- package/README.md +3 -1
- package/bin/cli.mjs +3 -1
- package/package.json +1 -1
- package/skill/PERMISSIONS.md +1 -1
- package/skill/SKILL.md +1 -1
- package/skill/scripts/failure-hook.mjs +1 -1
- package/skill/scripts/lode.mjs +54 -21
package/PERMISSIONS.md
CHANGED
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
- Only with `--no-agents-md`: the rules line in `.github/copilot-instructions.md` (for Copilot), since Copilot would otherwise not get it.
|
|
15
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`).
|
|
16
16
|
- `.claude/skills/lode-integration-check/`: a copy of the Lode Integration Check skill.
|
|
17
|
+
- `.agents/skills/lode-integration-check/` (for Codex and Gemini CLI) and `.github/skills/lode-integration-check/` (for VS Code's Copilot): the same copy of the skill. Remove deletes only the files setup copied that are unchanged, and any folder left empty.
|
|
17
18
|
- `.claude/lode-init.json`: a note of what was added, so `remove` can undo exactly that.
|
|
18
19
|
|
|
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
|
|
20
|
+
`--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 to `.claude/skills/` and writes the note; `vscode` also copies it to `.github/skills/`, and `gemini` and `codex` to `.agents/skills/`. Lode Gate and the other hooks are added only with `--client claude` or no `--client`.
|
|
20
21
|
|
|
21
22
|
### Only with `--gate` (Lode Gate, Claude Code only, off unless you add it)
|
|
22
23
|
|
package/README.md
CHANGED
|
@@ -11,7 +11,9 @@ It adds:
|
|
|
11
11
|
|
|
12
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
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
|
-
3. **The Lode Integration Check skill** in `.claude/skills
|
|
14
|
+
3. **The Lode Integration Check skill** in `.claude/skills/` (Claude Code and Grok Build), `.agents/skills/` (Codex and Gemini CLI) and `.github/skills/` (VS Code's Copilot).
|
|
15
|
+
|
|
16
|
+
Already set up before 0.5.4? Run `npx trylode setup` again to add the skill for Codex, Gemini CLI and VS Code's Copilot. It adds only what is missing.
|
|
15
17
|
|
|
16
18
|
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.
|
|
17
19
|
|
package/bin/cli.mjs
CHANGED
|
@@ -17,7 +17,9 @@ const USAGE = `Usage:
|
|
|
17
17
|
CLAUDE.md, AGENTS.md, GEMINI.md, .cursor/rules/lode.mdc: the Lode rules line (each created if missing;
|
|
18
18
|
--no-agents-md leaves AGENTS.md out and writes .github/copilot-instructions.md instead);
|
|
19
19
|
.grok/rules/lode.md for Grok Build's terminal app when the line won't be in AGENTS.md
|
|
20
|
-
.claude/skills/lode-integration-check/: the Lode Integration Check skill
|
|
20
|
+
.claude/skills/lode-integration-check/: the Lode Integration Check skill (Claude Code, Grok Build)
|
|
21
|
+
.agents/skills/lode-integration-check/: the same skill for Codex and Gemini CLI
|
|
22
|
+
.github/skills/lode-integration-check/: the same skill for VS Code's Copilot
|
|
21
23
|
--gate Also enables Lode Gate for Claude Code in .claude/settings.local.json (user-local, not shared).
|
|
22
24
|
Injects Lode's facts into the agent's context before installing a known package; never blocks.
|
|
23
25
|
--triage Also enables the Lode failure hook for Claude Code in .claude/settings.local.json (user-local, not shared).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trylode",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
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" },
|
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`, `.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
|
|
19
|
+
| `init` | the skill folders `.claude/skills/lode-integration-check/`, `.agents/skills/lode-integration-check/` and `.github/skills/lode-integration-check/`, `.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/` (and, for `vscode`, `gemini`, `codex` or every client, in `.github/skills/` or `.agents/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 |
|
package/skill/SKILL.md
CHANGED
|
@@ -249,7 +249,7 @@ 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` (Grok Build, formerly Cursor), a copy of this skill in `.claude/skills
|
|
252
|
+
`.cursor/mcp.json` (Grok Build, formerly Cursor), a copy of this skill in `.claude/skills/` (and in `.agents/skills/` for Codex and Gemini CLI, `.github/skills/` for VS Code's Copilot), 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
254
|
missing), and as `.cursor/rules/lode.mdc` (plus `.grok/rules/lode.md` for Grok Build's terminal app when
|
|
255
255
|
the line won't be in `AGENTS.md`). Add `--no-rules` to leave the rules line out, or `--no-agents-md`
|
|
@@ -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.7'; // 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
|
@@ -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.7';
|
|
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' };
|
|
@@ -1219,13 +1219,14 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
|
|
|
1219
1219
|
try { const s2 = fs.fstatSync(fd); if (!s2.isFile() || s2.ino !== st.ino) return { bad: 'changed while being read.' }; return { text: fs.readFileSync(fd, 'utf8'), st }; } finally { fs.closeSync(fd); }
|
|
1220
1220
|
};
|
|
1221
1221
|
try { if (!fs.lstatSync(path.join(cwd, '.claude')).isDirectory()) return '.claude is not a folder, so lode init won\'t write there. Nothing was written.'; } catch { /* absent: created when needed */ }
|
|
1222
|
+
const NEW_SKILL_KEYS = ['agents_skill_files', 'github_skill_files']; // LOD-328: the .agents and .github skill copies
|
|
1222
1223
|
let marker = { added: [], skill_files: {} };
|
|
1223
1224
|
const mr = readSafe(markerRel);
|
|
1224
1225
|
if (mr.bad) return `${markerRel}: ${mr.bad} Nothing was written.`;
|
|
1225
1226
|
if (mr.text != null) {
|
|
1226
1227
|
let m; try { m = JSON.parse(mr.text); } catch { m = undefined; }
|
|
1227
1228
|
const plainObj = (o) => !!o && typeof o === 'object' && !Array.isArray(o);
|
|
1228
|
-
if (!plainObj(m) || (m.added != null && !(Array.isArray(m.added) && m.added.every(plainObj))) || (m.skill_files != null && !plainObj(m.skill_files)))
|
|
1229
|
+
if (!plainObj(m) || (m.added != null && !(Array.isArray(m.added) && m.added.every(plainObj))) || (m.skill_files != null && !plainObj(m.skill_files)) || NEW_SKILL_KEYS.some((k) => m[k] != null && !plainObj(m[k])) || (m.skill_dirs_created != null && !(Array.isArray(m.skill_dirs_created) && m.skill_dirs_created.every((x) => typeof x === 'string'))))
|
|
1229
1230
|
return `${markerRel} isn't the note lode init writes, so nothing was changed. Nothing was written.`;
|
|
1230
1231
|
marker = { added: [], skill_files: {}, ...m };
|
|
1231
1232
|
}
|
|
@@ -1250,9 +1251,15 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
|
|
|
1250
1251
|
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 })) });
|
|
1251
1252
|
const here = path.dirname(url.fileURLToPath(import.meta.url));
|
|
1252
1253
|
const skillSrc = path.resolve(here, '..');
|
|
1253
|
-
const skillRel = path.join('.claude', 'skills', 'lode-integration-check');
|
|
1254
|
-
const skillDst = path.join(cwd, skillRel);
|
|
1255
1254
|
const SKILL_FILES = ['SKILL.md', 'PERMISSIONS.md', path.join('scripts', 'lode.mjs')];
|
|
1255
|
+
// LOD-328 (Paul, 05-12-2026): the skill goes where each client reads skills, from the clients' own docs (read
|
|
1256
|
+
// 05-12-2026). Claude Code: .claude/skills/. Codex's docs name .agents/skills/; Gemini CLI reads it or .gemini/skills/.
|
|
1257
|
+
// VS Code names .github/skills/ as the Copilot harness's project location (its deprecated Local harness is documented
|
|
1258
|
+
// as also reading .claude and .agents). Grok Build reads .claude/skills/ and .agents/skills/. Each copy has its own key in the marker (an older
|
|
1259
|
+
// marker without the new keys is unchanged), a fixed folder and a fixed file list.
|
|
1260
|
+
const skillSpots = [{ rel: path.join('.claude', 'skills', 'lode-integration-check'), key: 'skill_files', want: true },
|
|
1261
|
+
{ rel: path.join('.agents', 'skills', 'lode-integration-check'), key: 'agents_skill_files', want: on('codex', 'gemini') },
|
|
1262
|
+
{ rel: path.join('.github', 'skills', 'lode-integration-check'), key: 'github_skill_files', want: on('vscode') }];
|
|
1256
1263
|
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
1257
1264
|
const plan = [], refused = [];
|
|
1258
1265
|
for (const t of targets) {
|
|
@@ -1277,10 +1284,16 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
|
|
|
1277
1284
|
else if (has) refused.push(`${t.file}: its "lode" entry isn't the one lode init adds, so it was left alone.`);
|
|
1278
1285
|
} 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 ?? '') });
|
|
1279
1286
|
}
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1287
|
+
for (const sp of skillSpots) {
|
|
1288
|
+
const dst = path.join(cwd, sp.rel), noted = Object.keys(marker[sp.key] || {}).length > 0;
|
|
1289
|
+
if (sp.key !== 'skill_files' && (remove ? !noted : !sp.want)) continue; // the .claude copy behaves as before LOD-328
|
|
1290
|
+
const top = sp.rel.split(path.sep)[0];
|
|
1291
|
+
const topBad = (() => { try { const st = fs.lstatSync(path.join(cwd, top)); return !st.isSymbolicLink() && !st.isDirectory(); } catch { return false; } })();
|
|
1292
|
+
if (!safe(sp.rel)) refused.push(`${sp.rel}: it or a folder above it is a link, so lode init won't touch it.`);
|
|
1293
|
+
else if (topBad) refused.push(`${sp.rel}: ${top} is not a folder, so lode init won't write there.`);
|
|
1294
|
+
else if (remove) { if (noted) plan.push({ do: 'remove-skill', file: sp.rel, spot: sp }); }
|
|
1295
|
+
else if (!fs.existsSync(path.join(dst, 'SKILL.md')) && path.resolve(skillSrc) !== path.resolve(dst)) plan.push({ do: 'copy-skill', file: sp.rel, spot: sp });
|
|
1296
|
+
}
|
|
1284
1297
|
// The rules line: one fixed block in CLAUDE.md and AGENTS.md (each created if missing; AGENTS.md left alone with
|
|
1285
1298
|
// --no-agents-md, LOD-287, Paul 03-12-2026), and its own
|
|
1286
1299
|
// Cursor rule file. A fixed list of files, never paths read from the marker; --remove takes out only the exact block
|
|
@@ -1475,30 +1488,50 @@ async function initCmd({ client = 'all', yes = false, remove = false, gate = fal
|
|
|
1475
1488
|
} catch (e) { failed.push(` ${p.file}: not changed (${e.code || e.message}).`); }
|
|
1476
1489
|
}
|
|
1477
1490
|
if (p.do === 'copy-skill') {
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
marker.skill_files[rel] = hash(to);
|
|
1491
|
+
const { rel: skillRel, key } = p.spot, skillDst = path.join(cwd, skillRel);
|
|
1492
|
+
const copied = {};
|
|
1493
|
+
// Security review 05-12-2026 (Low 1): note which of the fixed parent folders init itself creates, so --remove
|
|
1494
|
+
// never takes away a .agents or .github folder (or its skills/) the user already had, even an empty one
|
|
1495
|
+
if (key !== 'skill_files') {
|
|
1496
|
+
const made = [path.dirname(path.dirname(skillRel)), path.dirname(skillRel)].filter((d) => !fs.existsSync(path.join(cwd, d)));
|
|
1497
|
+
if (made.length) marker.skill_dirs_created = [...new Set([...(marker.skill_dirs_created || []), ...made])];
|
|
1486
1498
|
}
|
|
1499
|
+
try {
|
|
1500
|
+
for (const rel of SKILL_FILES) {
|
|
1501
|
+
const from = path.join(skillSrc, rel), to = path.join(skillDst, rel);
|
|
1502
|
+
if (!fs.existsSync(from) || !safe(path.join(skillRel, rel))) continue;
|
|
1503
|
+
fs.mkdirSync(path.dirname(to), { recursive: true });
|
|
1504
|
+
if (!safe(path.join(skillRel, rel))) continue;
|
|
1505
|
+
try { fs.copyFileSync(from, to, fs.constants.COPYFILE_EXCL); } catch { continue; } // never over an existing file
|
|
1506
|
+
copied[rel] = hash(to);
|
|
1507
|
+
}
|
|
1508
|
+
} catch (e) { failed.push(` ${skillRel}/: not all copied (${e.code || e.message}).`); }
|
|
1509
|
+
marker[key] = copied;
|
|
1487
1510
|
}
|
|
1488
1511
|
if (p.do === 'remove-skill') {
|
|
1489
1512
|
// Delete only files lode init copies (a fixed list, never a path read from the marker), inside the skill
|
|
1490
1513
|
// folder, not through links, regular files only, and only if nobody has changed them (security review 30-11-2026)
|
|
1491
|
-
|
|
1514
|
+
const { rel: skillRel, key } = p.spot, skillDst = path.join(cwd, skillRel);
|
|
1515
|
+
let removed = 0;
|
|
1516
|
+
for (const [rel, h] of Object.entries(marker[key] || {})) {
|
|
1492
1517
|
if (!SKILL_FILES.includes(rel) || !safe(path.join(skillRel, rel))) continue;
|
|
1493
1518
|
const f = path.join(skillDst, rel);
|
|
1494
1519
|
if (!path.resolve(f).startsWith(path.resolve(skillDst) + path.sep)) continue;
|
|
1495
|
-
try { if (fs.lstatSync(f).isFile() && hash(f) === h) fs.rmSync(f); } catch { /* already gone */ }
|
|
1520
|
+
try { if (fs.lstatSync(f).isFile() && hash(f) === h) { fs.rmSync(f); removed++; } } catch { /* already gone */ }
|
|
1521
|
+
}
|
|
1522
|
+
// Empty folders: the skill's own, then (for the new copies, and only when this run removed a file: Low 2) skills/
|
|
1523
|
+
// and .agents or .github, only those the note says init created (Low 1; checked against the fixed names) and only if empty
|
|
1524
|
+
const dirs = [path.join(skillDst, 'scripts'), skillDst];
|
|
1525
|
+
if (key !== 'skill_files' && removed) {
|
|
1526
|
+
for (const d of [path.dirname(skillRel), path.dirname(path.dirname(skillRel))]) if ((marker.skill_dirs_created || []).includes(d)) dirs.push(path.join(cwd, d));
|
|
1527
|
+
marker.skill_dirs_created = (marker.skill_dirs_created || []).filter((d) => !d.startsWith(skillRel.split(path.sep)[0]));
|
|
1528
|
+
if (!marker.skill_dirs_created.length) delete marker.skill_dirs_created;
|
|
1496
1529
|
}
|
|
1497
|
-
for (const d of
|
|
1498
|
-
marker.skill_files = {};
|
|
1530
|
+
for (const d of dirs) { try { if (!fs.lstatSync(d).isSymbolicLink() && !fs.readdirSync(d).length) fs.rmdirSync(d); } catch { /* not empty or gone */ } }
|
|
1531
|
+
if (key === 'skill_files') marker.skill_files = {}; else delete marker[key];
|
|
1499
1532
|
}
|
|
1500
1533
|
}
|
|
1501
|
-
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)) { writeInProject(fs, path, cwd, markerRel, JSON.stringify(marker, null, 2) + '\n', markerSt(fs, markerFile)); }
|
|
1534
|
+
if ((marker.added || []).length || Object.keys(marker.skill_files || {}).length || NEW_SKILL_KEYS.some((k) => Object.keys(marker[k] || {}).length) || marker.grok_rules === true || Object.values(HOOK_KINDS).some((k) => marker[k.key] || Object.keys(marker[k.filesKey] || {}).length)) { writeInProject(fs, path, cwd, markerRel, JSON.stringify(marker, null, 2) + '\n', markerSt(fs, markerFile)); }
|
|
1502
1535
|
else { try { fs.rmSync(markerFile); } catch { /* none */ } }
|
|
1503
1536
|
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.`;
|
|
1504
1537
|
}
|