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.
- package/CHANGELOG.md +407 -0
- package/LICENSE +21 -0
- package/README.es.md +560 -0
- package/README.md +559 -2
- package/core/AGENTS.es.md +60 -0
- package/core/AGENTS.md +60 -0
- package/core/README.md +8 -0
- package/core/agents/debug.md +14 -0
- package/core/agents/explore.md +13 -0
- package/core/agents/planner.md +14 -0
- package/core/agents/research.md +13 -0
- package/core/agents/review.md +13 -0
- package/core/copilot-usage-tui.js +189 -0
- package/core/mcp.json +38 -0
- package/core/pins.json +39 -0
- package/core/tiers.json +4 -0
- package/node_modules/@clack/core/LICENSE +9 -0
- package/node_modules/@clack/core/README.md +22 -0
- package/node_modules/@clack/core/dist/index.d.mts +503 -0
- package/node_modules/@clack/core/dist/index.mjs +1003 -0
- package/node_modules/@clack/core/package.json +63 -0
- package/node_modules/@clack/prompts/LICENSE +9 -0
- package/node_modules/@clack/prompts/README.md +396 -0
- package/node_modules/@clack/prompts/dist/index.d.mts +949 -0
- package/node_modules/@clack/prompts/dist/index.mjs +1423 -0
- package/node_modules/@clack/prompts/package.json +67 -0
- package/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
- package/node_modules/fast-string-truncated-width/dist/index.js +111 -0
- package/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
- package/node_modules/fast-string-truncated-width/dist/types.js +2 -0
- package/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
- package/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
- package/node_modules/fast-string-truncated-width/license +21 -0
- package/node_modules/fast-string-truncated-width/package.json +35 -0
- package/node_modules/fast-string-truncated-width/readme.md +59 -0
- package/node_modules/fast-string-width/dist/index.d.ts +4 -0
- package/node_modules/fast-string-width/dist/index.js +14 -0
- package/node_modules/fast-string-width/license +21 -0
- package/node_modules/fast-string-width/package.json +34 -0
- package/node_modules/fast-string-width/readme.md +42 -0
- package/node_modules/fast-wrap-ansi/LICENSE +23 -0
- package/node_modules/fast-wrap-ansi/README.md +26 -0
- package/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
- package/node_modules/fast-wrap-ansi/lib/main.js +218 -0
- package/node_modules/fast-wrap-ansi/package.json +51 -0
- package/node_modules/jsonc-parser/CHANGELOG.md +76 -0
- package/node_modules/jsonc-parser/LICENSE.md +21 -0
- package/node_modules/jsonc-parser/README.md +364 -0
- package/node_modules/jsonc-parser/SECURITY.md +41 -0
- package/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
- package/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
- package/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
- package/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
- package/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
- package/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
- package/node_modules/jsonc-parser/lib/esm/main.js +178 -0
- package/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
- package/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
- package/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
- package/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
- package/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
- package/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
- package/node_modules/jsonc-parser/lib/umd/main.js +194 -0
- package/node_modules/jsonc-parser/package.json +37 -0
- package/node_modules/sisteransi/license +21 -0
- package/node_modules/sisteransi/package.json +34 -0
- package/node_modules/sisteransi/readme.md +113 -0
- package/node_modules/sisteransi/src/index.js +58 -0
- package/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
- package/package.json +30 -4
- package/profiles/README.md +10 -0
- package/profiles/anthropic-api/gsd-defaults.json +26 -0
- package/profiles/anthropic-api.json +18 -0
- package/profiles/antigravity.json +12 -0
- package/profiles/claude-subscription/gsd-defaults.json +26 -0
- package/profiles/claude-subscription.json +17 -0
- package/profiles/github-copilot/gsd-defaults.json +26 -0
- package/profiles/github-copilot.json +17 -0
- package/profiles/openai-api/gsd-defaults.json +26 -0
- package/profiles/openai-api.json +17 -0
- package/profiles/opencode-go/gsd-defaults.json +26 -0
- package/profiles/opencode-go.json +17 -0
- package/profiles/vertex-gemini/gsd-defaults.json +26 -0
- package/profiles/vertex-gemini.json +18 -0
- package/scripts/adhd-skill.mjs +12 -0
- package/scripts/behavior-diff.sh +47 -0
- package/scripts/bump-pins.mjs +115 -0
- package/scripts/check-private.sh +52 -0
- package/scripts/check-readme.mjs +131 -0
- package/scripts/ci-download.sh +20 -0
- package/scripts/ci-install-opencode-v2.sh +6 -0
- package/scripts/ci-latest-report.mjs +38 -0
- package/scripts/ci-timing.mjs +61 -0
- package/scripts/copilot-context-mode.mjs +33 -0
- package/scripts/labels.sh +56 -0
- package/scripts/lean.mjs +1319 -0
- package/scripts/lib/adapters/antigravity.mjs +83 -0
- package/scripts/lib/adapters/claude.mjs +127 -0
- package/scripts/lib/adapters/copilot-cli.mjs +82 -0
- package/scripts/lib/adapters/cursor.mjs +60 -0
- package/scripts/lib/adapters/opencode-v1.mjs +79 -0
- package/scripts/lib/adapters/opencode-v2.mjs +216 -0
- package/scripts/lib/adapters/vscode-copilot.mjs +56 -0
- package/scripts/lib/adhd.mjs +28 -0
- package/scripts/lib/adopt.mjs +619 -0
- package/scripts/lib/agent-lifecycle.mjs +280 -0
- package/scripts/lib/backup-stamp.mjs +25 -0
- package/scripts/lib/copilot-usage.mjs +49 -0
- package/scripts/lib/doctor.mjs +279 -0
- package/scripts/lib/feedback.mjs +48 -0
- package/scripts/lib/fsops.mjs +319 -0
- package/scripts/lib/gsd.mjs +42 -0
- package/scripts/lib/inventory.mjs +196 -0
- package/scripts/lib/lean-update.mjs +30 -0
- package/scripts/lib/logins.mjs +28 -0
- package/scripts/lib/migrate.mjs +407 -0
- package/scripts/lib/network.mjs +119 -0
- package/scripts/lib/node-runtime.mjs +85 -0
- package/scripts/lib/opencode-backup.mjs +204 -0
- package/scripts/lib/opencode-upgrade.mjs +441 -0
- package/scripts/lib/opencode1.mjs +203 -0
- package/scripts/lib/parallel.mjs +270 -0
- package/scripts/lib/pins-diff.mjs +33 -0
- package/scripts/lib/pins.mjs +52 -0
- package/scripts/lib/plugin-health.mjs +191 -0
- package/scripts/lib/prereqs.mjs +203 -0
- package/scripts/lib/project.mjs +38 -0
- package/scripts/lib/redact.mjs +30 -0
- package/scripts/lib/render.mjs +101 -0
- package/scripts/lib/shell-path.mjs +22 -0
- package/scripts/lib/summary-data.mjs +30 -0
- package/scripts/lib/summary-html.mjs +159 -0
- package/scripts/lib/system.mjs +269 -0
- package/scripts/lib/terminals.mjs +316 -0
- package/scripts/lib/ui.mjs +34 -0
- package/scripts/lib/unverified.mjs +49 -0
- package/scripts/lib/update-plan.mjs +60 -0
- package/scripts/lib/upgrade.mjs +231 -0
- package/scripts/lib/verify-commit.mjs +16 -0
- package/scripts/lib/verify-prompt.mjs +46 -0
- package/scripts/lib/verify-sha256.mjs +20 -0
- package/scripts/lint-workflows.mjs +25 -0
- package/scripts/models-refresh.mjs +58 -0
- package/scripts/parallel.mjs +59 -0
- package/scripts/pins-latest.mjs +66 -0
- package/scripts/release.mjs +71 -0
- package/scripts/verify-pins.mjs +36 -0
- package/scripts/version-watch.mjs +124 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Antigravity CLI (`agy`) adapter. Paths confirmed on agy 1.4.12 in CI.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { OWNED_MARK } from '../fsops.mjs';
|
|
5
|
+
import { tierFor, modelFor } from '../render.mjs';
|
|
6
|
+
import { localServer } from './opencode-v2.mjs';
|
|
7
|
+
import { skillSource, skillsCli } from '../pins.mjs';
|
|
8
|
+
|
|
9
|
+
const TOOLS = {
|
|
10
|
+
'read-only': ['view_file', 'grep_search', 'find_by_name'],
|
|
11
|
+
'git-read': ['view_file', 'grep_search', 'find_by_name', 'run_command'],
|
|
12
|
+
'read-write': ['view_file', 'grep_search', 'find_by_name', 'run_command', 'write_to_file', 'replace_file_content'],
|
|
13
|
+
};
|
|
14
|
+
const WEB = ['search_web', 'read_url_content'];
|
|
15
|
+
|
|
16
|
+
export function renderAntigravityAgent(agent, profile) {
|
|
17
|
+
const tier = tierFor(profile, agent.name, agent.tier);
|
|
18
|
+
const tools = [...TOOLS[agent.access], ...(agent.name === 'research' ? WEB : [])];
|
|
19
|
+
return [
|
|
20
|
+
'---',
|
|
21
|
+
`# ${OWNED_MARK} (tier: ${tier})`,
|
|
22
|
+
`name: ${agent.name}`,
|
|
23
|
+
`description: ${agent.description}`,
|
|
24
|
+
'subagent: true',
|
|
25
|
+
`model: ${modelFor(profile, tier)?.model ?? 'inherit'}`,
|
|
26
|
+
'tools:',
|
|
27
|
+
...tools.map((t) => `- ${t}`),
|
|
28
|
+
'---',
|
|
29
|
+
'',
|
|
30
|
+
agent.body,
|
|
31
|
+
'',
|
|
32
|
+
].join('\n');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// #148: a skill folder is ours only if an earlier run recorded it in state.json (prior) or it did not exist before.
|
|
36
|
+
// An unmarked folder with the same name is the user's: it is neither overwritten nor removed.
|
|
37
|
+
const skills = (home, prior, tool, desc, repo, names) => {
|
|
38
|
+
const mine = names.filter((n) => prior.some((c) => c.desc === desc && c.undo?.some((u) => u.includes(n))) || !fs.existsSync(path.join(home, '.gemini', 'config', 'skills', n)));
|
|
39
|
+
for (const n of names.filter((x) => !mine.includes(x))) console.log(`Kept your existing Antigravity skill "${n}": lean-agents did not install it and will not remove it.`);
|
|
40
|
+
if (!mine.length) return null;
|
|
41
|
+
return {
|
|
42
|
+
tool,
|
|
43
|
+
desc,
|
|
44
|
+
run: [['npx', '-y', skillsCli(), 'add', repo, '--skill', ...mine, '-a', 'antigravity-cli', '-g', '-y']],
|
|
45
|
+
// Without -a: `remove -a` keeps ~/.agents/skills while another detected agent may share that folder.
|
|
46
|
+
undo: [['npx', '-y', skillsCli(), 'remove', ...mine, '-g', '-y']],
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export function antigravityAdapter({ home, core, profile, opts, rules, adhdCommand }) {
|
|
51
|
+
const dir = path.join(home, '.gemini', 'config');
|
|
52
|
+
const tools = opts.tools;
|
|
53
|
+
const actions = [{ kind: 'file', path: path.join(dir, 'rules', 'lean-agents.md'), content: rules }];
|
|
54
|
+
const commands = [];
|
|
55
|
+
|
|
56
|
+
for (const agent of core.agents) {
|
|
57
|
+
actions.push({ kind: 'file', path: path.join(dir, 'agents', `${agent.name}.md`), content: renderAntigravityAgent(agent, profile) });
|
|
58
|
+
}
|
|
59
|
+
const edits = [];
|
|
60
|
+
for (const name of ['serena', 'playwright'].filter((t) => tools.includes(t))) {
|
|
61
|
+
const [command, ...args] = localServer(core, name).command;
|
|
62
|
+
edits.push({ path: ['mcpServers', name], value: { command, args }, mode: 'setIfAbsent' });
|
|
63
|
+
}
|
|
64
|
+
if (edits.length) actions.push({ kind: 'json', path: path.join(dir, 'mcp_config.json'), edits });
|
|
65
|
+
|
|
66
|
+
if (tools.includes('rtk')) {
|
|
67
|
+
commands.push({ tool: 'rtk', desc: 'RTK plugin for Antigravity', run: [['rtk', 'init', '-g', '--agent', 'antigravity']], undo: [['rtk', 'init', '-g', '--agent', 'antigravity', '--uninstall']] });
|
|
68
|
+
}
|
|
69
|
+
if (tools.includes('context-mode')) {
|
|
70
|
+
// Context Mode 2.x dropped its Antigravity plugin and `context-mode setup --list` has no antigravity agent (2.1.4).
|
|
71
|
+
console.log('Context Mode has no Antigravity setup in v2: skipped. Check `context-mode setup --list` for support.');
|
|
72
|
+
}
|
|
73
|
+
if (tools.includes('caveman')) {
|
|
74
|
+
const c = skills(home, opts.prior ?? [], 'caveman', 'Caveman skills for Antigravity', skillSource('caveman'), ['caveman', 'caveman-compress', 'caveman-stats']);
|
|
75
|
+
if (c) commands.push(c);
|
|
76
|
+
}
|
|
77
|
+
if (tools.includes('i-have-adhd')) {
|
|
78
|
+
const c = skills(home, opts.prior ?? [], 'i-have-adhd', 'i-have-adhd skill for Antigravity', skillSource('i-have-adhd'), ['i-have-adhd']);
|
|
79
|
+
// adhdCommand rewrites every i-have-adhd copy, so it must not run over a kept user skill.
|
|
80
|
+
if (c) commands.push(c, adhdCommand);
|
|
81
|
+
}
|
|
82
|
+
return { actions, commands };
|
|
83
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Claude Code adapter. Files only under ~/.claude; MCP servers and plugins go through
|
|
2
|
+
// the `claude` CLI so ~/.claude.json (which holds auth) is never edited directly.
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { OWNED_MARK } from '../fsops.mjs';
|
|
5
|
+
import { tierFor, modelFor } from '../render.mjs';
|
|
6
|
+
import { privacyOf, updaterMode } from '../network.mjs';
|
|
7
|
+
import { statuslineScript } from '../copilot-usage.mjs';
|
|
8
|
+
import { marketplaceSource, skillSource, skillsCli } from '../pins.mjs';
|
|
9
|
+
|
|
10
|
+
// Also the key of its record in state.json: removing the entry replaces that record (empty undo), so --uninstall does not remove it twice.
|
|
11
|
+
const CTX_MCP = 'Context Mode MCP server (user scope)';
|
|
12
|
+
const TOOLS = {
|
|
13
|
+
'read-only': 'Read, Grep, Glob',
|
|
14
|
+
'git-read': 'Read, Grep, Glob, Bash(git diff:*), Bash(git log:*), Bash(git show:*), Bash(git status:*)',
|
|
15
|
+
'read-write': null,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Web tools are dropped when other outbound calls are off.
|
|
19
|
+
export function renderClaudeAgent(agent, profile, web) {
|
|
20
|
+
const tier = tierFor(profile, agent.name, agent.tier);
|
|
21
|
+
const model = modelFor(profile, tier)?.model ?? 'inherit';
|
|
22
|
+
let tools = TOOLS[agent.access];
|
|
23
|
+
if (agent.name === 'research' && tools && web) tools += ', WebFetch, WebSearch';
|
|
24
|
+
const lines = [
|
|
25
|
+
'---',
|
|
26
|
+
`# ${OWNED_MARK} (tier: ${tier})`,
|
|
27
|
+
`name: ${agent.name}`,
|
|
28
|
+
`description: ${agent.description}`,
|
|
29
|
+
`model: ${model}`,
|
|
30
|
+
];
|
|
31
|
+
if (tools) lines.push(`tools: ${tools}`);
|
|
32
|
+
lines.push('---', '', agent.body, '');
|
|
33
|
+
return lines.join('\n');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const plugin = (repo, id) => ({
|
|
37
|
+
run: [['claude', 'plugin', 'marketplace', 'add', repo], ['claude', 'plugin', 'install', id]],
|
|
38
|
+
undo: [['claude', 'plugin', 'uninstall', id]],
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export function claudeAdapter({ home, core, profile, opts, rulesPath, adhdCommand }) {
|
|
42
|
+
const dir = path.join(home, '.claude');
|
|
43
|
+
const actions = [];
|
|
44
|
+
const commands = [];
|
|
45
|
+
const tools = opts.tools;
|
|
46
|
+
|
|
47
|
+
actions.push({ kind: 'block', path: path.join(dir, 'CLAUDE.md'), body: `@${rulesPath}` });
|
|
48
|
+
for (const agent of core.agents) {
|
|
49
|
+
actions.push({ kind: 'file', path: path.join(dir, 'agents', `${agent.name}.md`), content: renderClaudeAgent(agent, profile, opts.network.outbound !== 'off') });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const env = { BASH_MAX_OUTPUT_LENGTH: '15000', CLAUDE_AUTOCOMPACT_PCT_OVERRIDE: '80' };
|
|
53
|
+
const edits = Object.entries(env).map(([k, v]) => ({ path: ['env', k], value: v, mode: 'setIfAbsent' }));
|
|
54
|
+
edits.unshift({ path: ['model'], value: profile?.main_model ?? 'sonnet', mode: 'setIfAbsent' });
|
|
55
|
+
const net = opts.network;
|
|
56
|
+
const off = [
|
|
57
|
+
...(net.telemetry === 'off' ? ['DISABLE_TELEMETRY', 'DISABLE_ERROR_REPORTING'] : []),
|
|
58
|
+
...(net.outbound === 'off' ? ['DISABLE_BUG_COMMAND'] : []),
|
|
59
|
+
// Also stops updates and telemetry, so only when every category is off.
|
|
60
|
+
...(privacyOf(net) === 'strict' ? ['CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC'] : []),
|
|
61
|
+
...(net.telemetry === 'off' ? ['DO_NOT_TRACK'] : []),
|
|
62
|
+
];
|
|
63
|
+
for (const k of off) edits.push({ path: ['env', k], value: '1', mode: 'set' });
|
|
64
|
+
// Managed installs update through --update: off unless the user already chose a value (network off forces it).
|
|
65
|
+
// A DISABLE_AUTOUPDATER already in the environment is the user's own choice, so it is respected too.
|
|
66
|
+
const updater = updaterMode(opts);
|
|
67
|
+
if (updater && !(updater === 'setIfAbsent' && (opts.env ?? process.env).DISABLE_AUTOUPDATER !== undefined)) edits.push({ path: ['env', 'DISABLE_AUTOUPDATER'], value: '1', mode: updater });
|
|
68
|
+
// Opt-in only (#304): experimental, and a session started with it resumes only with it on. User settings only; project settings ignore it.
|
|
69
|
+
if (tools.includes('code-mode')) edits.push({ path: ['env', 'CLAUDE_CODE_EXPERIMENTAL_CODE_MODE'], value: '1', mode: 'setIfAbsent' });
|
|
70
|
+
if (tools.includes('copilot-usage')) {
|
|
71
|
+
// Only when the user has no statusLine (setIfAbsent); uninstall removes it only while it is still ours. Forward slashes: Claude runs it through bash, also on Windows.
|
|
72
|
+
const script = path.join(dir, 'lean-copilot-usage-statusline.mjs');
|
|
73
|
+
actions.push({ kind: 'file', path: script, content: statuslineScript() });
|
|
74
|
+
const q = (p) => `"${p.replaceAll('\\', '/')}"`;
|
|
75
|
+
edits.push({ path: ['statusLine'], value: { type: 'command', command: `${q(process.execPath)} ${q(script)}` }, mode: 'setIfAbsent', keepIfChanged: true });
|
|
76
|
+
}
|
|
77
|
+
actions.push({ kind: 'json', path: path.join(dir, 'settings.json'), edits });
|
|
78
|
+
|
|
79
|
+
if (tools.includes('rtk')) {
|
|
80
|
+
commands.push({ tool: 'rtk', desc: 'RTK hook for Claude Code', run: [['rtk', 'init', '-g', '--auto-patch']], undo: [['rtk', 'init', '-g', '--uninstall']] });
|
|
81
|
+
}
|
|
82
|
+
if (tools.includes('context-mode') && opts.toolNode) {
|
|
83
|
+
// The plugin starts its server with the first `node` on PATH, so on an old Node it registers the absolute server instead (hooks and skills are lost).
|
|
84
|
+
commands.push({
|
|
85
|
+
tool: 'context-mode',
|
|
86
|
+
desc: CTX_MCP,
|
|
87
|
+
run: [['claude', 'mcp', 'add', '--scope', 'user', 'context-mode', '--', ...core.mcp['context-mode'].command]],
|
|
88
|
+
undo: [['claude', 'mcp', 'remove', '--scope', 'user', 'context-mode']],
|
|
89
|
+
skipIfOutput: { cmd: ['claude', 'mcp', 'get', 'context-mode'], ok: true },
|
|
90
|
+
});
|
|
91
|
+
} else if (tools.includes('context-mode')) {
|
|
92
|
+
// An earlier run on an old Node registered the absolute MCP server; the plugin runs its own, so lean-agents removes the one it added.
|
|
93
|
+
if ((opts.prior ?? []).some((c) => c.desc === CTX_MCP && c.undo?.length)) {
|
|
94
|
+
commands.push({ tool: 'context-mode', desc: CTX_MCP, run: [['claude', 'mcp', 'remove', '--scope', 'user', 'context-mode']], undo: [] });
|
|
95
|
+
}
|
|
96
|
+
commands.push({ tool: 'context-mode', desc: 'Context Mode plugin', ...plugin(marketplaceSource('context-mode-plugin'), 'context-mode@context-mode') });
|
|
97
|
+
}
|
|
98
|
+
if (tools.includes('ponytail')) {
|
|
99
|
+
commands.push({ tool: 'ponytail', desc: 'Ponytail plugin', ...plugin(marketplaceSource('ponytail-plugin'), 'ponytail@ponytail') });
|
|
100
|
+
}
|
|
101
|
+
if (tools.includes('i-have-adhd')) {
|
|
102
|
+
commands.push({ tool: 'i-have-adhd', desc: 'i-have-adhd plugin', ...plugin(marketplaceSource('i-have-adhd'), 'i-have-adhd@i-have-adhd') }, adhdCommand);
|
|
103
|
+
if (opts.adhdAlways) actions.push({ kind: 'file', path: path.join(dir, '.i-have-adhd-always'), content: '' , force: true });
|
|
104
|
+
}
|
|
105
|
+
for (const name of ['serena', 'playwright']) {
|
|
106
|
+
if (!tools.includes(name)) continue;
|
|
107
|
+
const server = core.mcp[name];
|
|
108
|
+
const cmd = [...server.command];
|
|
109
|
+
if (name === 'serena') cmd.splice(cmd.indexOf('start-mcp-server') + 1, 0, '--context', server.context['claude-code']);
|
|
110
|
+
commands.push({
|
|
111
|
+
tool: name,
|
|
112
|
+
desc: `${name} MCP server (user scope)`,
|
|
113
|
+
run: [['claude', 'mcp', 'add', '--scope', 'user', name, '--', ...cmd]],
|
|
114
|
+
undo: [['claude', 'mcp', 'remove', '--scope', 'user', name]],
|
|
115
|
+
skipIfOutput: { cmd: ['claude', 'mcp', 'get', name], ok: true },
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (tools.includes('caveman')) {
|
|
119
|
+
commands.push({
|
|
120
|
+
tool: 'caveman',
|
|
121
|
+
desc: 'Caveman skills for Claude Code',
|
|
122
|
+
run: [['npx', '-y', skillsCli(), 'add', skillSource('caveman'), '--skill', 'caveman', 'caveman-compress', 'caveman-stats', '-a', 'claude-code', '-g', '-y']],
|
|
123
|
+
undo: [['npx', '-y', skillsCli(), 'remove', 'caveman', 'caveman-compress', 'caveman-stats', '-a', 'claude-code', '-g', '-y']],
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return { actions, commands };
|
|
127
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// GitHub Copilot CLI adapter. Paths and keys confirmed on copilot 1.0.105 in CI.
|
|
2
|
+
// Copilot has no rule import, so the rendered rules go in a marked block.
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { OWNED_MARK } from '../fsops.mjs';
|
|
6
|
+
import { tierFor, modelFor } from '../render.mjs';
|
|
7
|
+
import { envDir } from '../system.mjs';
|
|
8
|
+
import { localServer } from './opencode-v2.mjs';
|
|
9
|
+
import { skillSource, skillsCli } from '../pins.mjs';
|
|
10
|
+
import { toolEnv } from '../node-runtime.mjs';
|
|
11
|
+
import { updaterMode } from '../network.mjs';
|
|
12
|
+
|
|
13
|
+
const CONTEXT_MODE_SCRIPT = fileURLToPath(new URL('../../copilot-context-mode.mjs', import.meta.url));
|
|
14
|
+
|
|
15
|
+
const TOOLS = {
|
|
16
|
+
'read-only': ['read', 'search'],
|
|
17
|
+
'git-read': ['read', 'search', 'execute'],
|
|
18
|
+
'read-write': null,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Web tools are dropped when other outbound calls are off.
|
|
22
|
+
export function renderCopilotAgent(agent, profile, web) {
|
|
23
|
+
const tier = tierFor(profile, agent.name, agent.tier);
|
|
24
|
+
const model = modelFor(profile, tier)?.model.replace('github-copilot/', '');
|
|
25
|
+
const tools = TOOLS[agent.access] && [...TOOLS[agent.access], ...(agent.name === 'research' && web ? ['web'] : [])];
|
|
26
|
+
const lines = ['---', `# ${OWNED_MARK} (tier: ${tier})`, `name: ${agent.name}`, `description: ${agent.description}`];
|
|
27
|
+
if (model) lines.push(`model: ${model}`);
|
|
28
|
+
if (tools) lines.push(`tools: ${JSON.stringify(tools)}`);
|
|
29
|
+
lines.push('---', '', agent.body, '');
|
|
30
|
+
return lines.join('\n');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const skills = (tool, desc, repo, names) => ({
|
|
34
|
+
tool,
|
|
35
|
+
desc,
|
|
36
|
+
run: [['npx', '-y', skillsCli(), 'add', repo, '--skill', ...names, '-a', 'github-copilot', '-g', '-y']],
|
|
37
|
+
// Without -a: `remove -a` keeps ~/.agents/skills while another detected agent may share that folder.
|
|
38
|
+
undo: [['npx', '-y', skillsCli(), 'remove', ...names, '-g', '-y']],
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export function copilotAdapter({ home, core, profile, opts, rules, adhdCommand }) {
|
|
42
|
+
const dir = envDir(home, 'COPILOT_HOME', path.join(home, '.copilot'));
|
|
43
|
+
const tools = opts.tools;
|
|
44
|
+
const actions = [{ kind: 'block', path: path.join(dir, 'copilot-instructions.md'), body: rules }];
|
|
45
|
+
const commands = [];
|
|
46
|
+
|
|
47
|
+
for (const agent of core.agents) {
|
|
48
|
+
actions.push({ kind: 'file', path: path.join(dir, 'agents', `${agent.name}.agent.md`), content: renderCopilotAgent(agent, profile, opts.network.outbound !== 'off') });
|
|
49
|
+
}
|
|
50
|
+
const edits = [];
|
|
51
|
+
for (const name of ['serena', 'playwright', 'playwright-extension'].filter((t) => tools.includes(t))) {
|
|
52
|
+
const [command, ...args] = localServer(core, name).command;
|
|
53
|
+
edits.push({ path: ['mcpServers', name], value: { type: 'local', command, args, tools: ['*'] }, mode: 'setIfAbsent' });
|
|
54
|
+
}
|
|
55
|
+
if (edits.length) actions.push({ kind: 'json', path: path.join(dir, 'mcp-config.json'), edits, keepEmpty: [['mcpServers']] });
|
|
56
|
+
// Managed installs update through --update: off unless the user already set `autoUpdate` (network off forces it).
|
|
57
|
+
const updater = updaterMode(opts);
|
|
58
|
+
if (updater) actions.push({ kind: 'json', path: path.join(dir, 'settings.json'), edits: [{ path: ['autoUpdate'], value: false, mode: updater }] });
|
|
59
|
+
|
|
60
|
+
if (tools.includes('rtk')) {
|
|
61
|
+
commands.push({ tool: 'rtk', desc: 'RTK hook for Copilot CLI', run: [['rtk', 'init', '-g', '--copilot']], undo: [['rtk', 'init', '-g', '--copilot', '--uninstall']] });
|
|
62
|
+
}
|
|
63
|
+
if (tools.includes('context-mode')) {
|
|
64
|
+
// Only the MCP server (`copilot mcp add`, which writes mcp-config.json itself); the npm package comes from the prerequisite step.
|
|
65
|
+
commands.push({
|
|
66
|
+
tool: 'context-mode',
|
|
67
|
+
desc: 'Context Mode MCP server for Copilot CLI',
|
|
68
|
+
run: [[opts.toolNode?.node ?? 'node', CONTEXT_MODE_SCRIPT]],
|
|
69
|
+
undo: [['copilot', 'mcp', 'remove', 'context-mode']],
|
|
70
|
+
// The script registers process.execPath, so it must run on the tool's Node and look for the package in that Node's prefix.
|
|
71
|
+
...(opts.toolNode && { env: { ...toolEnv(opts.toolNode), LEAN_CONTEXT_MODE_DIR: path.join(opts.toolNode.modules, 'context-mode') } }),
|
|
72
|
+
});
|
|
73
|
+
console.log('Context Mode hooks and skills for Copilot CLI are not installed: run `context-mode setup --print copilot-cli` and follow it.');
|
|
74
|
+
}
|
|
75
|
+
if (tools.includes('caveman')) {
|
|
76
|
+
commands.push(skills('caveman', 'Caveman skills for Copilot CLI', skillSource('caveman'), ['caveman', 'caveman-compress', 'caveman-stats']));
|
|
77
|
+
}
|
|
78
|
+
if (tools.includes('i-have-adhd')) {
|
|
79
|
+
commands.push(skills('i-have-adhd', 'i-have-adhd skill for Copilot CLI', skillSource('i-have-adhd'), ['i-have-adhd']), adhdCommand);
|
|
80
|
+
}
|
|
81
|
+
return { actions, commands };
|
|
82
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Cursor adapter (IDE and the `agent` CLI). Cursor keeps user rules in its settings UI only,
|
|
2
|
+
// so global rules are not written here; `--project` puts them in the repo's AGENTS.md.
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { OWNED_MARK } from '../fsops.mjs';
|
|
5
|
+
import { localServer, mcpEdit } from './opencode-v2.mjs';
|
|
6
|
+
import { hasProxy } from '../network.mjs';
|
|
7
|
+
import { skillSource, skillsCli } from '../pins.mjs';
|
|
8
|
+
|
|
9
|
+
// Model IDs differ from every profile, so subagents inherit the chat model.
|
|
10
|
+
export function renderCursorAgent(agent) {
|
|
11
|
+
return [
|
|
12
|
+
'---',
|
|
13
|
+
`# ${OWNED_MARK} (tier: ${agent.tier})`,
|
|
14
|
+
`name: ${agent.name}`,
|
|
15
|
+
`description: ${agent.description}`,
|
|
16
|
+
'model: inherit',
|
|
17
|
+
`readonly: ${agent.access !== 'read-write'}`,
|
|
18
|
+
'---',
|
|
19
|
+
'',
|
|
20
|
+
agent.body,
|
|
21
|
+
'',
|
|
22
|
+
].join('\n');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// `mcpServers` entries for a Cursor mcp.json, user or project.
|
|
26
|
+
export function cursorServers(core, tools) {
|
|
27
|
+
return ['serena', 'playwright', 'playwright-extension', 'context-mode'].filter((t) => tools.includes(t)).map((name) => {
|
|
28
|
+
return mcpEdit(['mcpServers', name], ([command, ...args]) => ({ command, args }), localServer(core, name).command, core.mcp[name].legacy);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const skills = (tool, desc, repo, names) => ({
|
|
33
|
+
tool,
|
|
34
|
+
desc,
|
|
35
|
+
run: [['npx', '-y', skillsCli(), 'add', repo, '--skill', ...names, '-a', 'cursor', '-g', '-y']],
|
|
36
|
+
// Without -a: `remove -a` keeps ~/.agents/skills while another detected agent may share that folder.
|
|
37
|
+
undo: [['npx', '-y', skillsCli(), 'remove', ...names, '-g', '-y']],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export function cursorAdapter({ home, core, opts, adhdCommand }) {
|
|
41
|
+
const dir = path.join(home, '.cursor');
|
|
42
|
+
const tools = opts.tools;
|
|
43
|
+
const actions = core.agents.map((agent) => ({ kind: 'file', path: path.join(dir, 'agents', `${agent.name}.md`), content: renderCursorAgent(agent) }));
|
|
44
|
+
const commands = [];
|
|
45
|
+
const edits = cursorServers(core, tools);
|
|
46
|
+
if (edits.length) actions.push({ kind: 'json', path: path.join(dir, 'mcp.json'), edits });
|
|
47
|
+
// Proxies such as Zscaler break the agent's HTTP/2 stream (#25). Only the flag is written, never a proxy value.
|
|
48
|
+
if (hasProxy()) actions.push({ kind: 'json', path: path.join(dir, 'cli-config.json'), edits: [{ path: ['network', 'useHttp1ForAgent'], value: true, mode: 'setIfAbsent' }] });
|
|
49
|
+
|
|
50
|
+
if (tools.includes('rtk')) {
|
|
51
|
+
commands.push({ tool: 'rtk', desc: 'RTK hook for Cursor', run: [['rtk', 'init', '-g', '--agent', 'cursor']], undo: [['rtk', 'init', '-g', '--agent', 'cursor', '--uninstall']] });
|
|
52
|
+
}
|
|
53
|
+
if (tools.includes('caveman')) {
|
|
54
|
+
commands.push(skills('caveman', 'Caveman skills for Cursor', skillSource('caveman'), ['caveman', 'caveman-compress', 'caveman-stats']));
|
|
55
|
+
}
|
|
56
|
+
if (tools.includes('i-have-adhd')) {
|
|
57
|
+
commands.push(skills('i-have-adhd', 'i-have-adhd skill for Cursor', skillSource('i-have-adhd'), ['i-have-adhd']), adhdCommand);
|
|
58
|
+
}
|
|
59
|
+
return { actions, commands };
|
|
60
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// OpenCode 1.x adapter (>=1.18.29). Keys checked against the 1.19.0 config schema; files
|
|
2
|
+
// and commands are shared with the 2.x adapter, only config keys differ.
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { configPath, dcpConfigAction, localServer, opencodeShared, profileEdits, shellEdit } from './opencode-v2.mjs';
|
|
5
|
+
import { OWNED_MARK } from '../fsops.mjs';
|
|
6
|
+
import { configHome } from '../system.mjs';
|
|
7
|
+
import { npmSpec } from '../pins.mjs';
|
|
8
|
+
import { updaterMode } from '../network.mjs';
|
|
9
|
+
|
|
10
|
+
// OpenCode 1.19's TUI runs server plugins in a Bun worker and never calls the factory in Orca's managed
|
|
11
|
+
// plugins/orca-opencode-status.js, so Orca shows no status. Loading it from a file under another name
|
|
12
|
+
// fixes that (issue #78). Worker only: headless `opencode run` already loads the managed file.
|
|
13
|
+
const ORCA_SHIM = `// ${OWNED_MARK}
|
|
14
|
+
// Lets Orca's status plugin run in OpenCode 1.x's TUI worker (lean-agents#78).
|
|
15
|
+
export const LeanOrcaStatusShim = async (ctx) => {
|
|
16
|
+
if (typeof Bun === 'undefined' || Bun.isMainThread) return {};
|
|
17
|
+
try {
|
|
18
|
+
const mod = await import('./orca-opencode-status.js');
|
|
19
|
+
// Orca's default export is the factory (ORCA_OPENCODE_PLUGIN_API=v1) or an { id, server } object.
|
|
20
|
+
const factory = typeof mod.default === 'function' ? mod.default : mod.default?.server ?? mod.OrcaOpenCodeStatusPlugin;
|
|
21
|
+
return (await factory?.(ctx)) ?? {};
|
|
22
|
+
} catch {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
// Windows only: the bug is seen on the Windows work PC and not reproduced on Linux or macOS in CI, where the
|
|
29
|
+
// shim would run Orca's plugin a second time.
|
|
30
|
+
export function orcaShimActions({ dir, terminals, platform = process.platform }) {
|
|
31
|
+
if (platform !== 'win32' || !terminals?.includes('orca')) return [];
|
|
32
|
+
return [{ kind: 'file', path: path.join(dir, 'plugins', 'lean-orca-status-shim.js'), content: ORCA_SHIM }];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function opencodeV1Adapter({ home, core, profile, opts, rulesPath }) {
|
|
36
|
+
const dir = path.join(configHome(home), 'opencode');
|
|
37
|
+
const tools = opts.tools;
|
|
38
|
+
const { actions, commands } = opencodeShared({ home, dir, core, profile, opts });
|
|
39
|
+
const edits = [
|
|
40
|
+
{ path: ['$schema'], value: 'https://opencode.ai/config.json', mode: 'setIfAbsent' },
|
|
41
|
+
{ path: ['instructions'], value: rulesPath, mode: 'arrayAdd' },
|
|
42
|
+
{ path: ['default_agent'], value: 'plan', mode: 'setIfAbsent' },
|
|
43
|
+
{ path: ['compaction', 'auto'], value: true, mode: 'setIfAbsent' },
|
|
44
|
+
{ path: ['compaction', 'reserved'], value: 40000, mode: 'setIfAbsent' },
|
|
45
|
+
...profileEdits(profile, 'agent'),
|
|
46
|
+
];
|
|
47
|
+
const shell = shellEdit(opts);
|
|
48
|
+
if (shell) edits.push(shell);
|
|
49
|
+
|
|
50
|
+
for (const name of ['serena', 'playwright', 'playwright-extension']) {
|
|
51
|
+
if (tools.includes(name)) edits.push({ path: ['mcp', name], value: localServer(core, name), mode: 'setIfAbsent' });
|
|
52
|
+
}
|
|
53
|
+
// Context Mode is plugin-only here: plugin plus MCP breaks OpenCode tool registration.
|
|
54
|
+
if (tools.includes('context-mode')) {
|
|
55
|
+
edits.push({ path: ['plugin'], value: npmSpec('context-mode'), mode: 'arrayAdd', legacy: ['context-mode'] });
|
|
56
|
+
commands.push({
|
|
57
|
+
tool: 'context-mode',
|
|
58
|
+
desc: 'Context Mode package for OpenCode',
|
|
59
|
+
run: [['npm', 'install', '-g', npmSpec('context-mode')]],
|
|
60
|
+
undo: [['npm', 'uninstall', '-g', 'context-mode']],
|
|
61
|
+
skipIfOutput: { cmd: ['npm', 'ls', '-g', 'context-mode'], ok: true },
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (opts.terminals?.includes('warp')) edits.push({ path: ['plugin'], value: npmSpec('warp-opencode'), mode: 'arrayAdd', legacy: ['@warp-dot-dev/opencode-warp', '@warp-dot-dev/opencode-warp@0.1.7'] });
|
|
65
|
+
actions.push(...orcaShimActions({ dir, terminals: opts.terminals, platform: opts.platform }));
|
|
66
|
+
if (tools.includes('ponytail')) edits.push({ path: ['plugin'], value: npmSpec('ponytail'), mode: 'arrayAdd', legacy: ['@dietrichgebert/ponytail'] });
|
|
67
|
+
if (tools.includes('dcp')) {
|
|
68
|
+
edits.push({ path: ['plugin'], value: npmSpec('opencode-dcp'), mode: 'arrayAdd', legacy: [] }); // any DCP entry already there is the user's: kept, nothing appended (#212)
|
|
69
|
+
actions.push(dcpConfigAction(dir, profile));
|
|
70
|
+
}
|
|
71
|
+
const net = opts.network;
|
|
72
|
+
if (net.outbound === 'off') edits.push({ path: ['share'], value: 'disabled', mode: 'set' });
|
|
73
|
+
// Managed installs update through --update: off unless the user already set `autoupdate` (network off forces it).
|
|
74
|
+
if (updaterMode(opts)) edits.push({ path: ['autoupdate'], value: false, mode: updaterMode(opts) });
|
|
75
|
+
if (net.telemetry === 'off') edits.push({ path: ['experimental', 'openTelemetry'], value: false, mode: 'set' });
|
|
76
|
+
if (net.outbound === 'off' && profile?.provider !== 'opencode') edits.push({ path: ['disabled_providers'], value: 'opencode', mode: 'arrayAdd' });
|
|
77
|
+
actions.push({ kind: 'json', path: configPath(dir), edits });
|
|
78
|
+
return { actions, commands };
|
|
79
|
+
}
|