lean-agents 0.0.0-stage → 1.0.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.
Files changed (148) hide show
  1. package/CHANGELOG.md +407 -0
  2. package/LICENSE +21 -0
  3. package/README.es.md +560 -0
  4. package/README.md +559 -2
  5. package/core/AGENTS.es.md +60 -0
  6. package/core/AGENTS.md +60 -0
  7. package/core/README.md +8 -0
  8. package/core/agents/debug.md +14 -0
  9. package/core/agents/explore.md +13 -0
  10. package/core/agents/planner.md +14 -0
  11. package/core/agents/research.md +13 -0
  12. package/core/agents/review.md +13 -0
  13. package/core/copilot-usage-tui.js +189 -0
  14. package/core/mcp.json +38 -0
  15. package/core/pins.json +39 -0
  16. package/core/tiers.json +4 -0
  17. package/node_modules/@clack/core/LICENSE +9 -0
  18. package/node_modules/@clack/core/README.md +22 -0
  19. package/node_modules/@clack/core/dist/index.d.mts +503 -0
  20. package/node_modules/@clack/core/dist/index.mjs +1003 -0
  21. package/node_modules/@clack/core/package.json +63 -0
  22. package/node_modules/@clack/prompts/LICENSE +9 -0
  23. package/node_modules/@clack/prompts/README.md +396 -0
  24. package/node_modules/@clack/prompts/dist/index.d.mts +949 -0
  25. package/node_modules/@clack/prompts/dist/index.mjs +1423 -0
  26. package/node_modules/@clack/prompts/package.json +67 -0
  27. package/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
  28. package/node_modules/fast-string-truncated-width/dist/index.js +111 -0
  29. package/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
  30. package/node_modules/fast-string-truncated-width/dist/types.js +2 -0
  31. package/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
  32. package/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
  33. package/node_modules/fast-string-truncated-width/license +21 -0
  34. package/node_modules/fast-string-truncated-width/package.json +35 -0
  35. package/node_modules/fast-string-truncated-width/readme.md +59 -0
  36. package/node_modules/fast-string-width/dist/index.d.ts +4 -0
  37. package/node_modules/fast-string-width/dist/index.js +14 -0
  38. package/node_modules/fast-string-width/license +21 -0
  39. package/node_modules/fast-string-width/package.json +34 -0
  40. package/node_modules/fast-string-width/readme.md +42 -0
  41. package/node_modules/fast-wrap-ansi/LICENSE +23 -0
  42. package/node_modules/fast-wrap-ansi/README.md +26 -0
  43. package/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
  44. package/node_modules/fast-wrap-ansi/lib/main.js +218 -0
  45. package/node_modules/fast-wrap-ansi/package.json +51 -0
  46. package/node_modules/jsonc-parser/CHANGELOG.md +76 -0
  47. package/node_modules/jsonc-parser/LICENSE.md +21 -0
  48. package/node_modules/jsonc-parser/README.md +364 -0
  49. package/node_modules/jsonc-parser/SECURITY.md +41 -0
  50. package/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
  51. package/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
  52. package/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
  53. package/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
  54. package/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
  55. package/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
  56. package/node_modules/jsonc-parser/lib/esm/main.js +178 -0
  57. package/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
  58. package/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
  59. package/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
  60. package/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
  61. package/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
  62. package/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
  63. package/node_modules/jsonc-parser/lib/umd/main.js +194 -0
  64. package/node_modules/jsonc-parser/package.json +37 -0
  65. package/node_modules/sisteransi/license +21 -0
  66. package/node_modules/sisteransi/package.json +34 -0
  67. package/node_modules/sisteransi/readme.md +113 -0
  68. package/node_modules/sisteransi/src/index.js +58 -0
  69. package/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
  70. package/package.json +30 -4
  71. package/profiles/README.md +10 -0
  72. package/profiles/anthropic-api/gsd-defaults.json +26 -0
  73. package/profiles/anthropic-api.json +18 -0
  74. package/profiles/antigravity.json +12 -0
  75. package/profiles/claude-subscription/gsd-defaults.json +26 -0
  76. package/profiles/claude-subscription.json +17 -0
  77. package/profiles/github-copilot/gsd-defaults.json +26 -0
  78. package/profiles/github-copilot.json +17 -0
  79. package/profiles/openai-api/gsd-defaults.json +26 -0
  80. package/profiles/openai-api.json +17 -0
  81. package/profiles/opencode-go/gsd-defaults.json +26 -0
  82. package/profiles/opencode-go.json +17 -0
  83. package/profiles/vertex-gemini/gsd-defaults.json +26 -0
  84. package/profiles/vertex-gemini.json +18 -0
  85. package/scripts/adhd-skill.mjs +12 -0
  86. package/scripts/behavior-diff.sh +47 -0
  87. package/scripts/bump-pins.mjs +115 -0
  88. package/scripts/check-private.sh +52 -0
  89. package/scripts/check-readme.mjs +131 -0
  90. package/scripts/ci-download.sh +20 -0
  91. package/scripts/ci-install-opencode-v2.sh +6 -0
  92. package/scripts/ci-latest-report.mjs +38 -0
  93. package/scripts/ci-timing.mjs +61 -0
  94. package/scripts/copilot-context-mode.mjs +33 -0
  95. package/scripts/labels.sh +56 -0
  96. package/scripts/lean.mjs +1319 -0
  97. package/scripts/lib/adapters/antigravity.mjs +83 -0
  98. package/scripts/lib/adapters/claude.mjs +127 -0
  99. package/scripts/lib/adapters/copilot-cli.mjs +82 -0
  100. package/scripts/lib/adapters/cursor.mjs +60 -0
  101. package/scripts/lib/adapters/opencode-v1.mjs +79 -0
  102. package/scripts/lib/adapters/opencode-v2.mjs +216 -0
  103. package/scripts/lib/adapters/vscode-copilot.mjs +56 -0
  104. package/scripts/lib/adhd.mjs +28 -0
  105. package/scripts/lib/adopt.mjs +619 -0
  106. package/scripts/lib/agent-lifecycle.mjs +280 -0
  107. package/scripts/lib/backup-stamp.mjs +25 -0
  108. package/scripts/lib/copilot-usage.mjs +49 -0
  109. package/scripts/lib/doctor.mjs +279 -0
  110. package/scripts/lib/feedback.mjs +48 -0
  111. package/scripts/lib/fsops.mjs +319 -0
  112. package/scripts/lib/gsd.mjs +42 -0
  113. package/scripts/lib/inventory.mjs +196 -0
  114. package/scripts/lib/lean-update.mjs +30 -0
  115. package/scripts/lib/logins.mjs +28 -0
  116. package/scripts/lib/migrate.mjs +407 -0
  117. package/scripts/lib/network.mjs +119 -0
  118. package/scripts/lib/node-runtime.mjs +85 -0
  119. package/scripts/lib/opencode-backup.mjs +204 -0
  120. package/scripts/lib/opencode-upgrade.mjs +441 -0
  121. package/scripts/lib/opencode1.mjs +203 -0
  122. package/scripts/lib/parallel.mjs +270 -0
  123. package/scripts/lib/pins-diff.mjs +33 -0
  124. package/scripts/lib/pins.mjs +52 -0
  125. package/scripts/lib/plugin-health.mjs +191 -0
  126. package/scripts/lib/prereqs.mjs +203 -0
  127. package/scripts/lib/project.mjs +38 -0
  128. package/scripts/lib/redact.mjs +30 -0
  129. package/scripts/lib/render.mjs +101 -0
  130. package/scripts/lib/shell-path.mjs +22 -0
  131. package/scripts/lib/summary-data.mjs +30 -0
  132. package/scripts/lib/summary-html.mjs +159 -0
  133. package/scripts/lib/system.mjs +269 -0
  134. package/scripts/lib/terminals.mjs +316 -0
  135. package/scripts/lib/ui.mjs +34 -0
  136. package/scripts/lib/unverified.mjs +49 -0
  137. package/scripts/lib/update-plan.mjs +60 -0
  138. package/scripts/lib/upgrade.mjs +231 -0
  139. package/scripts/lib/verify-commit.mjs +16 -0
  140. package/scripts/lib/verify-prompt.mjs +46 -0
  141. package/scripts/lib/verify-sha256.mjs +20 -0
  142. package/scripts/lint-workflows.mjs +25 -0
  143. package/scripts/models-refresh.mjs +58 -0
  144. package/scripts/parallel.mjs +59 -0
  145. package/scripts/pins-latest.mjs +66 -0
  146. package/scripts/release.mjs +71 -0
  147. package/scripts/verify-pins.mjs +36 -0
  148. package/scripts/version-watch.mjs +124 -0
