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,316 @@
|
|
|
1
|
+
// Warp and Orca: detect the app, then plan the agent integrations for a user who already has it.
|
|
2
|
+
// The terminal apps themselves are never installed.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { which, quiet } from './system.mjs';
|
|
7
|
+
import { hasProxy } from './network.mjs';
|
|
8
|
+
import { skillSource, skillsCli, PINS } from './pins.mjs';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
|
|
11
|
+
const VERIFY = fileURLToPath(new URL('./verify-sha256.mjs', import.meta.url));
|
|
12
|
+
|
|
13
|
+
export const TERMINALS = ['warp', 'orca'];
|
|
14
|
+
// Skills CLI agent ids; VS Code Copilot reads ~/.copilot/skills like Copilot CLI.
|
|
15
|
+
const ORCA_SKILL_AGENT = { claude: 'claude-code', 'opencode-v1': 'opencode', 'opencode-v2': 'opencode', 'copilot-cli': 'github-copilot', 'vscode-copilot': 'github-copilot', cursor: 'cursor', antigravity: 'antigravity-cli' };
|
|
16
|
+
// Orca's hooks POST status to 127.0.0.1; Windows curl sends loopback to the proxy unless NO_PROXY lists it.
|
|
17
|
+
const LOOPBACK = ['localhost', '127.0.0.1', '::1'];
|
|
18
|
+
const ORCA_TELEMETRY_ENV = ['DO_NOT_TRACK', 'ORCA_TELEMETRY_DISABLED'];
|
|
19
|
+
const ps = (script) => ['powershell', '-NoProfile', '-NonInteractive', '-Command', script];
|
|
20
|
+
|
|
21
|
+
// `platform` and `env` are parameters so tests can fake an OS without touching the machine.
|
|
22
|
+
export function detectTerminals(home, { platform = process.platform, env = process.env, system = true } = {}) {
|
|
23
|
+
const has = (...paths) => paths.some((p) => p && fs.existsSync(p));
|
|
24
|
+
const found = [];
|
|
25
|
+
// `system` is false for a run with --home: it looks only inside it, so a throwaway HOME behaves the same on every machine.
|
|
26
|
+
const apps = platform === 'darwin' ? [path.join(home, 'Applications'), ...(system ? ['/Applications'] : [])] : [];
|
|
27
|
+
const local = platform === 'win32' && system ? env.LOCALAPPDATA : null;
|
|
28
|
+
// PATH lookups are system-wide, so they follow `system` too. Linux `orca` is the GNOME screen reader: not a signal.
|
|
29
|
+
// Windows install folders under Programs: VERIFY.
|
|
30
|
+
const onPath = (bin) => system && which(bin);
|
|
31
|
+
if (has(...apps.map((d) => path.join(d, 'Warp.app')), local && path.join(local, 'Programs', 'Warp')) || onPath('warp-terminal')) found.push('warp');
|
|
32
|
+
if (has(...apps.map((d) => path.join(d, 'Orca.app')), local && path.join(local, 'Programs', 'Orca')) || (platform !== 'linux' && onPath('orca'))) found.push('orca');
|
|
33
|
+
return found;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// --terminal value to a list; "both" and "none" are shorthands.
|
|
37
|
+
export function parseTerminal(v) {
|
|
38
|
+
if (v === 'both') return [...TERMINALS];
|
|
39
|
+
if (v === 'none') return [];
|
|
40
|
+
if (TERMINALS.includes(v)) return [v];
|
|
41
|
+
throw new Error('--terminal takes warp, orca, both or none');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Commands only: OpenCode plugin entries go into the OpenCode adapter's own json edit, because two
|
|
45
|
+
// json actions on one file would each start from the unedited text.
|
|
46
|
+
// `system` is false for --home runs: Windows user env changes are real-machine only.
|
|
47
|
+
export function terminalCommands({ home, terminals = [], installTerminals = [], agents = [], network = {}, platform = process.platform, env = process.env, system = true, readEnv = readWindowsEnv }) {
|
|
48
|
+
const commands = [];
|
|
49
|
+
|
|
50
|
+
const arch = platform === 'darwin' ? process.arch : 'x64';
|
|
51
|
+
const warpPin = PINS['warp-app'];
|
|
52
|
+
const orcaPin = PINS['orca-app'];
|
|
53
|
+
const canInstall = system && (platform === 'darwin' || platform === 'win32');
|
|
54
|
+
|
|
55
|
+
if (canInstall && installTerminals.includes('warp')) {
|
|
56
|
+
if (platform === 'darwin') {
|
|
57
|
+
commands.push({
|
|
58
|
+
tool: 'warp',
|
|
59
|
+
desc: 'Install Warp app',
|
|
60
|
+
skipIfExists: [path.join(home, 'Applications', 'Warp.app'), '/Applications/Warp.app'],
|
|
61
|
+
run: [['bash', '-c', 'if command -v brew >/dev/null 2>&1; then brew install --cask warp; else echo "Error: Homebrew is required to install Warp on macOS. Please install Warp manually from https://warp.dev" >&2; exit 1; fi']],
|
|
62
|
+
undo: [['bash', '-c', 'if command -v brew >/dev/null 2>&1; then brew uninstall --cask warp; fi']],
|
|
63
|
+
});
|
|
64
|
+
} else if (platform === 'win32') {
|
|
65
|
+
const url = warpPin.url['windows-x64'];
|
|
66
|
+
const sha = warpPin.sha256['windows-x64'];
|
|
67
|
+
const exe = path.join(os.tmpdir(), 'warp-installer.exe');
|
|
68
|
+
const local = env.LOCALAPPDATA;
|
|
69
|
+
commands.push({
|
|
70
|
+
tool: 'warp',
|
|
71
|
+
desc: 'Install Warp app',
|
|
72
|
+
skipIfExists: [`${local}\\Programs\\Warp`],
|
|
73
|
+
run: [
|
|
74
|
+
['curl', '-fsSL', '-o', exe, url],
|
|
75
|
+
['node', VERIFY, exe, sha],
|
|
76
|
+
[exe, '/CURRENTUSER', '/VERYSILENT']
|
|
77
|
+
],
|
|
78
|
+
always: [
|
|
79
|
+
ps(`if (Test-Path "${exe}") { Remove-Item "${exe}" }`)
|
|
80
|
+
],
|
|
81
|
+
// Inno Setup cancels silently while Warp runs and relaunches from %TEMP%; refuse, then wait for it.
|
|
82
|
+
undo: [ps(`$u = "$env:LOCALAPPDATA\\Programs\\Warp\\unins000.exe"; if (-not (Test-Path $u)) { exit 0 }; if (Get-Process -Name warp -ErrorAction SilentlyContinue) { Write-Error 'Warp is running: close it, then run --uninstall again'; exit 1 }; $p = Start-Process -FilePath $u -ArgumentList '/VERYSILENT','/SUPPRESSMSGBOXES','/NORESTART' -Wait -PassThru; for ($i = 0; $i -lt 30 -and (Test-Path $u); $i++) { Start-Sleep 2 }; if (Test-Path $u) { Write-Error "Warp uninstaller exit code $($p.ExitCode)"; exit 1 }`)],
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (canInstall && installTerminals.includes('orca')) {
|
|
88
|
+
if (platform === 'darwin') {
|
|
89
|
+
const key = arch === 'arm64' ? 'darwin-arm64' : 'darwin-x64';
|
|
90
|
+
const url = orcaPin.url[key];
|
|
91
|
+
const sha = orcaPin.sha256[key];
|
|
92
|
+
const script = `set -e
|
|
93
|
+
DIR=$(mktemp -d)
|
|
94
|
+
MOUNT="$DIR/mount"
|
|
95
|
+
MOUNTED=0
|
|
96
|
+
cleanup() {
|
|
97
|
+
if [ "$MOUNTED" -eq 1 ]; then
|
|
98
|
+
hdiutil detach "$MOUNT" -force >/dev/null 2>&1 || true
|
|
99
|
+
fi
|
|
100
|
+
rm -rf "$DIR"
|
|
101
|
+
}
|
|
102
|
+
trap cleanup EXIT
|
|
103
|
+
curl -fsSL -o "$DIR/orca.dmg" "${url}"
|
|
104
|
+
node "${VERIFY}" "$DIR/orca.dmg" "${sha}"
|
|
105
|
+
hdiutil attach -nobrowse -readonly -mountpoint "$MOUNT" "$DIR/orca.dmg"
|
|
106
|
+
MOUNTED=1
|
|
107
|
+
mkdir -p "${home}/Applications"
|
|
108
|
+
ditto "$MOUNT/Orca.app" "${home}/Applications/Orca.app"
|
|
109
|
+
`;
|
|
110
|
+
commands.push({
|
|
111
|
+
tool: 'orca',
|
|
112
|
+
desc: 'Install Orca app',
|
|
113
|
+
skipIfExists: [path.join(home, 'Applications', 'Orca.app'), '/Applications/Orca.app'],
|
|
114
|
+
run: [
|
|
115
|
+
['bash', '-c', script]
|
|
116
|
+
],
|
|
117
|
+
undo: [['rm', '-rf', path.join(home, 'Applications', 'Orca.app')]],
|
|
118
|
+
});
|
|
119
|
+
} else if (platform === 'win32') {
|
|
120
|
+
const url = orcaPin.url['windows-x64'];
|
|
121
|
+
const sha = orcaPin.sha256['windows-x64'];
|
|
122
|
+
const exe = path.join(os.tmpdir(), 'orca-installer.exe');
|
|
123
|
+
const local = env.LOCALAPPDATA;
|
|
124
|
+
commands.push({
|
|
125
|
+
tool: 'orca',
|
|
126
|
+
desc: 'Install Orca app',
|
|
127
|
+
skipIfExists: [`${local}\\Programs\\Orca`],
|
|
128
|
+
run: [
|
|
129
|
+
['curl', '-fsSL', '-o', exe, url],
|
|
130
|
+
['node', VERIFY, exe, sha],
|
|
131
|
+
[exe, '/currentuser', '/S']
|
|
132
|
+
],
|
|
133
|
+
always: [
|
|
134
|
+
ps(`if (Test-Path "${exe}") { Remove-Item "${exe}" }`)
|
|
135
|
+
],
|
|
136
|
+
// The NSIS uninstaller relaunches itself from %TEMP% and returns at once: wait until it has removed itself.
|
|
137
|
+
undo: [ps(`$u = "$env:LOCALAPPDATA\\Programs\\Orca\\Uninstall Orca.exe"; if (-not (Test-Path $u)) { exit 0 }; Start-Process -FilePath $u -ArgumentList '/S' -Wait; for ($i = 0; $i -lt 60 -and (Test-Path $u); $i++) { Start-Sleep 2 }; if (Test-Path $u) { Write-Error 'Orca uninstaller did not finish in 120 s'; exit 1 }`)],
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (terminals.includes('warp') && agents.includes('claude')) {
|
|
143
|
+
commands.push({
|
|
144
|
+
tool: 'warp',
|
|
145
|
+
desc: 'Warp plugin for Claude Code (needs jq)',
|
|
146
|
+
run: [['claude', 'plugin', 'marketplace', 'add', 'warpdotdev/claude-code-warp'], ['claude', 'plugin', 'install', 'warp@claude-code-warp']],
|
|
147
|
+
undo: [['claude', 'plugin', 'uninstall', 'warp@claude-code-warp']],
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
if (terminals.includes('orca')) {
|
|
151
|
+
const as = [...new Set(agents.map((a) => ORCA_SKILL_AGENT[a]).filter(Boolean))];
|
|
152
|
+
if (as.length) {
|
|
153
|
+
commands.push({
|
|
154
|
+
tool: 'orca',
|
|
155
|
+
desc: 'Orca skill orca-cli',
|
|
156
|
+
run: [['npx', '-y', skillsCli(), 'add', skillSource('orca-cli'), '--skill', 'orca-cli', '-a', ...as, '-g', '-y']],
|
|
157
|
+
undo: [['npx', '-y', skillsCli(), 'remove', 'orca-cli', '-g', '-y']],
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (platform === 'win32' && system) commands.push(...orcaWindowsCommands({ network, env, readEnv }));
|
|
161
|
+
}
|
|
162
|
+
return commands;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// One Windows env value from the User or Machine scope (null when unset); plan time only, read-only.
|
|
166
|
+
function readWindowsEnv(scope, name) {
|
|
167
|
+
const r = quiet(ps(`[Console]::Out.Write([Environment]::GetEnvironmentVariable('${name}','${scope}'))`));
|
|
168
|
+
return r.ok && r.out.trim() ? r.out.trim() : null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function orcaWindowsCommands({ network, env, readEnv }) {
|
|
172
|
+
const commands = [];
|
|
173
|
+
if (network.telemetry === 'off') {
|
|
174
|
+
for (const name of ORCA_TELEMETRY_ENV) {
|
|
175
|
+
commands.push({
|
|
176
|
+
tool: 'orca',
|
|
177
|
+
desc: `Orca telemetry off: ${name}=1 in your Windows user env (restart Orca)`,
|
|
178
|
+
run: [ps(`[Environment]::SetEnvironmentVariable('${name}','1','User')`)],
|
|
179
|
+
undo: [ps(`[Environment]::SetEnvironmentVariable('${name}',$null,'User')`)],
|
|
180
|
+
// A value you already set is yours: never overwritten, never undone.
|
|
181
|
+
skipIfOutput: { cmd: ps(`if (-not ([Environment]::GetEnvironmentVariable('${name}','User') -or [Environment]::GetEnvironmentVariable('${name}','Machine'))) { exit 1 }`) },
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (hasProxy(env)) {
|
|
186
|
+
// Scopes decide, not this shell: a value set only in the current session is not persisted anywhere.
|
|
187
|
+
const user = readEnv('User', 'NO_PROXY');
|
|
188
|
+
const machine = readEnv('Machine', 'NO_PROXY');
|
|
189
|
+
const have = (user ?? machine ?? '').split(',').map((x) => x.trim());
|
|
190
|
+
const missing = LOOPBACK.filter((h) => !have.includes(h));
|
|
191
|
+
if (missing.length) {
|
|
192
|
+
const list = missing.map((h) => `'${h}'`).join(',');
|
|
193
|
+
const get = (scope) => `[Environment]::GetEnvironmentVariable('NO_PROXY','${scope}')`;
|
|
194
|
+
commands.push({
|
|
195
|
+
tool: 'orca',
|
|
196
|
+
desc: `NO_PROXY: add ${missing.join(', ')} to your Windows user env so Orca status hooks skip the proxy (restart Orca)`,
|
|
197
|
+
// A user value shadows the machine one, so without a user value the machine value is the starting point.
|
|
198
|
+
run: [ps(`$v=${get('User')}; if (-not $v) { $v=${get('Machine')} }; $l=@($v -split ',' | Where-Object { $_ }); foreach ($h in @(${list})) { if ($l -notcontains $h) { $l += $h } }; [Environment]::SetEnvironmentVariable('NO_PROXY', ($l -join ','), 'User')`)],
|
|
199
|
+
// Drops only our entries. With no user value before, the var was ours: remove it once nothing but the machine value is left.
|
|
200
|
+
undo: [ps(`$l=@(${get('User')} -split ',' | Where-Object { $_ -and @(${list}) -notcontains $_ }); ${user ? '' : `$l=@($l | Where-Object { @(${get('Machine')} -split ',') -notcontains $_ }); `}[Environment]::SetEnvironmentVariable('NO_PROXY', $(if ($l.Count) { $l -join ',' } else { $null }), 'User')`)],
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return commands;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Git Bash's bash.exe absolute path, found under the standard install folders; null off Windows or not found.
|
|
208
|
+
// MSYSTEM alone (a shell started from Git Bash) carries no path, so it is not a source here.
|
|
209
|
+
export function gitBashPath({ platform = process.platform, env = process.env } = {}) {
|
|
210
|
+
if (platform !== 'win32') return null;
|
|
211
|
+
// USERPROFILE too: winget's user-scope Git follows the profile folder, which differs from LOCALAPPDATA when USERPROFILE is overridden.
|
|
212
|
+
const roots = [env.ProgramFiles, env['ProgramFiles(x86)'], env.LOCALAPPDATA && path.join(env.LOCALAPPDATA, 'Programs'), env.USERPROFILE && path.join(env.USERPROFILE, 'AppData', 'Local', 'Programs')];
|
|
213
|
+
for (const d of roots) {
|
|
214
|
+
if (!d) continue;
|
|
215
|
+
const p = path.join(d, 'Git', 'bin', 'bash.exe');
|
|
216
|
+
if (fs.existsSync(p)) return p;
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Git Bash on Windows: a shell started from it, or the standard install folders.
|
|
222
|
+
function gitBashPresent({ platform, env }) {
|
|
223
|
+
if (platform !== 'win32') return false;
|
|
224
|
+
return Boolean(env.MSYSTEM) || Boolean(gitBashPath({ platform, env }));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Which shell the agent will use on Windows, and what breaks without Git Bash. null off Windows.
|
|
228
|
+
export function shellNotice({ platform = process.platform, env = process.env } = {}) {
|
|
229
|
+
if (platform !== 'win32') return null;
|
|
230
|
+
if (gitBashPresent({ platform, env })) return { ok: true, text: 'Windows shell: Git Bash found. RTK and bash-style commands can run there.' };
|
|
231
|
+
return { ok: false, text: 'Windows shell: Git Bash not found, so agents fall back to PowerShell or cmd.exe. RTK rewrites and bash-style commands then fail or are skipped, output is not compressed (more tokens) and the rules\' POSIX examples do not apply. Fix: install Git for Windows (winget install Git.Git), then run --doctor.' };
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Marked ~/.bashrc block for Git Bash. Entries are appended at run time, so the user's own NO_PROXY is kept.
|
|
235
|
+
export function gitBashActions({ home, terminals, agents, platform = process.platform, env = process.env }) {
|
|
236
|
+
if (!gitBashPresent({ platform, env })) return [];
|
|
237
|
+
const lines = [];
|
|
238
|
+
if (agents.includes('cursor')) {
|
|
239
|
+
lines.push(
|
|
240
|
+
'# Cursor CLI hooks are denied under Git Bash unless MSYSTEM and SHELL are empty.',
|
|
241
|
+
"alias agent='MSYSTEM= SHELL= agent.cmd'",
|
|
242
|
+
"alias cursor-agent='MSYSTEM= SHELL= cursor-agent.cmd'",
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
if (terminals.includes('orca') && hasProxy(env)) {
|
|
246
|
+
lines.push(
|
|
247
|
+
'# Orca status hooks call 127.0.0.1 with curl: keep loopback off the proxy.',
|
|
248
|
+
`for h in ${LOOPBACK.join(' ')}; do`,
|
|
249
|
+
' case ",$NO_PROXY," in *",$h,"*) ;; *) NO_PROXY="${NO_PROXY:+$NO_PROXY,}$h" ;; esac',
|
|
250
|
+
' case ",$no_proxy," in *",$h,"*) ;; *) no_proxy="${no_proxy:+$no_proxy,}$h" ;; esac',
|
|
251
|
+
'done',
|
|
252
|
+
'export NO_PROXY no_proxy',
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
return lines.length ? [{ kind: 'block', toml: true, path: path.join(home, '.bashrc'), body: lines.join('\n') }] : [];
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Manual steps lean-agents cannot script: printed after install and by --doctor.
|
|
259
|
+
// `check` (when present) says whether a step is already done.
|
|
260
|
+
export function stillNeeded({ home, terminals, agents, platform = process.platform, env = process.env, exec = false, readEnv = readWindowsEnv }) {
|
|
261
|
+
const out = [];
|
|
262
|
+
if (agents.includes('cursor')) {
|
|
263
|
+
out.push({ text: 'Cursor: run `agent login` once (CLI) and sign in to the Cursor app; `agent mcp login <server>` for any MCP server that needs OAuth.' });
|
|
264
|
+
out.push({ text: 'Cursor: paste your global rules into Cursor Settings > Rules > User Rules (there is no file for them); --project writes team rules instead.' });
|
|
265
|
+
if (hasProxy(env)) out.push({ text: 'Cursor behind a proxy: export HTTP_PROXY, HTTPS_PROXY and NODE_USE_ENV_PROXY=1 in your shell profile (lean-agents never writes proxy values).' });
|
|
266
|
+
}
|
|
267
|
+
if (terminals.includes('orca')) {
|
|
268
|
+
if (platform === 'win32') {
|
|
269
|
+
out.push({ text: 'Orca: click "Install CLI & Skills" in Orca to put `orca` on PATH (%LOCALAPPDATA%\\Programs\\Orca\\resources\\bin).', check: exec ? () => Boolean(which('orca')) : undefined });
|
|
270
|
+
}
|
|
271
|
+
if (platform === 'win32' && hasProxy(env)) {
|
|
272
|
+
// Orca hands its own env to every terminal and Bun (OpenCode) reads proxy vars once, so a NO_PROXY added later needs an Orca restart.
|
|
273
|
+
out.push({
|
|
274
|
+
text: 'Orca behind a proxy: the Windows user NO_PROXY must list localhost, 127.0.0.1 and ::1, and Orca must be restarted after you change it (an Orca started earlier keeps the old value: status posts go to the proxy and fail with 403).',
|
|
275
|
+
check: exec ? () => LOOPBACK.every((h) => (readEnv('User', 'NO_PROXY') ?? readEnv('Machine', 'NO_PROXY') ?? '').split(',').map((x) => x.trim()).includes(h)) : undefined,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
// Mod+P is Ctrl+P on Windows; the rebind is the owner's report from the Windows work PC (#78).
|
|
279
|
+
if (platform === 'win32') out.push({ text: 'Orca: Ctrl+P opens Orca\'s worktree quick-open, so OpenCode never sees it. To keep Ctrl+P for OpenCode, put {"platforms":{"win32":{"worktree.quickOpen":["Ctrl+Shift+P"]}}} in ~/.orca/keybindings.json (lean-agents never edits that file).' });
|
|
280
|
+
out.push(
|
|
281
|
+
{ text: 'Orca: the first launch turns on agent status hooks, which write into ~/.claude/settings.json and ~/.cursor/hooks.json (Settings > Agents > Agent status hooks). --uninstall leaves them alone.', check: () => orcaHooksFound(home).length > 0 },
|
|
282
|
+
{ text: 'Orca: Settings > Agents > Agent permissions may start agents in Yolo mode; pick Manual if you expect approval prompts.' },
|
|
283
|
+
{ text: 'Orca: Settings > Session History > "Search inside sessions" indexes the full text of every agent chat on this machine; it is on by default.' },
|
|
284
|
+
{ text: 'Orca: restart Orca after env changes, then start a fresh agent tab (restored tabs keep the old env).' },
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
return out;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Orca hook entries found in other agents' configs, for --doctor.
|
|
291
|
+
const ORCA_HOOK = /[\\/]\.orca[\\/]agent-hooks|orca-agent-hook|ORCA_AGENT_HOOK/i;
|
|
292
|
+
export function orcaHooksFound(home) {
|
|
293
|
+
return [path.join(home, '.claude', 'settings.json'), path.join(home, '.cursor', 'hooks.json')].filter((f) => {
|
|
294
|
+
if (!fs.existsSync(f)) return false;
|
|
295
|
+
let text;
|
|
296
|
+
try { text = fs.readFileSync(f, 'utf8'); } catch { return false; }
|
|
297
|
+
// On Windows Orca writes the Cursor hook as a PowerShell -EncodedCommand (UTF-16LE base64).
|
|
298
|
+
const decoded = [...text.matchAll(/-EncodedCommand\s+([A-Za-z0-9+/=]+)/gi)].map((m) => Buffer.from(m[1], 'base64').toString('utf16le'));
|
|
299
|
+
return [text, ...decoded].some((t) => ORCA_HOOK.test(t));
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// True when an Orca opt-out is already set (Windows real home only). Reads process.env only: on Windows
|
|
304
|
+
// it carries the User and Machine vars from login, and spawning PowerShell here would touch USERPROFILE on a dry run.
|
|
305
|
+
export function orcaEnvSet({ platform = process.platform, system = true, env = process.env } = {}) {
|
|
306
|
+
if (platform !== 'win32' || !system) return false;
|
|
307
|
+
return ORCA_TELEMETRY_ENV.some((name) => Boolean(env[name]));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Printed with the all-off network preset; app settings stay the user's.
|
|
311
|
+
export function terminalPrivacyNotes(terminals, { orcaEnvSet = false } = {}) {
|
|
312
|
+
const notes = [];
|
|
313
|
+
if (terminals.includes('warp')) notes.push('Warp telemetry: set `[privacy] telemetry_enabled = false` in its settings.toml (the free plan may need it on for AI)');
|
|
314
|
+
if (terminals.includes('orca') && !orcaEnvSet) notes.push('Orca telemetry: set DO_NOT_TRACK=1 where Orca starts, or turn off Settings > Privacy > Share anonymous usage data');
|
|
315
|
+
return notes;
|
|
316
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Menus and progress for a real terminal, with @clack/prompts. lean.mjs keeps its readline prompter
|
|
2
|
+
// for every other case: clack hangs without a TTY or with a zero-width one, and Git Bash (mintty) has no raw mode.
|
|
3
|
+
export const canUseMenus = (input) => input.isTTY === true && typeof input.setRawMode === 'function' && process.stdout.isTTY === true && process.stdout.columns > 0;
|
|
4
|
+
|
|
5
|
+
export async function menuPrompter(input) {
|
|
6
|
+
const c = await import('@clack/prompts');
|
|
7
|
+
const io = { input, output: process.stdout };
|
|
8
|
+
const answer = (v) => {
|
|
9
|
+
if (c.isCancel(v)) { c.cancel('Cancelled.'); throw new Error('cancelled, nothing changed'); }
|
|
10
|
+
return v;
|
|
11
|
+
};
|
|
12
|
+
c.intro('lean-agents');
|
|
13
|
+
return {
|
|
14
|
+
menus: true,
|
|
15
|
+
// Yes/no questions keep their readline answers (y/n), so callers do not change.
|
|
16
|
+
ask: async (q, def) => {
|
|
17
|
+
if (def === 'y' || def === 'n') return answer(await c.confirm({ ...io, message: q, initialValue: def === 'y' })) ? 'y' : 'n';
|
|
18
|
+
return String(answer(await c.text({ ...io, message: q, placeholder: def, defaultValue: def }))).trim() || def;
|
|
19
|
+
},
|
|
20
|
+
select: async ({ message, options, def }) => answer(await c.select({ ...io, message, options, initialValue: def })),
|
|
21
|
+
multi: async ({ message, items, defaults }) => answer(await c.multiselect({ ...io, message, options: items, initialValues: defaults, required: false })),
|
|
22
|
+
close() { if (input !== process.stdin) input.destroy(); },
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Progress list and final summary. Without menus the engine prints its plain lines instead.
|
|
27
|
+
export async function menuProgress() {
|
|
28
|
+
const c = await import('@clack/prompts');
|
|
29
|
+
return {
|
|
30
|
+
step: (i, n, desc) => c.log.step(`[${i}/${n}] ${desc}`),
|
|
31
|
+
result: (ok, desc) => (ok ? c.log.success(desc) : c.log.error(`failed: ${desc}. Run the command above by hand, then --doctor.`)),
|
|
32
|
+
summary: (title, lines, ok) => { c.note(lines.join('\n'), title); c.outro(ok ? 'Done.' : 'Finished with errors.'); },
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Settings upstream does not document (VERIFY in docs/compatibility.md). lean-agents never guesses
|
|
2
|
+
// them: the user pastes their docs or IT notes, saved as-is for an agent to apply after review.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { OWNED_MARK } from './fsops.mjs';
|
|
6
|
+
import { configHome } from './system.mjs';
|
|
7
|
+
import { redactUrl } from './network.mjs';
|
|
8
|
+
|
|
9
|
+
export const notesDir = (home) => path.join(home, '.config', 'lean-agents', 'notes');
|
|
10
|
+
|
|
11
|
+
// "kept": another agent or the user already set the tool up, so the question is skipped and no notes are added.
|
|
12
|
+
export function unverifiedItems(o, home, { platform = process.platform, env = process.env, stateFiles = [] } = {}) {
|
|
13
|
+
const ours = new Set(stateFiles.map((f) => f.path));
|
|
14
|
+
const foreign = (p) => fs.existsSync(p) && !ours.has(p);
|
|
15
|
+
const off = (c) => o.network[c] === 'off';
|
|
16
|
+
const win = platform === 'win32';
|
|
17
|
+
const items = [];
|
|
18
|
+
const add = (id, label, kept = false) => items.push({ id, label, kept });
|
|
19
|
+
if (o.agents.includes('antigravity') && (off('telemetry') || off('autoUpdate'))) add('antigravity', 'Antigravity telemetry and auto-update switches');
|
|
20
|
+
if (o.tools.includes('serena')) add('serena', 'Serena config (serena_config.yml)', fs.existsSync(path.join(home, '.serena', 'serena_config.yml')));
|
|
21
|
+
if (win && (env.HTTPS_PROXY || env.https_proxy || env.HTTP_PROXY || env.http_proxy)) add('winget-proxy', 'winget persistent proxy');
|
|
22
|
+
if (o.tools.includes('playwright') || win) add('download-hosts', 'download hosts (Playwright browsers, winget packages)');
|
|
23
|
+
if (off('telemetry')) {
|
|
24
|
+
if (o.tools.includes('dcp')) add('dcp', 'DCP telemetry', foreign(path.join(configHome(home), 'opencode', 'dcp.jsonc')));
|
|
25
|
+
if (o.tools.includes('gsd')) add('gsd', 'GSD telemetry', foreign(path.join(home, '.gsd', 'defaults.json')));
|
|
26
|
+
if (o.tools.includes('autoskills')) add('autoskills', 'AutoSkills telemetry');
|
|
27
|
+
}
|
|
28
|
+
return items;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Pasted notes may hold credentials in forms other than a URL.
|
|
32
|
+
export const redactNotes = (text) => redactUrl(text)
|
|
33
|
+
.replace(/(^|[\s=])[^\s:@/=]+:[^\s@/]+@/g, '$1***@')
|
|
34
|
+
.replace(/((?:password|passwd|pwd|token|secret)\s*[=:]\s*)\S+/gi, '$1***');
|
|
35
|
+
|
|
36
|
+
// The answer is one line of text, or an absolute or ~ path to a file with the docs.
|
|
37
|
+
export function notesFile(home, item, answer) {
|
|
38
|
+
const p = answer.replace(/^~(?=[/\\])/, home);
|
|
39
|
+
const fromFile = path.isAbsolute(p) && fs.existsSync(p) && fs.statSync(p).isFile();
|
|
40
|
+
const text = redactNotes(fromFile ? fs.readFileSync(p, 'utf8') : answer).trimEnd();
|
|
41
|
+
return {
|
|
42
|
+
kind: 'file',
|
|
43
|
+
path: path.join(notesDir(home), `${item.id}.md`),
|
|
44
|
+
content: `<!-- ${OWNED_MARK}: your notes, never applied automatically -->\n# ${item.label}\n\n`
|
|
45
|
+
+ 'Upstream does not document this setting (VERIFY in lean-agents docs/compatibility.md).\n'
|
|
46
|
+
+ 'Ask your agent to apply these notes, showing you each change first.\n\n'
|
|
47
|
+
+ `Source: ${fromFile ? p : 'pasted'}\n\n${text}\n`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// The --update plan (#182): one row per tool `installed -> release pin`, what is held back, and the CHANGELOG notes
|
|
2
|
+
// since the installed lean-agents version. Pure: versions, state and the changelog text are passed in; no I/O, no network.
|
|
3
|
+
import { compare } from './node-runtime.mjs';
|
|
4
|
+
import { pinInUse } from './pins.mjs';
|
|
5
|
+
|
|
6
|
+
// Agent CLI binary -> [pin key, key in agents.json]. Cursor and Antigravity have no version pin, so they get no row.
|
|
7
|
+
const AGENTS = { claude: ['claude-code', 'claude'], opencode: ['opencode-v2', 'opencode-v2'], copilot: ['copilot-cli', 'copilot-cli'] };
|
|
8
|
+
const major = (v) => String(v).replace(/^v/, '').split('.')[0];
|
|
9
|
+
// `download` and `ciOnly` pins never reach state.pins (see pins.mjs), so they cannot be rows here either.
|
|
10
|
+
const tracked = (p) => !p.ciOnly && p.kind !== 'download';
|
|
11
|
+
|
|
12
|
+
// action: update (will move to the pin), held (never moved), major (pin is another major), own (not installed by lean-agents).
|
|
13
|
+
// `installed`: versions of the binaries on PATH ({ claude, opencode, copilot }, null when absent). `owned`: agents.json `agents` keys.
|
|
14
|
+
export function planUpdate({ saved, pins, installed = {}, owned = [] }) {
|
|
15
|
+
const rows = [];
|
|
16
|
+
for (const [tool, was] of Object.entries(saved.pins ?? {})) {
|
|
17
|
+
const p = pins[tool];
|
|
18
|
+
if (!p || !tracked(p) || p.version === was || !pinInUse(tool, saved.options)) continue;
|
|
19
|
+
rows.push({ tool, installed: was, pinned: p.version, action: p.hold ? 'held' : 'update', reason: p.hold ? 'held pin' : null });
|
|
20
|
+
}
|
|
21
|
+
for (const [bin, [key, agent]] of Object.entries(AGENTS)) {
|
|
22
|
+
const have = installed[bin];
|
|
23
|
+
if (!have || have === 'unknown') continue;
|
|
24
|
+
if (bin === 'opencode' && major(have) === '1') {
|
|
25
|
+
rows.push({ tool: 'opencode-v1', installed: have, pinned: pins['opencode-v1']?.version ?? null, action: 'held', reason: 'OpenCode 1.x is never updated by lean-agents' });
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const pinned = pins[key]?.version;
|
|
29
|
+
if (!pinned || compare(have, pinned) >= 0) continue;
|
|
30
|
+
const base = { tool: key, installed: have, pinned };
|
|
31
|
+
if (!owned.includes(agent)) rows.push({ ...base, action: 'own', reason: 'installed by you, left alone' });
|
|
32
|
+
else if (major(have) !== major(pinned)) rows.push({ ...base, action: 'major', reason: `crosses major ${major(have)} -> ${major(pinned)}, update it yourself` });
|
|
33
|
+
else rows.push({ ...base, action: 'update', reason: null });
|
|
34
|
+
}
|
|
35
|
+
return rows;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// `## [x.y.z]` sections of the shipped CHANGELOG newer than `from`, up to and including `to`; [Unreleased] is never included.
|
|
39
|
+
export function changelogNotes(text, from, to) {
|
|
40
|
+
const out = [];
|
|
41
|
+
let cur = null;
|
|
42
|
+
for (const line of String(text ?? '').split('\n')) {
|
|
43
|
+
const h = /^## \[(\d+\.\d+\.\d+)\]/.exec(line);
|
|
44
|
+
if (h) {
|
|
45
|
+
cur = compare(h[1], from) > 0 && compare(h[1], to) <= 0 ? { version: h[1], body: [] } : null;
|
|
46
|
+
if (cur) out.push(cur);
|
|
47
|
+
} else if (cur) cur.body.push(line);
|
|
48
|
+
}
|
|
49
|
+
return out.map((s) => ({ version: s.version, body: s.body.join('\n').trim() }));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function formatUpdatePlan(rows, notes) {
|
|
53
|
+
const out = [];
|
|
54
|
+
const moves = rows.filter((r) => r.action === 'update');
|
|
55
|
+
const rest = rows.filter((r) => r.action !== 'update');
|
|
56
|
+
if (moves.length) out.push('Pins that will change (old -> new):', ...moves.map((r) => `${r.tool}: ${r.installed} -> ${r.pinned}`));
|
|
57
|
+
if (rest.length) out.push('Not updated:', ...rest.map((r) => `${r.tool}: ${r.installed}${r.pinned && r.pinned !== r.installed ? ` -> ${r.pinned}` : ''} (${r.reason})`));
|
|
58
|
+
if (notes.length) out.push(`Release notes since your version (${notes.map((n) => n.version).join(', ')}):`, ...notes.flatMap((n) => [`## ${n.version}`, n.body]));
|
|
59
|
+
return out.join('\n');
|
|
60
|
+
}
|