lean-agents 0.0.0-stage → 0.8.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 (132) hide show
  1. package/LICENSE +21 -0
  2. package/README.es.md +454 -0
  3. package/README.md +453 -2
  4. package/core/AGENTS.es.md +60 -0
  5. package/core/AGENTS.md +60 -0
  6. package/core/README.md +8 -0
  7. package/core/agents/debug.md +14 -0
  8. package/core/agents/explore.md +13 -0
  9. package/core/agents/planner.md +14 -0
  10. package/core/agents/research.md +13 -0
  11. package/core/agents/review.md +13 -0
  12. package/core/copilot-usage-tui.js +186 -0
  13. package/core/mcp.json +38 -0
  14. package/core/pins.json +30 -0
  15. package/core/tiers.json +4 -0
  16. package/node_modules/@clack/core/LICENSE +9 -0
  17. package/node_modules/@clack/core/README.md +22 -0
  18. package/node_modules/@clack/core/dist/index.d.mts +503 -0
  19. package/node_modules/@clack/core/dist/index.mjs +1003 -0
  20. package/node_modules/@clack/core/package.json +63 -0
  21. package/node_modules/@clack/prompts/LICENSE +9 -0
  22. package/node_modules/@clack/prompts/README.md +396 -0
  23. package/node_modules/@clack/prompts/dist/index.d.mts +949 -0
  24. package/node_modules/@clack/prompts/dist/index.mjs +1423 -0
  25. package/node_modules/@clack/prompts/package.json +67 -0
  26. package/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
  27. package/node_modules/fast-string-truncated-width/dist/index.js +111 -0
  28. package/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
  29. package/node_modules/fast-string-truncated-width/dist/types.js +2 -0
  30. package/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
  31. package/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
  32. package/node_modules/fast-string-truncated-width/license +21 -0
  33. package/node_modules/fast-string-truncated-width/package.json +35 -0
  34. package/node_modules/fast-string-truncated-width/readme.md +59 -0
  35. package/node_modules/fast-string-width/dist/index.d.ts +4 -0
  36. package/node_modules/fast-string-width/dist/index.js +14 -0
  37. package/node_modules/fast-string-width/license +21 -0
  38. package/node_modules/fast-string-width/package.json +34 -0
  39. package/node_modules/fast-string-width/readme.md +42 -0
  40. package/node_modules/fast-wrap-ansi/LICENSE +23 -0
  41. package/node_modules/fast-wrap-ansi/README.md +26 -0
  42. package/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
  43. package/node_modules/fast-wrap-ansi/lib/main.js +218 -0
  44. package/node_modules/fast-wrap-ansi/package.json +51 -0
  45. package/node_modules/jsonc-parser/CHANGELOG.md +76 -0
  46. package/node_modules/jsonc-parser/LICENSE.md +21 -0
  47. package/node_modules/jsonc-parser/README.md +364 -0
  48. package/node_modules/jsonc-parser/SECURITY.md +41 -0
  49. package/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
  50. package/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
  51. package/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
  52. package/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
  53. package/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
  54. package/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
  55. package/node_modules/jsonc-parser/lib/esm/main.js +178 -0
  56. package/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
  57. package/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
  58. package/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
  59. package/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
  60. package/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
  61. package/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
  62. package/node_modules/jsonc-parser/lib/umd/main.js +194 -0
  63. package/node_modules/jsonc-parser/package.json +37 -0
  64. package/node_modules/sisteransi/license +21 -0
  65. package/node_modules/sisteransi/package.json +34 -0
  66. package/node_modules/sisteransi/readme.md +113 -0
  67. package/node_modules/sisteransi/src/index.js +58 -0
  68. package/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
  69. package/package.json +29 -4
  70. package/profiles/README.md +10 -0
  71. package/profiles/anthropic-api/gsd-defaults.json +26 -0
  72. package/profiles/anthropic-api.json +18 -0
  73. package/profiles/antigravity.json +12 -0
  74. package/profiles/claude-subscription/gsd-defaults.json +26 -0
  75. package/profiles/claude-subscription.json +17 -0
  76. package/profiles/github-copilot/gsd-defaults.json +26 -0
  77. package/profiles/github-copilot.json +17 -0
  78. package/profiles/openai-api/gsd-defaults.json +26 -0
  79. package/profiles/openai-api.json +17 -0
  80. package/profiles/opencode-go/gsd-defaults.json +26 -0
  81. package/profiles/opencode-go.json +17 -0
  82. package/profiles/vertex-gemini/gsd-defaults.json +26 -0
  83. package/profiles/vertex-gemini.json +18 -0
  84. package/scripts/adhd-skill.mjs +12 -0
  85. package/scripts/bump-pins.mjs +104 -0
  86. package/scripts/check-private.sh +52 -0
  87. package/scripts/check-readme.mjs +131 -0
  88. package/scripts/ci-download.sh +20 -0
  89. package/scripts/ci-install-opencode-v2.sh +6 -0
  90. package/scripts/ci-latest-report.mjs +38 -0
  91. package/scripts/copilot-context-mode.mjs +33 -0
  92. package/scripts/labels.sh +55 -0
  93. package/scripts/lean.mjs +700 -0
  94. package/scripts/lib/adapters/antigravity.mjs +72 -0
  95. package/scripts/lib/adapters/claude.mjs +122 -0
  96. package/scripts/lib/adapters/copilot-cli.mjs +81 -0
  97. package/scripts/lib/adapters/cursor.mjs +60 -0
  98. package/scripts/lib/adapters/opencode-v1.mjs +86 -0
  99. package/scripts/lib/adapters/opencode-v2.mjs +168 -0
  100. package/scripts/lib/adapters/vscode-copilot.mjs +56 -0
  101. package/scripts/lib/adhd.mjs +28 -0
  102. package/scripts/lib/adopt.mjs +474 -0
  103. package/scripts/lib/agent-lifecycle.mjs +163 -0
  104. package/scripts/lib/copilot-usage.mjs +49 -0
  105. package/scripts/lib/doctor.mjs +207 -0
  106. package/scripts/lib/feedback.mjs +30 -0
  107. package/scripts/lib/fsops.mjs +291 -0
  108. package/scripts/lib/gsd.mjs +42 -0
  109. package/scripts/lib/inventory.mjs +195 -0
  110. package/scripts/lib/lean-update.mjs +30 -0
  111. package/scripts/lib/migrate.mjs +407 -0
  112. package/scripts/lib/network.mjs +79 -0
  113. package/scripts/lib/node-runtime.mjs +85 -0
  114. package/scripts/lib/parallel.mjs +265 -0
  115. package/scripts/lib/pins.mjs +47 -0
  116. package/scripts/lib/project.mjs +38 -0
  117. package/scripts/lib/redact.mjs +30 -0
  118. package/scripts/lib/render.mjs +101 -0
  119. package/scripts/lib/system.mjs +178 -0
  120. package/scripts/lib/terminals.mjs +218 -0
  121. package/scripts/lib/ui.mjs +34 -0
  122. package/scripts/lib/unverified.mjs +49 -0
  123. package/scripts/lib/upgrade.mjs +130 -0
  124. package/scripts/lib/verify-commit.mjs +16 -0
  125. package/scripts/lib/verify-sha256.mjs +20 -0
  126. package/scripts/lint-workflows.mjs +25 -0
  127. package/scripts/models-refresh.mjs +58 -0
  128. package/scripts/parallel.mjs +59 -0
  129. package/scripts/pins-latest.mjs +43 -0
  130. package/scripts/release.mjs +46 -0
  131. package/scripts/verify-pins.mjs +36 -0
  132. package/scripts/version-watch.mjs +118 -0
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env bash
2
+ # Fails if any tracked file contains private data.
3
+ # Generic patterns live here; personal ones come from a gitignored
4
+ # .private-denylist file or the PRIVATE_DENYLIST env var (one regex per line).
5
+ set -euo pipefail
6
+
7
+ cd "$(git rev-parse --show-toplevel)"
8
+
9
+ # shellcheck disable=SC1003 # backslashes in the Windows path regex are intended
10
+ patterns=(
11
+ '/Users/[A-Za-z0-9._-]+/' # macOS home paths
12
+ 'C:\\\\Users\\\\[A-Za-z0-9._-]+\\\\' # Windows home paths
13
+ '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}' # email addresses
14
+ 'AKIA[0-9A-Z]{16}' # AWS access key
15
+ 'ghp_[A-Za-z0-9]{36}' # GitHub token
16
+ 'github_pat_[A-Za-z0-9_]{20,}' # GitHub fine-grained token
17
+ 'sk-[A-Za-z0-9_-]{20,}' # OpenAI/Anthropic style keys
18
+ 'AIza[0-9A-Za-z_-]{35}' # Google API key
19
+ 'xox[baprs]-[A-Za-z0-9-]+' # Slack token
20
+ '-----BEGIN [A-Z ]*PRIVATE KEY-----'
21
+ )
22
+
23
+ # Allowed placeholders and public addresses.
24
+ allow='(<username>|noreply@|users\.noreply\.github\.com|@example\.com|@anthropic\.com|git@github\.com)'
25
+
26
+ if [[ -f .private-denylist ]]; then
27
+ while IFS= read -r line; do
28
+ [[ -n "$line" && "$line" != \#* ]] && patterns+=("$line")
29
+ done < .private-denylist
30
+ fi
31
+ if [[ -n "${PRIVATE_DENYLIST:-}" ]]; then
32
+ while IFS= read -r line; do
33
+ [[ -n "$line" ]] && patterns+=("$line")
34
+ done <<< "$PRIVATE_DENYLIST"
35
+ fi
36
+
37
+ status=0
38
+ for p in "${patterns[@]}"; do
39
+ hits=$(git ls-files -z -- ':!scripts/check-private.sh' \
40
+ | xargs -0 grep -nIiE -e "$p" 2>/dev/null | grep -viE "$allow" || true)
41
+ if [[ -n "$hits" ]]; then
42
+ # Never echo the matched private pattern itself; show file:line only.
43
+ echo "Private data found (pattern #$(( $(printf '%s\n' "${patterns[@]}" | grep -nxF -- "$p" | head -1 | cut -d: -f1) ))):"
44
+ echo "$hits" | cut -d: -f1,2 | sed 's/^/ /'
45
+ status=1
46
+ fi
47
+ done
48
+
49
+ if [[ $status -eq 0 ]]; then
50
+ echo "check-private: OK (${#patterns[@]} patterns)"
51
+ fi
52
+ exit $status
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env node
2
+ // Checks the READMEs: links and anchors resolve, the part before Details fits the 1-minute budget,
3
+ // images have alt text and stay small, EN and ES share one structure, and every installer command
4
+ // shown exits 0 as a dry run in a temp HOME. Used by tests/readme.test.mjs, the lint job and the release.
5
+ import fs from 'node:fs';
6
+ import os from 'node:os';
7
+ import path from 'node:path';
8
+ import { spawnSync } from 'node:child_process';
9
+ import { fileURLToPath } from 'node:url';
10
+
11
+ export const ROOT = fileURLToPath(new URL('..', import.meta.url));
12
+ export const READMES = ['README.md', 'README.es.md'];
13
+ export const DETAILS_MARK = '<!-- details -->';
14
+ export const HERO_BUDGET = 80;
15
+ export const MAX_IMAGE_BYTES = 5 * 1024 * 1024;
16
+
17
+ const read = (f) => fs.readFileSync(path.join(ROOT, f), 'utf8');
18
+ const stripFences = (md) => md.replace(/^\s*```[\s\S]*?^\s*```/gm, '');
19
+
20
+ // GitHub heading slug: lowercase, drop punctuation, spaces to hyphens.
21
+ export const slug = (h) => h.toLowerCase().replace(/[`*]/g, '').replace(/[^\p{L}\p{N} _-]/gu, '').replace(/ /g, '-');
22
+
23
+ export function headings(md) {
24
+ return [...stripFences(md).matchAll(/^(#{1,6}) +(.+)$/gm)].map((m) => ({ level: m[1].length, text: m[2].trim() }));
25
+ }
26
+
27
+ // Broken relative links, images and anchors, as readable strings.
28
+ export function brokenLinks(file) {
29
+ const md = read(file);
30
+ const own = new Set(headings(md).map((h) => slug(h.text)));
31
+ const bad = [];
32
+ const refs = [...md.matchAll(/\]\(([^)\s]+)\)/g)].map((m) => m[1]).concat([...md.matchAll(/(?:src|href)="([^"]+)"/g)].map((m) => m[1]));
33
+ for (const ref of refs) {
34
+ if (/^(https?:|mailto:)/.test(ref)) continue;
35
+ const [target, anchor] = ref.split('#');
36
+ const dest = target ? path.join(ROOT, path.dirname(file), target) : path.join(ROOT, file);
37
+ if (!fs.existsSync(dest)) { bad.push(`${file}: missing ${ref}`); continue; }
38
+ if (anchor && dest.endsWith('.md')) {
39
+ const known = dest === path.join(ROOT, file) ? own : new Set(headings(fs.readFileSync(dest, 'utf8')).map((h) => slug(h.text)));
40
+ if (!known.has(anchor)) bad.push(`${file}: no anchor ${ref}`);
41
+ }
42
+ }
43
+ return bad;
44
+ }
45
+
46
+ // Every <img> and ![alt](src) in the text.
47
+ const images = (text) => { const md = stripFences(text); return [
48
+ ...[...md.matchAll(/<img\b[^>]*>/g)].map((m) => ({ src: m[0].match(/\bsrc="([^"]*)"/)?.[1], alt: m[0].match(/\balt="([^"]*)"/)?.[1] })),
49
+ ...[...md.matchAll(/!\[([^\]]*)\]\(([^)\s]+)/g)].map((m) => ({ src: m[2], alt: m[1] })),
50
+ ]; };
51
+
52
+ // Lines before the Details divider must fit the budget, so the first screen stays a 1-minute read.
53
+ export function heroProblems(md, file) {
54
+ const at = md.split('\n').findIndex((l) => l.trim() === DETAILS_MARK);
55
+ if (at < 0) return [`${file}: no ${DETAILS_MARK} divider`];
56
+ return at > HERO_BUDGET ? [`${file}: ${at} lines before Details, the budget is ${HERO_BUDGET}`] : [];
57
+ }
58
+
59
+ // Images need alt text and a local file of at most 5 MB (a missing file is reported by brokenLinks).
60
+ export function imageProblems(md, file, dir = path.join(ROOT, path.dirname(file))) {
61
+ const bad = [];
62
+ for (const { src, alt } of images(md)) {
63
+ if (!alt?.trim()) bad.push(`${file}: image without alt text ${src}`);
64
+ if (!src || /^(https?:|data:)/.test(src)) continue;
65
+ const dest = path.join(dir, src);
66
+ if (fs.existsSync(dest) && fs.statSync(dest).size > MAX_IMAGE_BYTES) bad.push(`${file}: image over 5 MB ${src}`);
67
+ }
68
+ return bad;
69
+ }
70
+
71
+ // Shape that EN and ES must share: heading levels, rows and columns per table, fenced blocks.
72
+ export function shape(file) {
73
+ const md = read(file);
74
+ const tables = [...md.matchAll(/(?:^\|.*\|\n?)+/gm)].map((m) => {
75
+ const rows = m[0].trim().split('\n');
76
+ return `${rows.length}x${rows[0].split('|').length - 2}`;
77
+ });
78
+ return {
79
+ headings: headings(md).map((h) => h.level).join(''),
80
+ tables: tables.join(','),
81
+ fences: [...md.matchAll(/^\s*```(\w*)/gm)].map((m) => m[1]).join(','),
82
+ images: images(md).length,
83
+ details: (md.match(/<details>/g) || []).length,
84
+ links: (md.match(/\]\(/g) || []).length,
85
+ bullets: (md.match(/^\s*[-*] /gm) || []).length,
86
+ };
87
+ }
88
+
89
+ const kebab = (s) => s.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
90
+
91
+ // Engine argument lists for every `install.sh | bash -s --` and install.ps1 command in the text.
92
+ export function installerArgs(file) {
93
+ const out = [];
94
+ for (const raw of read(file).split('\n')) {
95
+ const line = raw.replace(/\s+#.*$/, '');
96
+ const sh = line.match(/install\.sh \| bash -s -- (.+?)`?$/);
97
+ const ps = line.match(/install\.ps1\)\)\) ?([^`]*)`?/);
98
+ if (sh) out.push(sh[1].trim().split(/\s+/));
99
+ else if (ps) out.push(ps[1].trim().split(/\s+/).filter(Boolean).map((a) => (/^-[A-Z]/.test(a) ? `--${kebab(a.slice(1))}` : a)));
100
+ }
101
+ return out;
102
+ }
103
+
104
+ // Runs one command as a dry run in a temp HOME; returns the exit status.
105
+ export function dryRun(args) {
106
+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'lean-readme-'));
107
+ const home = path.join(tmp, 'home');
108
+ fs.mkdirSync(home);
109
+ const a = args.map((x) => (x === '.' ? tmp : x));
110
+ const lean = (...rest) => spawnSync(process.execPath, [path.join(ROOT, 'scripts/lean.mjs'), '--home', home, '--no-exec', '--yes', ...rest], { cwd: tmp, encoding: 'utf8', timeout: 60000 });
111
+ // --doctor exits 1 on a HOME with nothing installed, so give it a no-exec install to check.
112
+ if (a.includes('--doctor')) lean();
113
+ let r;
114
+ try { r = lean('--dry-run', ...a); } finally { fs.rmSync(tmp, { recursive: true, force: true }); }
115
+ return { status: r.status, stderr: r.stderr.trim().split('\n').slice(-2).join(' ') };
116
+ }
117
+
118
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
119
+ let failed = 0;
120
+ for (const f of READMES) {
121
+ for (const b of [...brokenLinks(f), ...heroProblems(read(f), f), ...imageProblems(read(f), f)]) { console.log(b); failed++; }
122
+ for (const args of installerArgs(f)) {
123
+ const r = dryRun(args);
124
+ if (r.status !== 0) { console.log(`${f}: exit ${r.status} for ${args.join(' ')} ${r.stderr}`); failed++; }
125
+ }
126
+ }
127
+ const [en, es] = READMES.map(shape);
128
+ for (const k of Object.keys(en)) if (en[k] !== es[k]) { console.log(`EN/ES differ in ${k}: ${en[k]} vs ${es[k]}`); failed++; }
129
+ console.log(failed ? `${failed} problem(s)` : 'README checks passed');
130
+ process.exit(failed ? 1 : 0);
131
+ }
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env bash
2
+ # Download a pinned CI file and check its SHA256 before anything runs it: ci-download.sh <key> <dest>
3
+ # Keys, URLs and hashes live in tests/ci-downloads.json (CI_DOWNLOADS points a test at another file). With CI_LATEST=true (ci-latest) a mismatch only warns,
4
+ # because that run exists to see the newest upstream. The file is still run unverified then: the warning and the step
5
+ # summary say so, and nothing is merged without a human reviewing the pin-bump PR.
6
+ set -euo pipefail
7
+ key=$1 dest=$2
8
+ entry="(require(process.env.CI_DOWNLOADS || './tests/ci-downloads.json')['$key'] || require('./core/pins.json').pins['$key'])"
9
+ url=$(node -p "$entry.url")
10
+ want=$(node -p "$entry.sha256")
11
+ curl -fsSL -o "$dest" "$url"
12
+ # Hashed in node: sha256sum prefixes the hash with a backslash when the path has one (Windows runners).
13
+ got=$(node --input-type=module -e "import { sha256 } from './scripts/lib/verify-sha256.mjs'; console.log(sha256(process.argv[1]))" "$dest")
14
+ if [ "$got" != "$want" ]; then
15
+ if [ "${CI_LATEST:-}" = true ]; then echo "::warning::$key changed upstream: sha256 $got (pinned $want)"; echo "- $key changed upstream, ran unverified: sha256 $got (pinned $want)" >> "${GITHUB_STEP_SUMMARY:-/dev/null}"; exit 0; fi
16
+ echo "::error::$key: sha256 $got does not match the pinned $want" >&2
17
+ rm -f "$dest"
18
+ exit 1
19
+ fi
20
+ echo "$key: sha256 ok"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ # OpenCode 2 for the real-* jobs: the installer is checked against its pinned SHA256, then run with the pinned version
3
+ # (core/pins.json "opencode-v2", package @opencode/cli on npm; the installer downloads that version from the npm registry).
4
+ set -euo pipefail
5
+ bash scripts/ci-download.sh opencode-installer "$RUNNER_TEMP/opencode-install"
6
+ bash "$RUNNER_TEMP/opencode-install" --version "$(node -p "require('./core/pins.json').pins['opencode-v2'].version")"
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ // Daily "latest versions" CI run failed: open one `version-watch` issue, or comment on the open one once per run.
3
+ // Needs GITHUB_TOKEN, GITHUB_REPOSITORY, RUN_URL, RUN_ID and FAILED_JOBS (newline-separated names).
4
+ import { pathToFileURL } from 'node:url';
5
+ import { githubApi } from './version-watch.mjs';
6
+
7
+ export const TITLE = 'Latest versions break CI';
8
+ const mark = (runId) => `<!-- ci-latest:${runId} -->`;
9
+
10
+ // issues: [{ number, title, state, body, comments: [string] }]. Returns the one action to take, or null.
11
+ export function plan(issues, { failed, runUrl, runId }) {
12
+ const open = issues.find((i) => i.title === TITLE && i.state === 'open');
13
+ if (open && [open.body, ...open.comments].some((t) => t?.includes(mark(runId)))) return null;
14
+ const body = [
15
+ `The daily run with the newest upstream versions failed: ${runUrl}`,
16
+ `Failed jobs:\n${failed.map((j) => `- ${j}`).join('\n')}`,
17
+ 'The run summary lists which pins moved. PRs are not affected: they use `core/pins.json`. Open `Update available` issues name the tool; run its `ci` job to confirm before bumping.',
18
+ mark(runId),
19
+ ].join('\n\n');
20
+ return open ? { type: 'comment', number: open.number, body } : { type: 'create', title: TITLE, body };
21
+ }
22
+
23
+ export async function run({ api, ...ctx }, log = console.log) {
24
+ const issues = await api.list();
25
+ for (const i of issues) i.comments = await api.comments(i.number);
26
+ const action = plan(issues, ctx);
27
+ if (!action) log('already reported for this run');
28
+ else if (action.type === 'create') await api.create(action.title, action.body);
29
+ else await api.comment(action.number, action.body);
30
+ if (action) log(action.type);
31
+ return action;
32
+ }
33
+
34
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
35
+ const { GITHUB_TOKEN, GITHUB_REPOSITORY, RUN_URL, RUN_ID, FAILED_JOBS = '' } = process.env;
36
+ if (!GITHUB_TOKEN || !GITHUB_REPOSITORY || !RUN_ID) { console.error('needs GITHUB_TOKEN, GITHUB_REPOSITORY and RUN_ID'); process.exit(1); }
37
+ await run({ api: githubApi(GITHUB_REPOSITORY, GITHUB_TOKEN), failed: FAILED_JOBS.split('\n').filter(Boolean), runUrl: RUN_URL, runId: RUN_ID });
38
+ }
@@ -0,0 +1,33 @@
1
+ // Registers Context Mode 2 with Copilot CLI. Its `setup` is a silent no-op for Copilot (plugin install
2
+ // "does not work yet", upstream docs/install/copilot-cli.md), so this runs the manual step from
3
+ // `context-mode setup --print copilot-cli`. The server path depends on where npm put the global package.
4
+ import { execFileSync, spawnSync } from 'node:child_process';
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
7
+ import { which } from './lib/system.mjs';
8
+
9
+ const shell = process.platform === 'win32';
10
+ const q = (a) => (shell ? `"${a}"` : a);
11
+
12
+ // shortcut: any "context-mode" entry counts as ours, so a hand-made one is kept; the undo (`copilot mcp remove`) still removes it. Compare paths if that ever matters.
13
+ const listed = spawnSync('copilot', ['mcp', 'list', '--json'], { encoding: 'utf8', shell });
14
+ if (listed.status === 0 && listed.stdout.includes('"context-mode"')) {
15
+ console.log('context-mode is already registered with Copilot CLI, left alone');
16
+ process.exit(0);
17
+ }
18
+
19
+ // The command npm linked is the ground truth for the prefix: a symlink into the package on Unix, a shim next
20
+ // to node_modules on Windows. `npm root -g` is only the fallback, since it recomputes the prefix.
21
+ const candidates = [];
22
+ const bin = process.env.LEAN_CONTEXT_MODE_DIR ? null : which('context-mode');
23
+ if (process.env.LEAN_CONTEXT_MODE_DIR) candidates.push(process.env.LEAN_CONTEXT_MODE_DIR); // set by lean-agents: the package lives in the tool Node's own prefix
24
+ if (bin) candidates.push(path.dirname(fs.realpathSync(bin)), path.join(path.dirname(bin), 'node_modules', 'context-mode'));
25
+ if (!process.env.LEAN_CONTEXT_MODE_DIR) candidates.push(path.join(execFileSync('npm', ['root', '-g'], { encoding: 'utf8', shell }).trim(), 'context-mode'));
26
+ const dir = candidates.find((d) => fs.existsSync(path.join(d, 'server.mjs')));
27
+ // The prerequisite step skips the install when any context-mode (for example 1.x) is already on PATH.
28
+ if (!dir) {
29
+ console.error(`context-mode 2 not found under npm root -g (looked in: ${candidates.join('; ')}); run npm i -g context-mode@2.1.4`);
30
+ process.exit(1);
31
+ }
32
+ const r = spawnSync('copilot', ['mcp', 'add', 'context-mode', '--', process.execPath, path.join(dir, 'server.mjs'), '--agent', 'copilot-cli'].map(q), { stdio: 'inherit', shell });
33
+ process.exit(r.status ?? 1);
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env bash
2
+ # Creates or updates the issue labels lean-agents uses. Safe to run again.
3
+ # Old GitHub default labels are renamed, so issues that carry them keep them.
4
+ #
5
+ # bash scripts/labels.sh [--dry-run] [owner/repo]
6
+ set -euo pipefail
7
+
8
+ dry_run=false
9
+ repo_args=()
10
+ for arg in "$@"; do
11
+ case "$arg" in
12
+ --dry-run) dry_run=true ;;
13
+ -*) echo "usage: labels.sh [--dry-run] [owner/repo]" >&2; exit 2 ;;
14
+ *) repo_args+=(--repo "$arg") ;;
15
+ esac
16
+ done
17
+
18
+ gh_run() {
19
+ if $dry_run; then printf 'gh'; printf ' %q' "$@"; printf '\n'; else gh "$@"; fi
20
+ }
21
+
22
+ # gh label list is read-only, so it also runs in --dry-run.
23
+ existing="$(gh label list ${repo_args[@]+"${repo_args[@]}"} --limit 200 --json name --jq '.[].name')"
24
+ has() { printf '%s\n' "$existing" | grep -Fxq "$1"; }
25
+
26
+ # old|new
27
+ for pair in 'bug|type: bug' 'documentation|type: docs' 'enhancement|type: feature'; do
28
+ old="${pair%%|*}"
29
+ new="${pair#*|}"
30
+ if has "$old" && ! has "$new"; then
31
+ gh_run label edit "$old" --name "$new" ${repo_args[@]+"${repo_args[@]}"}
32
+ fi
33
+ done
34
+
35
+ # name|color|description
36
+ while IFS='|' read -r name color desc; do
37
+ [[ -n "$name" ]] || continue
38
+ gh_run label create "$name" --color "$color" --description "$desc" --force ${repo_args[@]+"${repo_args[@]}"}
39
+ done <<'EOF'
40
+ type: bug|d73a4a|Something does not work
41
+ type: feature|a2eeef|New capability or change
42
+ type: update|0e8a16|Pinned tool version, drift or update failure
43
+ type: docs|0075ca|Documentation only
44
+ type: ci|ededed|Workflows and test jobs
45
+ type: security|b60205|Security hardening or exposure
46
+ priority: p0|b60205|Blocks users or leaks data; fix now
47
+ priority: p1|d93f0b|Next release
48
+ priority: p2|fbca04|Later, no deadline
49
+ area: engine|5319e7|scripts/lean.mjs and scripts/lib
50
+ area: installer|5319e7|install.sh and install.ps1
51
+ area: ci|5319e7|.github/workflows and tests/real-*
52
+ area: docs|5319e7|README, docs/, CHANGELOG
53
+ area: adapters|5319e7|scripts/lib/adapters and per-agent output
54
+ version-watch|ededed|Opened by the daily version watch
55
+ EOF