@@ -0,0 +1,48 @@
1
+ // Opt-in feedback after a failed install: a redacted issue draft the agent shows before anything is filed.
2
+ import os from 'node:os';
3
+ import { redactText } from './redact.mjs';
4
+
5
+ // Filing an issue is an outbound call, so only the `outbound` category decides (strict turns it off).
6
+ export const feedbackAllowed = (network) => network?.outbound === 'on';
7
+
8
+ // Returns null when the preset forbids it. Everything free-form goes through redactText.
9
+ export function draftIssue({ network, home, env = process.env, versions = {}, command, error, kind = 'install', platform = `${os.platform()} ${os.arch()}` }) {
10
+ if (!feedbackAllowed(network)) return null;
11
+ const clean = (t) => redactText(t, { home, env });
12
+ const update = kind === 'update';
13
+ const verify = kind === 'verify';
14
+ const versionLines = Object.entries(versions).map(([k, v]) => `- ${k}: ${clean(v)}`);
15
+ return {
16
+ title: clean(`${update ? 'Update finding' : verify ? 'Verify finding' : 'Install failed'}: ${command}`).slice(0, 100),
17
+ body: [
18
+ update ? '## What the update found' : verify ? '## What the check found' : '## What failed',
19
+ `- OS: ${platform}`,
20
+ ...versionLines,
21
+ `- ${update || verify ? 'Tool' : 'Command'}: \`${clean(command)}\``,
22
+ '',
23
+ update || verify ? '## Details' : '## Error',
24
+ '```',
25
+ clean(error).trim(),
26
+ '```',
27
+ '',
28
+ '_Drafted by an agent, redacted by lean-agents, filed only after the user said yes._',
29
+ ].join('\n'),
30
+ };
31
+ }
32
+
33
+ // A doctor row `{ item, status, detail }` as an issue draft. Unlike draftIssue it always returns the redacted text, so a
34
+ // strict or offline user can copy it; `canFile` says whether the agent may offer to file it (feedbackAllowed).
35
+ export function draftFromRow({ network, row, ...rest }) {
36
+ const draft = draftIssue({ ...rest, network: { outbound: 'on' }, command: row.item, error: `${row.status}: ${row.detail ?? ''}`, kind: 'verify' });
37
+ return { ...draft, canFile: feedbackAllowed(network) };
38
+ }
39
+
40
+ const ISSUE_URL = /^https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/issues\/\d+$/;
41
+
42
+ // state.json `filedIssues`: [{ item, title, url, filedAt }], one entry per issue the user said yes to. Pure: returns the new list.
43
+ export function addFiledIssue(list = [], { item, title, url, filedAt = new Date().toISOString() }, { home, env = process.env } = {}) {
44
+ if (!ISSUE_URL.test(url)) throw new Error(`not a GitHub issue URL: ${url}`);
45
+ if (list.some((f) => f.url === url)) return list;
46
+ const clean = (t) => redactText(t, { home, env });
47
+ return [...list, { item: clean(item), title: clean(title), url, filedAt }];
48
+ }
@@ -0,0 +1,319 @@
1
+ // File operations: plan each change without touching disk, then apply with backups.
2
+ // Three action kinds:
3
+ // file - a whole file lean-agents owns (rules, agent definitions, loaders)
4
+ // json - edits to a JSON/JSONC file the user owns; comments and formatting survive
5
+ // block - a marked block inside a text file the user owns (CLAUDE.md, AGENTS.md);
6
+ // toml: true uses # markers and puts the block first, so its keys stay top-level;
7
+ // id: '<name>' uses # markers named by id (shell rc files: several blocks per file, and HTML markers break the shell)
8
+ import fs from 'node:fs';
9
+ import path from 'node:path';
10
+ import crypto from 'node:crypto';
11
+ import { parse, modify, applyEdits, findNodeAtLocation, parseTree } from 'jsonc-parser';
12
+
13
+ // Rename that waits out a file another process holds for a moment (Windows antivirus or indexer: EBUSY, EPERM, EACCES on a file
14
+ // just written). Retries `tries` times, `ms` apart; if it still fails, the error says so and keeps its code.
15
+ const waitMs = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
16
+ export function renameRetry(from, to, { rename = fs.renameSync, sleep = waitMs, tries = 8, ms = 250 } = {}) {
17
+ for (let i = 1; ; i++) {
18
+ try { return rename(from, to); } catch (e) {
19
+ if (!['EBUSY', 'EPERM', 'EACCES'].includes(e.code)) throw e;
20
+ if (i >= tries) throw Object.assign(new Error(`${e.message} (still locked after ${tries} tries over ${Math.round(((tries - 1) * ms) / 1000)} s: another program holds it; close it and try again)`), { code: e.code });
21
+ sleep(ms);
22
+ }
23
+ }
24
+ }
25
+
26
+ export const OWNED_MARK = 'managed by lean-agents';
27
+ const BLOCK_START = '<!-- lean-agents:start -->';
28
+ const BLOCK_END = '<!-- lean-agents:end -->';
29
+ const TOML_START = '# lean-agents:start';
30
+ const TOML_END = '# lean-agents:end';
31
+ const FORMAT = { formattingOptions: { insertSpaces: true, tabSize: 2, eol: '\n' } };
32
+
33
+ export const sha = (text) => crypto.createHash('sha256').update(text).digest('hex');
34
+ const read = (p) => (fs.existsSync(p) ? fs.readFileSync(p, 'utf8') : null);
35
+
36
+ // The mark counts only in the first lines (a skill's frontmatter pushes it past line 5), so a user file that merely mentions it stays theirs.
37
+ const OWNED_LINES = 10;
38
+ export const hasMark = (text) => text.split('\n', OWNED_LINES).join('\n').includes(OWNED_MARK);
39
+
40
+ const realRoots = (roots) => roots.filter(Boolean).map((r) => { try { return fs.realpathSync(r); } catch { return path.resolve(r); } });
41
+ const within = (child, root) => { const rel = path.relative(root, child); return !rel.startsWith('..') && !path.isAbsolute(rel); };
42
+ const isLink = (p) => { try { return fs.lstatSync(p).isSymbolicLink(); } catch { return false; } };
43
+
44
+ // Why a target must not be written, or null. A symlinked target or a real parent outside the roots is never touched (edit by hand).
45
+ export function unsafe(target, roots) {
46
+ if (isLink(target)) {
47
+ let real = '?';
48
+ try { real = fs.realpathSync(target); } catch { /* dangling link */ }
49
+ return `symlink to ${real}; edit by hand`;
50
+ }
51
+ if (!roots?.length) return null;
52
+ let dir = path.dirname(path.resolve(target));
53
+ for (;;) {
54
+ try { dir = fs.realpathSync(dir); break; } catch { /* not created yet: check the nearest existing parent */ }
55
+ const up = path.dirname(dir);
56
+ if (up === dir) break;
57
+ dir = up;
58
+ }
59
+ return realRoots(roots).some((r) => within(dir, r)) ? null : 'outside home and project';
60
+ }
61
+
62
+ // Backups can hold secrets from the user's config: owner-only files in owner-only dirs.
63
+ export function writePrivate(file, text) {
64
+ fs.writeFileSync(file, text, { mode: 0o600 });
65
+ fs.chmodSync(file, 0o600);
66
+ }
67
+ export const dropBackups = (dir) => fs.rmSync(dir, { recursive: true, force: true });
68
+ export function privateDir(dir, stop) {
69
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
70
+ for (let d = dir; ; d = path.dirname(d)) {
71
+ fs.chmodSync(d, 0o700);
72
+ if (d === stop || path.dirname(d) === d) break;
73
+ }
74
+ }
75
+
76
+ function getAt(text, keyPath) {
77
+ const tree = parseTree(text);
78
+ if (!tree) return undefined;
79
+ const node = findNodeAtLocation(tree, keyPath);
80
+ return node === undefined ? undefined : parse(text.slice(node.offset, node.offset + node.length));
81
+ }
82
+
83
+ // True when `current` is the old shape in `legacy` (`*` in a string is a wildcard, `{semver}` is digits.digits.digits).
84
+ function isLegacy(current, legacy = []) {
85
+ const eq = (a, b) => typeof b === 'string' && typeof a === 'string' ? new RegExp(`^${b.split('*').map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('.*').replace(/\\\{semver\\\}/g, '\\d+\\.\\d+\\.\\d+')}$`).test(a)
86
+ : a && b && typeof a === 'object' && typeof b === 'object' ? Object.keys(a).length === Object.keys(b).length && Object.keys(b).every((k) => eq(a[k], b[k])) : a === b;
87
+ return legacy.some((l) => eq(current, l));
88
+ }
89
+
90
+ // Package name of an npm plugin spec: 'pkg@1.2.3' and '@scope/pkg@1.2.3' lose the version.
91
+ const pkgName = (v) => (typeof v === 'string' ? v.replace(/(?!^)@[^@/]*$/, '') : v);
92
+
93
+ // Returns { text, applied: [edit], kept: [{path, value}] }.
94
+ // `owned`: arrayAdd edits an earlier run recorded in state.json for this file, so a past pin counts as ours.
95
+ export function applyJsonEdits(original, edits, owned = []) {
96
+ let text = original && original.trim() ? original : '{}\n';
97
+ const applied = [];
98
+ const kept = [];
99
+ for (const e of edits) {
100
+ const current = getAt(text, e.path);
101
+ if (e.mode === 'arrayAdd') {
102
+ const list = Array.isArray(current) ? current : [];
103
+ if (list.some((v) => JSON.stringify(v) === JSON.stringify(e.value))) continue;
104
+ if (e.legacy) {
105
+ // Pinned plugin spec: an exact legacy value, or a pin we recorded earlier, becomes the pinned one in place; any
106
+ // other entry for the same package is the user's own choice, so it stays and nothing is added.
107
+ const wrote = (v) => owned.some((o) => o.mode === 'arrayAdd' && JSON.stringify(o.path) === JSON.stringify(e.path) && o.value === v && pkgName(v) === pkgName(e.value));
108
+ const old = list.findIndex((v) => e.legacy.includes(v) || wrote(v));
109
+ if (old >= 0) {
110
+ text = applyEdits(text, modify(text, [...e.path, old], e.value, FORMAT));
111
+ applied.push(e);
112
+ continue;
113
+ }
114
+ const own = list.find((v) => pkgName(v) === pkgName(e.value));
115
+ if (own !== undefined) { kept.push({ path: e.path, value: own }); continue; }
116
+ }
117
+ const target = Array.isArray(current) ? [...e.path, -1] : e.path;
118
+ const value = Array.isArray(current) ? e.value : [e.value];
119
+ text = applyEdits(text, modify(text, target, value, { ...FORMAT, isArrayInsertion: true }));
120
+ applied.push(e);
121
+ continue;
122
+ }
123
+ if (e.mode === 'remove') {
124
+ // Drops the key; `previous` (recorded by plan) lets undo write it back.
125
+ if (current === undefined) continue;
126
+ text = applyEdits(text, modify(text, e.path, undefined, FORMAT));
127
+ applied.push(e);
128
+ continue;
129
+ }
130
+ if (current !== undefined) {
131
+ if (JSON.stringify(current) === JSON.stringify(e.value)) continue;
132
+ if (e.mode !== 'set' && !(e.mode === 'upgradeIf' && isLegacy(current, e.legacy))) {
133
+ kept.push({ path: e.path, value: current });
134
+ continue;
135
+ }
136
+ }
137
+ text = applyEdits(text, modify(text, e.path, e.value, FORMAT));
138
+ applied.push(e);
139
+ }
140
+ return { text, applied, kept };
141
+ }
142
+
143
+ // Undo edits recorded at install time, leaving every other key alone.
144
+ export function revertJsonEdits(text, applied) {
145
+ for (const e of [...applied].reverse()) {
146
+ if (e.mode === 'arrayAdd') {
147
+ const list = getAt(text, e.path);
148
+ if (!Array.isArray(list)) continue;
149
+ const i = list.findIndex((v) => JSON.stringify(v) === JSON.stringify(e.value));
150
+ if (i >= 0) text = applyEdits(text, modify(text, [...e.path, i], undefined, FORMAT));
151
+ } else if (e.keepIfChanged && JSON.stringify(getAt(text, e.path)) !== JSON.stringify(e.value)) {
152
+ // The user changed our value after install: it is theirs now.
153
+ continue;
154
+ } else if (e.previous === undefined) {
155
+ text = applyEdits(text, modify(text, e.path, undefined, FORMAT));
156
+ } else {
157
+ text = applyEdits(text, modify(text, e.path, e.previous, FORMAT));
158
+ }
159
+ }
160
+ // Drop containers lean-agents created that are now empty.
161
+ const parents = applied.flatMap((e) => e.createdParents ?? []).sort((a, b) => b.length - a.length);
162
+ for (const p of parents) {
163
+ const v = getAt(text, p);
164
+ const empty = Array.isArray(v) ? v.length === 0 : v && typeof v === 'object' && Object.keys(v).length === 0;
165
+ if (empty) text = applyEdits(text, modify(text, p, undefined, FORMAT));
166
+ }
167
+ return text;
168
+ }
169
+
170
+ const idMarks = (id) => [`# lean-agents:${id}:start`, `# lean-agents:${id}:end`];
171
+
172
+ export function setBlock(original, body, toml = false, id = undefined) {
173
+ const [open, close] = id ? idMarks(id) : toml ? [TOML_START, TOML_END] : [BLOCK_START, BLOCK_END];
174
+ const block = `${open}\n${body.trim()}\n${close}`;
175
+ const text = original ?? '';
176
+ const start = text.indexOf(open);
177
+ const end = text.indexOf(close);
178
+ if (start >= 0 && end > start) {
179
+ return text.slice(0, start) + block + text.slice(end + close.length);
180
+ }
181
+ if (toml) return text ? `${block}\n\n${text}` : `${block}\n`;
182
+ const sep = text && !text.endsWith('\n\n') ? (text.endsWith('\n') ? '\n' : '\n\n') : '';
183
+ return `${text}${sep}${block}\n`;
184
+ }
185
+
186
+ export function removeBlock(text, id = undefined) {
187
+ for (const [open, close] of id ? [idMarks(id)] : [[BLOCK_START, BLOCK_END], [TOML_START, TOML_END]]) {
188
+ const start = text.indexOf(open);
189
+ const end = text.indexOf(close);
190
+ if (start < 0 || end < start) continue;
191
+ const head = text.slice(0, start);
192
+ const tail = text.slice(end + close.length).replace(/^\n+/, '');
193
+ // A block between two others leaves one blank line, not the separators of both.
194
+ const rest = tail ? head.replace(/\n*$/, head ? '\n\n' : '') + tail : head;
195
+ return rest.replace(/\n{3,}$/, '\n\n').replace(/^\n+$/, '');
196
+ }
197
+ return text;
198
+ }
199
+
200
+ // Compute what each action would do. Pure apart from reading files.
201
+ // `prior`: the `files` entries of the last state.json, to tell our earlier edits from the user's.
202
+ export function plan(actions, roots = [], prior = []) {
203
+ return actions.map((a) => {
204
+ const blocked = unsafe(a.path, roots);
205
+ if (blocked) return { ...a, before: null, after: null, status: 'skip', note: blocked };
206
+ const before = read(a.path);
207
+ let after;
208
+ let note = '';
209
+ let applied;
210
+ let keptKeys;
211
+ if (a.kind === 'file') {
212
+ if (before !== null && before !== a.content && !hasMark(before) && !a.force) {
213
+ return { ...a, before, after: before, status: 'skip', note: 'exists and is not managed by lean-agents' };
214
+ }
215
+ after = a.content;
216
+ } else if (a.kind === 'json') {
217
+ if (before !== null && parse(before, [], { allowTrailingComma: true }) === undefined) {
218
+ return { ...a, before, after: before, status: 'skip', note: 'could not parse; edit by hand' };
219
+ }
220
+ const absent = (keyPath) => before === null || getAt(before, keyPath) === undefined;
221
+ const edits = a.edits.map((e) => {
222
+ const depth = e.mode === 'arrayAdd' ? e.path.length : e.path.length - 1;
223
+ const createdParents = [];
224
+ for (let k = 1; k <= depth; k++) if (absent(e.path.slice(0, k))) createdParents.push(e.path.slice(0, k));
225
+ const previous = before === null ? undefined : getAt(before, e.path);
226
+ // An upgraded legacy entry has no user value to restore: uninstall removes it.
227
+ const upgraded = e.mode === 'upgradeIf' && isLegacy(previous, e.legacy);
228
+ return { ...e, previous: upgraded ? undefined : previous, upgraded, createdParents };
229
+ });
230
+ const owned = prior.filter((f) => f.path === a.path).flatMap((f) => f.applied ?? []);
231
+ const r = applyJsonEdits(before, edits, owned);
232
+ after = r.text;
233
+ applied = r.applied;
234
+ keptKeys = r.kept.map((k) => k.path.join('.'));
235
+ if (r.kept.length) note = `kept your values for: ${r.kept.map((k) => k.path.join('.')).join(', ')}`;
236
+ } else if (a.kind === 'block') {
237
+ after = setBlock(before, a.body, a.toml, a.id);
238
+ }
239
+ const status = before === null ? 'create' : before === after ? 'unchanged' : 'modify';
240
+ // A file lean-agents created and nobody edited since holds nothing of the user's: a rerun needs no backup of it.
241
+ const mine = prior.filter((f) => f.path === a.path);
242
+ const noBackup = before !== null && mine.some((f) => f.created) && sha(before) === mine.at(-1).hash;
243
+ return { ...a, before, after, applied, status, note, keptKeys, noBackup };
244
+ });
245
+ }
246
+
247
+ export function describe(planned, home) {
248
+ const rel = (p) => (p === home || p.startsWith(home + path.sep) ? `~${p.slice(home.length)}` : p);
249
+ return planned
250
+ .map((p) => ` ${p.status.padEnd(9)} ${rel(p.path)}${p.note ? ` (${p.note})` : ''}`)
251
+ .join('\n');
252
+ }
253
+
254
+ // Write planned changes. Returns state entries for uninstall; a caller that passes `entries` keeps what was written if a later write throws.
255
+ export function apply(planned, backupDir, home, roots = [home], entries = []) {
256
+ for (const p of planned) {
257
+ if (p.status === 'skip' || p.status === 'unchanged') continue;
258
+ const blocked = unsafe(p.path, roots);
259
+ if (blocked) throw new Error(`refusing to write ${p.path}: ${blocked}`);
260
+ let backup = null;
261
+ if (p.before !== null && !p.noBackup) {
262
+ const rel = home && (p.path === home || p.path.startsWith(home + path.sep)) ? path.relative(home, p.path) : p.path.replace(/^[A-Za-z]:/, '').replace(/^[\\/]+/, '');
263
+ backup = path.join(backupDir, rel);
264
+ privateDir(path.dirname(backup), path.dirname(backupDir));
265
+ writePrivate(backup, p.before);
266
+ }
267
+ // The folders this write creates, deepest first: undo removes them again once they are empty (#223).
268
+ const dirs = [];
269
+ for (let d = path.dirname(p.path); !fs.existsSync(d); d = path.dirname(d)) dirs.push(d);
270
+ fs.mkdirSync(path.dirname(p.path), { recursive: true });
271
+ entries.push({ path: p.path, kind: p.kind, created: p.before === null, backup, hash: sha(p.after), applied: p.applied, noRestore: p.applied?.some((e) => e.upgraded), keepEmpty: p.keepEmpty, ...(p.id && { id: p.id }), ...(dirs.length && { dirs }) });
272
+ fs.writeFileSync(p.path, p.after);
273
+ }
274
+ return entries;
275
+ }
276
+
277
+ // Only empty folders: a file the user added since keeps its folder.
278
+ function removeEmptyDirs(dirs = []) {
279
+ for (const d of dirs) try { fs.rmdirSync(d); } catch { return; }
280
+ }
281
+
282
+ // Undo state entries. If the user edited a file after install, remove only our parts.
283
+ export function undo(entries, roots = []) {
284
+ const report = [];
285
+ for (const e of [...entries].reverse()) {
286
+ const blocked = unsafe(e.path, roots);
287
+ if (blocked) { report.push(['left (symlink)', e.path]); continue; }
288
+ const now = read(e.path);
289
+ if (now === null) { removeEmptyDirs(e.dirs); continue; }
290
+ const untouched = sha(now) === e.hash;
291
+ if (untouched && e.created) {
292
+ fs.rmSync(e.path);
293
+ report.push(['removed', e.path]);
294
+ removeEmptyDirs(e.dirs);
295
+ } else if (untouched && e.backup && !e.noRestore && fs.existsSync(e.backup)) {
296
+ fs.writeFileSync(e.path, fs.readFileSync(e.backup, 'utf8'));
297
+ report.push(['restored', e.path]);
298
+ } else if (e.kind === 'json') {
299
+ let text = revertJsonEdits(now, e.applied ?? []);
300
+ const left = parse(text, [], { allowTrailingComma: true });
301
+ if (e.created && left && typeof left === 'object' && !Object.keys(left).length) {
302
+ fs.rmSync(e.path);
303
+ report.push(['removed', e.path]);
304
+ removeEmptyDirs(e.dirs);
305
+ continue;
306
+ }
307
+ // A tool that rejects a file without its container key (Copilot: "mcpServers: Required") keeps it empty.
308
+ for (const key of e.keepEmpty ?? []) if (getAt(text, key) === undefined) text = applyEdits(text, modify(text, key, {}, FORMAT));
309
+ fs.writeFileSync(e.path, text);
310
+ report.push(['reverted our keys', e.path]);
311
+ } else if (e.kind === 'block') {
312
+ fs.writeFileSync(e.path, removeBlock(now, e.id));
313
+ report.push(['removed our block', e.path]);
314
+ } else {
315
+ report.push(['left (you edited it)', e.path]);
316
+ }
317
+ }
318
+ return report;
319
+ }
@@ -0,0 +1,42 @@
1
+ // GSD Core (opt-in). One upstream install per runtime; ~/.gsd/defaults.json gets per-agent
2
+ // models from profiles/<name>/gsd-defaults.json. The json action backs that file up first.
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { loadProfile, modelFor } from './render.mjs';
6
+ import { npmSpec } from './pins.mjs';
7
+ import { toolEnv } from './node-runtime.mjs';
8
+
9
+ const PACKAGE = npmSpec('gsd-core');
10
+ const FLAGS = { claude: '--claude', 'opencode-v1': '--opencode', 'opencode-v2': '--opencode', 'copilot-cli': '--copilot', antigravity: '--antigravity', cursor: '--cursor' };
11
+
12
+ export function gsdProfileName(o) {
13
+ // --profile only selects OpenCode models; its IDs mean nothing to the other runtimes.
14
+ if (o.profile && o.agents.some((a) => a.startsWith('opencode'))) return o.profile;
15
+ if (o.agents.includes('copilot-cli')) return 'github-copilot';
16
+ return o.agents.includes('claude') ? 'claude-subscription' : null;
17
+ }
18
+
19
+ export function gsdPlan(root, home, o) {
20
+ for (const a of o.agents.filter((x) => !FLAGS[x])) console.log(`GSD Core has no installer for ${a}: skipped.`);
21
+ // On its own Node, npx runs from that Node and PATH leads with it, so the hooks GSD writes name this Node (they use process.execPath).
22
+ const tn = o.toolNode;
23
+ const npx = tn ? [tn.node, tn.npxCli] : ['npx'];
24
+ const commands = [...new Set(o.agents.map((a) => FLAGS[a]).filter(Boolean))].map((flag) => ({
25
+ tool: 'gsd',
26
+ desc: `GSD Core (${flag.slice(2)})`,
27
+ run: [[...npx, '-y', PACKAGE, flag, '--global']],
28
+ undo: [[...npx, '-y', PACKAGE, flag, '--global', '--uninstall']],
29
+ ...(tn && { env: toolEnv(tn) }),
30
+ }));
31
+ const name = gsdProfileName(o);
32
+ const file = name && path.join(root, 'profiles', name, 'gsd-defaults.json');
33
+ if (!file || !fs.existsSync(file)) return { actions: [], commands };
34
+ const profile = loadProfile(root, name);
35
+ // shortcut: one model map for every runtime, use model_profile_overrides if mixing runtimes matters.
36
+ const bare = !o.agents.some((a) => a.startsWith('opencode'));
37
+ const edits = Object.entries(JSON.parse(fs.readFileSync(file, 'utf8')).model_overrides).map(([agent, tier]) => {
38
+ const model = modelFor(profile, tier).model;
39
+ return { path: ['model_overrides', agent], value: bare ? model.replace('github-copilot/', '') : model, mode: 'setIfAbsent' };
40
+ });
41
+ return { actions: [{ kind: 'json', path: path.join(home, '.gsd', 'defaults.json'), edits }], commands };
42
+ }
@@ -0,0 +1,196 @@
1
+ // Read-only inventory of what is already on the machine: which Node runs each registered MCP command, which
2
+ // pinned npm packages sit in which nvm Node, and which skill folders are read twice. Never writes; `home`, `env`,
3
+ // `platform` and `fsx` are passed in so tests never read the real machine (#104 points 4-5, #132).
4
+ import fs from 'node:fs';
5
+ import { spawn } from 'node:child_process';
6
+ import path from 'node:path';
7
+ import { createHash } from 'node:crypto';
8
+ import { PINS } from './pins.mjs';
9
+ import { configHome, envDir } from './system.mjs';
10
+ import { configPath } from './adapters/opencode-v2.mjs';
11
+ import { vscodeUserDir } from './adapters/vscode-copilot.mjs';
12
+ import { mcpServers } from './migrate.mjs';
13
+ import { installedNodes, satisfies } from './node-runtime.mjs';
14
+
15
+ const j = path.join;
16
+
17
+ // Files that hold MCP servers per client, as { client, file, keyPath }. Same `~` paths on every OS (proven for Windows by #78).
18
+ // shortcut: MCP files only; hooks, plugins and OpenCode data come with --adopt. OpenCode 1.x keeps servers under `mcp`, 2.x under `mcp.servers`.
19
+ export function clients(home) {
20
+ const oc = configPath(j(configHome(home), 'opencode'));
21
+ const code = vscodeUserDir(home);
22
+ const insiders = j(path.dirname(path.dirname(code)), 'Code - Insiders', 'User');
23
+ return [
24
+ { client: 'claude', file: j(home, '.claude.json'), keyPath: ['mcpServers'] },
25
+ { client: 'cursor', file: j(home, '.cursor', 'mcp.json'), keyPath: ['mcpServers'] },
26
+ { client: 'vscode', file: j(code, 'mcp.json'), keyPath: ['servers'] },
27
+ { client: 'vscode-insiders', file: j(insiders, 'mcp.json'), keyPath: ['servers'] }, // VERIFY: user dir
28
+ { client: 'opencode', file: oc, keyPath: ['mcp'] },
29
+ { client: 'opencode', file: oc, keyPath: ['mcp', 'servers'] },
30
+ { client: 'copilot-cli', file: j(envDir(home, 'COPILOT_HOME', j(home, '.copilot')), 'mcp-config.json'), keyPath: ['mcpServers'] },
31
+ ];
32
+ }
33
+
34
+ const VERSION_DIR = /[\\/]v(\d+\.\d+\.\d+)(?=[\\/])/;
35
+
36
+ // How one registered command picks its Node.
37
+ // style: absolute (full path to node) · symlink (an nvm "current" link that moves with `nvm use`) · path (bare `node`, first on PATH)
38
+ // · npx-path (bare `npx`, which runs the first `node` on PATH) · npx-absolute (full path to npx) · bun · other.
39
+ // node: the binary that will run, or null. nodeVersion: from the vX.Y.Z folder in its path (or its real path), else null.
40
+ export function launchOf(argv, { env = process.env, platform = process.platform, fsx = fs } = {}) {
41
+ const win = platform === 'win32';
42
+ const P = win ? path.win32 : path.posix;
43
+ const cmd = argv[0] ?? '';
44
+ const base = P.basename(cmd).replace(/\.(exe|cmd|bat)$/i, '').toLowerCase();
45
+ const exists = (p) => { try { return fsx.existsSync(p); } catch { return false; } };
46
+ const real = (p) => { try { return fsx.realpathSync(p); } catch { return p; } };
47
+ const key = Object.keys(env).find((k) => k.toUpperCase() === 'PATH');
48
+ const onPath = () => (env[key] ?? '').split(win ? ';' : ':').filter(Boolean).map((d) => P.join(d, win ? 'node.exe' : 'node')).find(exists) ?? null;
49
+ const links = win ? [env.NVM_SYMLINK ?? 'C:\\nodejs'] : env.NVM_DIR ? [P.join(env.NVM_DIR, 'current'), P.join(env.NVM_DIR, 'alias')] : [];
50
+ // Only nvm's own links move with `nvm use`; any other link (Homebrew's /opt/homebrew/bin/node) is a fixed path whose real path gives the version.
51
+ const isLink = (p) => links.some((l) => (win ? p.toLowerCase().startsWith(l.toLowerCase()) : p.startsWith(l)));
52
+ const versionOf = (p) => (VERSION_DIR.exec(p) ?? VERSION_DIR.exec(real(p)))?.[1] ?? null;
53
+ const out = (style, node) => ({ style, node, nodeVersion: node ? versionOf(node) : null });
54
+
55
+ if (!cmd) return out('url', null);
56
+ if (base === 'node') return P.isAbsolute(cmd) ? out(isLink(cmd) ? 'symlink' : 'absolute', cmd) : out('path', onPath());
57
+ if (base === 'npx') {
58
+ if (!P.isAbsolute(cmd)) return out('npx-path', onPath());
59
+ // npx.cmd (Windows) runs the node.exe beside it; the POSIX npx script runs the first `node` on PATH.
60
+ const beside = win ? P.join(P.dirname(cmd), 'node.exe') : null;
61
+ const node = beside && exists(beside) ? beside : onPath();
62
+ return out(win && node === beside && isLink(beside) ? 'symlink' : 'npx-absolute', node);
63
+ }
64
+ if (base === 'bun' || base === 'bunx') return out('bun', null);
65
+ return out('other', null);
66
+ }
67
+
68
+ // The npm pin an MCP command runs (key in core/pins.json), or null for a server of the user's own.
69
+ // Only pins with an `engines.node` range matter here; matching is by package name as a whole word.
70
+ export function pinOf(argv) {
71
+ for (const [key, p] of Object.entries(PINS)) {
72
+ if (p.kind !== 'npm' || !p.node || p.ciOnly || key === 'skills-cli') continue;
73
+ const re = new RegExp(`(^|[\\\\/])${p.source.replace(/[/.]/g, '\\$&')}([@\\\\/]|$)`);
74
+ if (argv.some((a) => re.test(a))) return key;
75
+ }
76
+ return null;
77
+ }
78
+
79
+ const FRAGILE = new Set(['symlink', 'path', 'npx-path', 'npx-absolute']);
80
+
81
+ // Verdict for one launch against its pin's Node range: 'ok' | 'wrong-node' | 'unknown' (version not readable without running it).
82
+ export function classify(launch, pinKey) {
83
+ const range = PINS[pinKey]?.node;
84
+ const status = !launch.nodeVersion ? 'unknown' : satisfies(launch.nodeVersion, range) ? 'ok' : 'wrong-node';
85
+ return { status, range, fragile: FRAGILE.has(launch.style) };
86
+ }
87
+
88
+ // Every registered MCP command that runs a pinned npm tool: { client, name, file, pin, launch, ...classify }. Args and env are never returned.
89
+ export function mcpLaunches(home, opts = {}) {
90
+ const seen = new Set();
91
+ const out = [];
92
+ for (const { client, file, keyPath } of clients(home)) {
93
+ for (const s of mcpServers(file, keyPath)) {
94
+ const pin = s.command.length ? pinOf(s.command) : null;
95
+ const id = `${file}\0${s.name}`;
96
+ if (!pin || seen.has(id)) continue;
97
+ seen.add(id);
98
+ const launch = launchOf(s.command, opts);
99
+ out.push({ client, name: s.name, file, pin, launch, ...classify(launch, pin) });
100
+ }
101
+ }
102
+ return out;
103
+ }
104
+
105
+ // Every pinned npm package installed under each nvm Node: { pin, name, version, node, prefix }.
106
+ export function npmCopies(nvm) {
107
+ const out = [];
108
+ for (const n of installedNodes(nvm)) {
109
+ for (const [pin, p] of Object.entries(PINS)) {
110
+ if (p.kind !== 'npm' || p.ciOnly) continue;
111
+ try {
112
+ const v = JSON.parse(fs.readFileSync(j(n.modules, ...p.source.split('/'), 'package.json'), 'utf8')).version;
113
+ out.push({ pin, name: p.source, version: v, node: n.version, prefix: n.dir });
114
+ } catch { /* not installed under this Node */ }
115
+ }
116
+ }
117
+ return out;
118
+ }
119
+
120
+ // Skill folders an agent reads, in no particular order. Sources and dates: docs/compatibility.md "Skill folders".
121
+ export function skillDirs(agent, home) {
122
+ const claude = j(home, '.claude', 'skills');
123
+ const shared = j(home, '.agents', 'skills');
124
+ if (agent === 'claude') return [claude];
125
+ if (agent === 'cursor') return [j(home, '.cursor', 'skills'), shared];
126
+ if (agent === 'copilot') return [j(envDir(home, 'COPILOT_HOME', j(home, '.copilot')), 'skills'), shared];
127
+ if (agent.startsWith('opencode')) return [j(configHome(home), 'opencode', 'skills'), shared, claude];
128
+ return [];
129
+ }
130
+
131
+ const SAFE_NAME = /^[A-Za-z0-9][\w.-]*$/;
132
+
133
+ // One hash over the paths and bytes of every file under a skill folder.
134
+ // A file or folder that cannot be read gives the marker 'unreadable' instead of an error, so --doctor never crashes on it.
135
+ const UNREADABLE = 'unreadable';
136
+ export function treeSha(dir, fsx) {
137
+ const h = createHash('sha256');
138
+ const walk = (d, rel) => {
139
+ for (const e of fsx.readdirSync(d, { withFileTypes: true }).sort((a, b) => (a.name < b.name ? -1 : 1))) {
140
+ const p = j(d, e.name);
141
+ if (e.isDirectory()) walk(p, `${rel}${e.name}/`);
142
+ else if (e.isFile()) h.update(`${rel}${e.name}\0`).update(fsx.readFileSync(p)).update('\0');
143
+ }
144
+ };
145
+ try { walk(dir, ''); } catch { return UNREADABLE; }
146
+ return h.digest('hex');
147
+ }
148
+
149
+ // Skills (a folder with SKILL.md) found in two or more of `dirs`. Two paths that are one folder (a link) are not a duplicate,
150
+ // unless `links` is set: --adopt counts them, because a client scanning both paths still meets the skill twice (#176).
151
+ export function duplicateSkills(dirs, fsx = fs, { links = false } = {}) {
152
+ const found = new Map();
153
+ for (const d of dirs) {
154
+ let names;
155
+ try { names = fsx.readdirSync(d); } catch { continue; }
156
+ for (const name of names.filter((n) => SAFE_NAME.test(n) && fsx.existsSync(j(d, n, 'SKILL.md')))) {
157
+ let real;
158
+ try { real = fsx.realpathSync(j(d, name)); } catch { real = j(d, name); }
159
+ const list = found.get(name) ?? [];
160
+ if (links || !list.some((x) => x.real === real)) list.push({ dir: d, real });
161
+ found.set(name, list);
162
+ }
163
+ }
164
+ return [...found].filter(([, l]) => l.length > 1).sort(([a], [b]) => (a < b ? -1 : 1)).map(([name, l]) => {
165
+ const shas = l.map((x) => treeSha(j(x.dir, name), fsx));
166
+ const unreadable = shas.includes(UNREADABLE);
167
+ // The load order is not documented and OpenCode 1.19's log shows the "existing" copy changing per skill (#78), so no winner is claimed.
168
+ return { name, dirs: l.map((x) => x.dir), shas, unreadable, linked: new Set(l.map((x) => x.real)).size < l.length, differs: unreadable || new Set(shas).size > 1, winner: 'unknown (load order)' };
169
+ });
170
+ }
171
+
172
+ // Start one MCP command as written and wait for its `initialize` reply: { ok, name, error }. `expect`: the serverInfo.name wanted.
173
+ // Spawned without a shell and with `env` as given, so the caller decides which Node leads PATH (#104, #106).
174
+ export function probeInitialize(argv, { env = process.env, expect, timeoutMs = 120000, stderr = 'inherit' } = {}) {
175
+ return new Promise((resolve) => {
176
+ const [cmd, ...args] = argv;
177
+ let done = false;
178
+ let buf = '';
179
+ const child = spawn(cmd, args, { stdio: ['pipe', 'pipe', stderr], env, windowsHide: true });
180
+ const end = (r) => { if (done) return; done = true; clearTimeout(timer); child.removeAllListeners('exit'); child.kill(); resolve(r); };
181
+ const timer = setTimeout(() => end({ ok: false, name: null, error: `no initialize reply in ${timeoutMs / 1000}s` }), timeoutMs);
182
+ child.on('error', (e) => end({ ok: false, name: null, error: e.message }));
183
+ child.on('exit', (code) => end({ ok: false, name: null, error: `exited (${code}) before replying to initialize` }));
184
+ child.stdout.on('data', (d) => {
185
+ buf += d;
186
+ for (const line of buf.split('\n')) {
187
+ let msg; try { msg = JSON.parse(line); } catch { continue; }
188
+ if (msg?.id !== 1) continue;
189
+ const name = msg.result?.serverInfo?.name ?? null;
190
+ end({ ok: expect ? name === expect : Boolean(msg.result), name, error: null });
191
+ }
192
+ });
193
+ child.stdin.on('error', () => {});
194
+ child.stdin.write(`${JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'lean-agents-ci', version: '0' } } })}\n`);
195
+ });
196
+ }
@@ -0,0 +1,30 @@
1
+ // The lean-update skill (skills/lean-update) installed for every selected agent through the Skills CLI.
2
+ import { skillSource, skillsCli } from './pins.mjs';
3
+
4
+ // Skills CLI `-a` name per lean-agents agent; Copilot CLI and VS Code Copilot share one.
5
+ const SKILLS_AGENT = {
6
+ claude: 'claude-code',
7
+ 'opencode-v1': 'opencode',
8
+ 'opencode-v2': 'opencode',
9
+ 'copilot-cli': 'github-copilot',
10
+ 'vscode-copilot': 'github-copilot',
11
+ cursor: 'cursor',
12
+ antigravity: 'antigravity-cli',
13
+ };
14
+
15
+ // CI installs the skill from the checkout (LEAN_AGENTS_SKILL_SOURCE) because the pinned release tag does not exist before release.
16
+ const source = () => process.env.LEAN_AGENTS_SKILL_SOURCE || skillSource('lean-update');
17
+
18
+ // Same repo and tag for every skill this repo ships; `coordinate` is opt-in, lean-update is always installed.
19
+ const skillCommands = (skill, agents) => [...new Set(agents.map((a) => SKILLS_AGENT[a]).filter(Boolean))].map((flag) => ({
20
+ tool: skill,
21
+ optional: true, // the pinned tag may not exist yet (before a release); the rest of the install still stands
22
+ desc: `${skill} skill for ${flag}`,
23
+ run: [['npx', '-y', skillsCli(), 'add', source(), '--skill', skill, '-a', flag, '-g', '-y']],
24
+ // Without -a: `remove -a` keeps ~/.agents/skills while another detected agent may share that folder.
25
+ undo: [['npx', '-y', skillsCli(), 'remove', skill, '-g', '-y']],
26
+ }));
27
+
28
+ export const leanUpdateCommands = (agents) => skillCommands('lean-update', agents);
29
+ export const coordinateCommands = (agents) => skillCommands('coordinate', agents);
30
+ export const leanMigrateCommands = (agents) => skillCommands('lean-migrate', agents);