@mumbrane/leto 0.0.0-stage → 0.19.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 (56) hide show
  1. package/README.md +395 -2
  2. package/bin/leto.js +8 -0
  3. package/evals/core/suite.json +249 -0
  4. package/index.js +12 -0
  5. package/package.json +43 -4
  6. package/src/agent.js +572 -0
  7. package/src/agents.js +68 -0
  8. package/src/anthropic.js +204 -0
  9. package/src/browser.js +427 -0
  10. package/src/btw.js +56 -0
  11. package/src/checkpoints.js +90 -0
  12. package/src/ci.js +115 -0
  13. package/src/cli.js +1926 -0
  14. package/src/client.js +111 -0
  15. package/src/config.js +205 -0
  16. package/src/documents.js +198 -0
  17. package/src/eval.js +289 -0
  18. package/src/hooks.js +115 -0
  19. package/src/ide.js +231 -0
  20. package/src/input.js +148 -0
  21. package/src/jobs.js +97 -0
  22. package/src/legacy.js +41 -0
  23. package/src/lsp.js +401 -0
  24. package/src/markdown.js +153 -0
  25. package/src/mcp.js +346 -0
  26. package/src/memory.js +136 -0
  27. package/src/orchestrator.js +141 -0
  28. package/src/patching.js +185 -0
  29. package/src/permissions.js +75 -0
  30. package/src/plugins.js +118 -0
  31. package/src/policy.js +74 -0
  32. package/src/pricing.js +67 -0
  33. package/src/processes.js +139 -0
  34. package/src/prompt.js +134 -0
  35. package/src/prompts.js +189 -0
  36. package/src/providers.js +59 -0
  37. package/src/repomap.js +211 -0
  38. package/src/sandbox.js +90 -0
  39. package/src/sdk.js +220 -0
  40. package/src/selftool.js +238 -0
  41. package/src/serve.js +233 -0
  42. package/src/session.js +168 -0
  43. package/src/setup.js +157 -0
  44. package/src/skills.js +125 -0
  45. package/src/theme.js +185 -0
  46. package/src/toolcalls.js +257 -0
  47. package/src/tools.js +976 -0
  48. package/src/tui.js +1179 -0
  49. package/src/ui.js +454 -0
  50. package/src/update.js +33 -0
  51. package/src/usage.js +83 -0
  52. package/src/verify.js +131 -0
  53. package/src/version.js +3 -0
  54. package/src/worktree.js +87 -0
  55. package/vscode/extension.js +132 -0
  56. package/vscode/package.json +21 -0
@@ -0,0 +1,249 @@
1
+ {
2
+ "name": "core",
3
+ "description": "24 small but real tasks: bug fixes, features, refactors, tests, debugging and code reading in JavaScript, Python, C and bash.",
4
+ "defaults": {
5
+ "timeout": 600
6
+ },
7
+ "tasks": [
8
+ {
9
+ "id": "js-fix-off-by-one",
10
+ "prompt": "npm test fails. Find and fix the bug in src/paginate.js. Don't change the tests.",
11
+ "files": {
12
+ "package.json": "{ \"type\": \"module\", \"scripts\": { \"test\": \"node test.js\" } }\n",
13
+ "src/paginate.js": "// Returns the items on page `page` (1-based), `size` per page.\nexport function paginate(items, page, size) {\n const start = page * size;\n return items.slice(start, start + size);\n}\n",
14
+ "test.js": "import assert from 'node:assert';\nimport { paginate } from './src/paginate.js';\nconst xs = [1,2,3,4,5,6,7];\nassert.deepStrictEqual(paginate(xs, 1, 3), [1,2,3]);\nassert.deepStrictEqual(paginate(xs, 3, 3), [7]);\nassert.deepStrictEqual(paginate(xs, 4, 3), []);\nconsole.log('ok');\n"
15
+ },
16
+ "check": "node test.js && git diff --quiet HEAD -- test.js"
17
+ },
18
+ {
19
+ "id": "js-async-bug",
20
+ "prompt": "loadAll in src/load.js sometimes returns before everything is loaded. Fix it so it waits for all loads and keeps the input order.",
21
+ "files": {
22
+ "package.json": "{ \"type\": \"module\" }\n",
23
+ "src/load.js": "const delay = (ms) => new Promise((r) => setTimeout(r, ms));\nexport async function loadOne(id) {\n await delay(30 - id * 5);\n return `item-${id}`;\n}\nexport async function loadAll(ids) {\n const out = [];\n ids.forEach(async (id) => {\n out.push(await loadOne(id));\n });\n return out;\n}\n",
24
+ "check.js": "import assert from 'node:assert';\nimport { loadAll } from './src/load.js';\nassert.deepStrictEqual(await loadAll([1,2,3,4]), ['item-1','item-2','item-3','item-4']);\nconsole.log('ok');\n"
25
+ },
26
+ "check": "node check.js"
27
+ },
28
+ {
29
+ "id": "js-add-feature-cli",
30
+ "prompt": "Add a --reverse flag to cli.js that prints the lines of the input file in reverse order. Without the flag it should keep printing them as they are.",
31
+ "files": {
32
+ "package.json": "{ \"type\": \"module\" }\n",
33
+ "cli.js": "import fs from 'node:fs';\nconst file = process.argv[2];\nconst lines = fs.readFileSync(file, 'utf8').trimEnd().split('\\n');\nfor (const l of lines) console.log(l);\n",
34
+ "in.txt": "a\nb\nc\n"
35
+ },
36
+ "check": "test \"$(node cli.js in.txt --reverse | tr '\\n' ,)\" = 'c,b,a,' && test \"$(node cli.js --reverse in.txt | tr '\\n' ,)\" = 'c,b,a,' && test \"$(node cli.js in.txt | tr '\\n' ,)\" = 'a,b,c,'"
37
+ },
38
+ {
39
+ "id": "js-rename-across-files",
40
+ "prompt": "Rename the function calcTotal to computeTotal everywhere in src/, including its uses and the re-export in src/index.js.",
41
+ "files": {
42
+ "package.json": "{ \"type\": \"module\" }\n",
43
+ "src/math.js": "export function calcTotal(items) {\n return items.reduce((s, x) => s + x.price * x.qty, 0);\n}\n",
44
+ "src/cart.js": "import { calcTotal } from './math.js';\nexport const cartTotal = (cart) => calcTotal(cart.items);\n",
45
+ "src/index.js": "export { calcTotal } from './math.js';\nexport { cartTotal } from './cart.js';\n"
46
+ },
47
+ "check": "node -e \"import('./src/index.js').then(m=>{if(m.calcTotal||typeof m.computeTotal!=='function'||m.cartTotal({items:[{price:2,qty:3}]})!==6)process.exit(1)})\" && ! grep -rq calcTotal src"
48
+ },
49
+ {
50
+ "id": "js-write-tests",
51
+ "prompt": "src/slug.js has no tests. Write a test file test/slug.test.js using node:test and node:assert that covers its behavior (lowercasing, spaces and punctuation, repeated dashes, leading/trailing dashes, accents). Don't change src/slug.js.",
52
+ "files": {
53
+ "package.json": "{ \"type\": \"module\", \"scripts\": { \"test\": \"node --test test/\" } }\n",
54
+ "src/slug.js": "export function slug(s) {\n return s\n .normalize('NFKD').replace(/[\\u0300-\\u036f]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n}\n"
55
+ },
56
+ "check": "test -f test/slug.test.js && node --test test/ && git diff --quiet HEAD -- src/slug.js && test $(grep -c 'assert' test/slug.test.js) -ge 4"
57
+ },
58
+ {
59
+ "id": "js-json-config-merge",
60
+ "prompt": "Implement mergeConfig(base, override) in src/merge.js: a deep merge where nested plain objects merge recursively, arrays and other values from override replace base, undefined values in override are ignored, and neither input is mutated.",
61
+ "files": {
62
+ "package.json": "{ \"type\": \"module\" }\n",
63
+ "src/merge.js": "export function mergeConfig(base, override) {\n // TODO\n}\n",
64
+ "check.js": "import assert from 'node:assert';\nimport { mergeConfig } from './src/merge.js';\nconst base = { a: 1, n: { x: 1, y: [1,2] }, keep: true };\nconst o = { a: 2, n: { y: [3], z: 9 }, keep: undefined };\nconst r = mergeConfig(base, o);\nassert.deepStrictEqual(r, { a: 2, n: { x: 1, y: [3], z: 9 }, keep: true });\nassert.deepStrictEqual(base, { a: 1, n: { x: 1, y: [1,2] }, keep: true });\nassert.deepStrictEqual(o.n, { y: [3], z: 9 });\nconsole.log('ok');\n"
65
+ },
66
+ "check": "node check.js"
67
+ },
68
+ {
69
+ "id": "js-perf-fix",
70
+ "prompt": "findDuplicates in src/dups.js is far too slow for big inputs (the check uses 200k items). Make it fast while returning the same result: each duplicated value once, in order of first appearance.",
71
+ "files": {
72
+ "package.json": "{ \"type\": \"module\" }\n",
73
+ "src/dups.js": "export function findDuplicates(xs) {\n const out = [];\n for (let i = 0; i < xs.length; i++) {\n for (let j = i + 1; j < xs.length; j++) {\n if (xs[i] === xs[j] && !out.includes(xs[i])) out.push(xs[i]);\n }\n }\n return out;\n}\n",
74
+ "check.js": "import assert from 'node:assert';\nimport { findDuplicates } from './src/dups.js';\nassert.deepStrictEqual(findDuplicates([3,1,3,2,1,3]), [3,1]);\nconst big = Array.from({ length: 200000 }, (_, i) => i % 150000);\nconst t = Date.now();\nconst r = findDuplicates(big);\nassert.equal(r.length, 50000);\nassert.ok(Date.now() - t < 1500, 'too slow');\nconsole.log('ok');\n"
75
+ },
76
+ "check": "timeout 20 node check.js"
77
+ },
78
+ {
79
+ "id": "js-express-like-router",
80
+ "prompt": "Finish src/router.js: route(method, pattern) registers handlers; patterns can contain :params (e.g. /users/:id/posts/:postId). handle(method, path) returns the handler's result called with { params }, or { status: 404 } when nothing matches. Methods must match exactly.",
81
+ "files": {
82
+ "package.json": "{ \"type\": \"module\" }\n",
83
+ "src/router.js": "export class Router {\n constructor() {\n this.routes = [];\n }\n route(method, pattern, handler) {\n // TODO\n }\n handle(method, path) {\n // TODO\n }\n}\n",
84
+ "check.js": "import assert from 'node:assert';\nimport { Router } from './src/router.js';\nconst r = new Router();\nr.route('GET', '/users/:id/posts/:postId', ({ params }) => params);\nr.route('GET', '/health', () => 'ok');\nr.route('POST', '/users', () => 'created');\nassert.deepStrictEqual(r.handle('GET', '/users/7/posts/42'), { id: '7', postId: '42' });\nassert.equal(r.handle('GET', '/health'), 'ok');\nassert.equal(r.handle('POST', '/users'), 'created');\nassert.deepStrictEqual(r.handle('GET', '/users'), { status: 404 });\nassert.deepStrictEqual(r.handle('DELETE', '/health'), { status: 404 });\nassert.deepStrictEqual(r.handle('GET', '/users/7/posts'), { status: 404 });\nconsole.log('ok');\n"
85
+ },
86
+ "check": "node check.js"
87
+ },
88
+ {
89
+ "id": "js-understand-codebase",
90
+ "prompt": "Without changing any code, find out which function in this project sends the welcome email and in which file it is defined. Write the answer as a single line `path:functionName` into ANSWER.txt.",
91
+ "files": {
92
+ "package.json": "{ \"type\": \"module\" }\n",
93
+ "src/users/service.js": "import { notify } from '../mail/notify.js';\nexport async function signUp(user) {\n await save(user);\n await notify.onSignup(user);\n}\nasync function save() {}\n",
94
+ "src/mail/notify.js": "import { sendTemplate } from './templates.js';\nexport const notify = {\n onSignup: (u) => sendTemplate('welcome', u.email),\n onReset: (u) => sendTemplate('reset', u.email),\n};\n",
95
+ "src/mail/templates.js": "import { deliver } from './smtp.js';\nexport function sendTemplate(name, to) {\n return deliver(to, `template:${name}`);\n}\n",
96
+ "src/mail/smtp.js": "export function deliver(to, body) {\n return { to, body };\n}\n"
97
+ },
98
+ "check": "grep -Eq 'src/mail/notify\\.js:(notify\\.)?onSignup|src/mail/templates\\.js:sendTemplate' ANSWER.txt && git diff --quiet HEAD -- src"
99
+ },
100
+ {
101
+ "id": "js-fix-regex-validation",
102
+ "prompt": "isValidEmail in src/validate.js accepts some invalid addresses and rejects some valid ones. Make it pass check.js without hard-coding the test cases.",
103
+ "files": {
104
+ "package.json": "{ \"type\": \"module\" }\n",
105
+ "src/validate.js": "export function isValidEmail(s) {\n return /.+@.+/.test(s);\n}\n",
106
+ "check.js": "import assert from 'node:assert';\nimport { isValidEmail } from './src/validate.js';\nfor (const ok of ['a@b.co', 'first.last+tag@sub.example.org', 'x_y-z@domain.io']) assert.ok(isValidEmail(ok), ok);\nfor (const bad of ['a@b', '@b.com', 'a@.com', 'a b@c.com', 'a@b.c', 'a@@b.com', 'a@b..com', 'plain']) assert.ok(!isValidEmail(bad), bad);\nconsole.log('ok');\n"
107
+ },
108
+ "check": "node check.js"
109
+ },
110
+ {
111
+ "id": "py-fix-bug",
112
+ "prompt": "python3 -m unittest fails. Fix the bug in inventory.py, not the tests.",
113
+ "files": {
114
+ "inventory.py": "class Inventory:\n def __init__(self):\n self.items = {}\n\n def add(self, name, qty=1):\n self.items[name] = qty\n\n def remove(self, name, qty=1):\n if self.items.get(name, 0) < qty:\n raise ValueError('not enough ' + name)\n self.items[name] -= qty\n if self.items[name] == 0:\n del self.items[name]\n\n def count(self, name):\n return self.items.get(name, 0)\n",
115
+ "test_inventory.py": "import unittest\nfrom inventory import Inventory\n\nclass T(unittest.TestCase):\n def test_add_accumulates(self):\n inv = Inventory(); inv.add('apple', 2); inv.add('apple', 3)\n self.assertEqual(inv.count('apple'), 5)\n def test_remove(self):\n inv = Inventory(); inv.add('pear', 2); inv.remove('pear', 2)\n self.assertEqual(inv.count('pear'), 0)\n self.assertNotIn('pear', inv.items)\n def test_remove_too_many(self):\n inv = Inventory(); inv.add('fig')\n with self.assertRaises(ValueError): inv.remove('fig', 2)\n\nif __name__ == '__main__':\n unittest.main()\n"
116
+ },
117
+ "check": "python3 -m unittest -q 2>&1 | tail -1 | grep -q OK && git diff --quiet HEAD -- test_inventory.py"
118
+ },
119
+ {
120
+ "id": "py-add-function",
121
+ "prompt": "Add a function `top_words(text, n)` to textstats.py that returns the n most common words (case-insensitive, punctuation ignored) as (word, count) tuples, most common first, ties broken alphabetically.",
122
+ "files": {
123
+ "textstats.py": "import re\n\ndef words(text):\n return re.findall(r\"[a-z']+\", text.lower())\n",
124
+ "check.py": "from textstats import top_words\nt = 'The cat and the hat. The CAT sat; a bat sat!'\nassert top_words(t, 3) == [('the', 3), ('cat', 2), ('sat', 2)], top_words(t, 3)\nassert top_words('b a b a c', 2) == [('a', 2), ('b', 2)]\nassert top_words('', 5) == []\nprint('ok')\n"
125
+ },
126
+ "check": "python3 check.py"
127
+ },
128
+ {
129
+ "id": "py-refactor-class",
130
+ "prompt": "shapes.py uses a long if/elif chain on a kind string. Refactor it into classes (Circle, Rect, Triangle) each with an area() method, plus a make_shape(kind, **dims) factory. Keep area(kind, **dims) working for old callers.",
131
+ "files": {
132
+ "shapes.py": "import math\n\ndef area(kind, **d):\n if kind == 'circle':\n return math.pi * d['r'] ** 2\n elif kind == 'rect':\n return d['w'] * d['h']\n elif kind == 'triangle':\n return 0.5 * d['b'] * d['h']\n raise ValueError(kind)\n",
133
+ "check.py": "import math\nfrom shapes import area, make_shape, Circle, Rect, Triangle\nassert abs(area('circle', r=2) - math.pi * 4) < 1e-9\nassert area('rect', w=2, h=3) == 6\nassert isinstance(make_shape('triangle', b=4, h=5), Triangle) and make_shape('triangle', b=4, h=5).area() == 10\nassert Rect(w=1, h=2).area() == 2\nassert isinstance(make_shape('circle', r=1), Circle)\ntry:\n make_shape('hexagon')\n raise SystemExit('should raise')\nexcept ValueError:\n pass\nimport inspect, shapes\nassert 'elif' not in inspect.getsource(shapes), 'still an if/elif chain'\nprint('ok')\n"
134
+ },
135
+ "check": "python3 check.py"
136
+ },
137
+ {
138
+ "id": "py-csv-report",
139
+ "prompt": "Write report.py: read sales.csv and print one line per region, sorted by region, as `region: total` where total is the sum of quantity*price rounded to 2 decimals (always 2 decimals). Ignore rows whose quantity isn't a number.",
140
+ "files": {
141
+ "sales.csv": "region,item,quantity,price\nnorth,widget,3,2.50\nsouth,gadget,1,10\nnorth,gizmo,2,1.25\neast,widget,n/a,2.50\nsouth,widget,4,2.5\neast,gadget,2,10.005\n"
142
+ },
143
+ "check": "test \"$(python3 report.py)\" = \"$(printf 'east: 20.01\\nnorth: 10.00\\nsouth: 20.00')\""
144
+ },
145
+ {
146
+ "id": "py-fix-mutable-default",
147
+ "prompt": "Something in cart.py makes carts share items. Find and fix it.",
148
+ "files": {
149
+ "cart.py": "class Cart:\n def __init__(self, items=[]):\n self.items = items\n\n def add(self, item):\n self.items.append(item)\n return self\n",
150
+ "check.py": "from cart import Cart\na = Cart().add('x')\nb = Cart()\nassert b.items == [], b.items\nc = Cart(['y']); c.add('z')\nassert c.items == ['y', 'z']\nprint('ok')\n"
151
+ },
152
+ "check": "python3 check.py"
153
+ },
154
+ {
155
+ "id": "py-parse-durations",
156
+ "prompt": "Implement parse_duration(s) in duration.py: it takes strings like '1h30m', '45s', '2h', '1h5m30s', '90m' and returns the total seconds as an int. Raise ValueError for empty or malformed input like '', 'abc', '5x', '1h1h', 'm5'.",
157
+ "files": {
158
+ "duration.py": "def parse_duration(s):\n raise NotImplementedError\n",
159
+ "check.py": "from duration import parse_duration as p\nassert p('1h30m') == 5400\nassert p('45s') == 45\nassert p('2h') == 7200\nassert p('1h5m30s') == 3930\nassert p('90m') == 5400\nfor bad in ['', 'abc', '5x', '1h1h', 'm5', '1m1h']:\n try:\n p(bad)\n except ValueError:\n continue\n raise SystemExit('accepted ' + repr(bad))\nprint('ok')\n"
160
+ },
161
+ "check": "python3 check.py"
162
+ },
163
+ {
164
+ "id": "py-cache-decorator",
165
+ "prompt": "Add a decorator `memoize(maxsize)` to cache.py: caches results by positional and keyword arguments, evicts the least recently used entry when full, and exposes `.cache_info()` returning a dict with hits, misses and size. Don't use functools.lru_cache.",
166
+ "files": {
167
+ "cache.py": "# memoize goes here\n",
168
+ "check.py": "import cache, inspect\nfrom cache import memoize\nassert 'lru_cache' not in inspect.getsource(cache)\ncalls = []\n@memoize(2)\ndef f(x, y=0):\n calls.append((x, y)); return x + y\nf(1); f(1); f(2); f(1, y=0)\nassert f.cache_info()['hits'] >= 2, f.cache_info()\nf(3) # evicts 2 (1 was used more recently)\nf(1); f(2)\nassert calls.count((2, 0)) == 2, calls\nassert calls.count((1, 0)) == 1, calls\nassert f.cache_info()['size'] == 2\nprint('ok')\n"
169
+ },
170
+ "check": "python3 check.py"
171
+ },
172
+ {
173
+ "id": "py-multi-file-feature",
174
+ "prompt": "Add a `discount_code` option to checkout: Order.total() should apply codes from discounts.py (SAVE10 = 10% off, FLAT5 = $5 off, never below 0). Unknown codes raise ValueError when set. Wire it through so `checkout(items, code)` in app.py works.",
175
+ "files": {
176
+ "order.py": "class Order:\n def __init__(self, items):\n self.items = items\n\n def subtotal(self):\n return sum(p * q for p, q in self.items)\n\n def total(self):\n return round(self.subtotal(), 2)\n",
177
+ "discounts.py": "# Discount codes and how they change a subtotal.\n",
178
+ "app.py": "from order import Order\n\ndef checkout(items):\n return Order(items).total()\n",
179
+ "check.py": "from app import checkout\nassert checkout([(10, 2)]) == 20\nassert checkout([(10, 2)], 'SAVE10') == 18\nassert checkout([(3, 1)], 'FLAT5') == 0\nassert checkout([(10, 1)], 'FLAT5') == 5\ntry:\n checkout([(1, 1)], 'BOGUS'); raise SystemExit('accepted bogus')\nexcept ValueError:\n pass\nprint('ok')\n"
180
+ },
181
+ "check": "python3 check.py"
182
+ },
183
+ {
184
+ "id": "c-fix-buffer",
185
+ "prompt": "The C program in strutil.c crashes or prints garbage for some inputs. Fix reverse() so `make test` passes, without changing main.",
186
+ "files": {
187
+ "strutil.c": "#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n\nchar *reverse(const char *s) {\n size_t n = strlen(s);\n char *out = malloc(n);\n for (size_t i = 0; i <= n; i++) out[i] = s[n - i];\n return out;\n}\n\nint main(int argc, char **argv) {\n for (int i = 1; i < argc; i++) {\n char *r = reverse(argv[i]);\n printf(\"%s\\n\", r);\n free(r);\n }\n return 0;\n}\n",
188
+ "Makefile": "test: strutil\n\ttest \"$$(./strutil abc '' hello)\" = \"$$(printf 'cba\\n\\nolleh')\"\n\nstrutil: strutil.c\n\tcc -Wall -Werror -fsanitize=address -g -o strutil strutil.c\n"
189
+ },
190
+ "check": "make -s test"
191
+ },
192
+ {
193
+ "id": "sh-script",
194
+ "prompt": "Write a bash script count.sh that takes a directory and prints how many files of each extension it contains (recursively), as `ext count` lines sorted by count descending then extension. Files without an extension count as `(none)`.",
195
+ "files": {
196
+ "data/a.txt": "1",
197
+ "data/b.txt": "2",
198
+ "data/c.md": "3",
199
+ "data/sub/d.txt": "4",
200
+ "data/sub/e.md": "5",
201
+ "data/sub/Makefile": "6",
202
+ "data/sub/deep/f.js": "7"
203
+ },
204
+ "check": "test \"$(bash count.sh data)\" = \"$(printf 'txt 3\\nmd 2\\n(none) 1\\njs 1')\""
205
+ },
206
+ {
207
+ "id": "js-fix-failing-build",
208
+ "prompt": "The TypeScript-style JSDoc types are fine, but `node build.js` fails. Find out why and fix the real problem in src/ (not build.js).",
209
+ "files": {
210
+ "package.json": "{ \"type\": \"module\" }\n",
211
+ "build.js": "import { render } from './src/render.js';\nconst out = render({ title: 'Hi', items: ['a', 'b'] });\nif (out !== '<h1>Hi</h1><ul><li>a</li><li>b</li></ul>') { console.error('bad output: ' + out); process.exit(1); }\nconsole.log('built');\n",
212
+ "src/render.js": "import { list } from './parts.js';\nexport function render({ title, items }) {\n return `<h1>${title}</h1>${list(items)}`;\n}\n",
213
+ "src/parts.js": "export function list(items) {\n return `<ul>${items.map(item).join(',')}</ul>`;\n}\nexport const item = (x) => `<li>${x}</li>`;\n"
214
+ },
215
+ "check": "node build.js && git diff --quiet HEAD -- build.js"
216
+ },
217
+ {
218
+ "id": "js-ambiguous-spec",
219
+ "prompt": "Add input validation to createUser in src/users.js: name is required (non-empty after trimming, max 50 chars) and age, if given, must be an integer 0-150. Invalid input should throw a ValidationError (export the class) whose `field` property names the bad field.",
220
+ "files": {
221
+ "package.json": "{ \"type\": \"module\" }\n",
222
+ "src/users.js": "let nextId = 1;\nexport function createUser({ name, age }) {\n return { id: nextId++, name: name.trim(), age: age ?? null };\n}\n",
223
+ "check.js": "import assert from 'node:assert';\nimport { createUser, ValidationError } from './src/users.js';\nassert.equal(createUser({ name: ' Ann ' }).name, 'Ann');\nassert.equal(createUser({ name: 'Bo', age: 30 }).age, 30);\nfor (const [input, field] of [[{ name: ' ' }, 'name'], [{}, 'name'], [{ name: 'x'.repeat(51) }, 'name'], [{ name: 'C', age: -1 }, 'age'], [{ name: 'C', age: 1.5 }, 'age'], [{ name: 'C', age: '20' }, 'age'], [{ name: 'C', age: 151 }, 'age']]) {\n assert.throws(() => createUser(input), (e) => e instanceof ValidationError && e.field === field, JSON.stringify(input));\n}\nconsole.log('ok');\n"
224
+ },
225
+ "check": "node check.js"
226
+ },
227
+ {
228
+ "id": "py-debug-from-traceback",
229
+ "prompt": "Running `python3 main.py` crashes. Fix the root cause (it's not in main.py).",
230
+ "files": {
231
+ "main.py": "from stats import summarize\nprint(summarize([4, 8, 15, 16, 23, 42]))\nprint(summarize([]))\n",
232
+ "stats.py": "def mean(xs):\n return sum(xs) / len(xs)\n\ndef summarize(xs):\n return {'n': len(xs), 'mean': mean(xs), 'max': max(xs)}\n",
233
+ "expected.txt": "{'n': 6, 'mean': 18.0, 'max': 42}\n{'n': 0, 'mean': None, 'max': None}\n"
234
+ },
235
+ "check": "python3 main.py | diff - expected.txt && git diff --quiet HEAD -- main.py expected.txt"
236
+ },
237
+ {
238
+ "id": "js-dedupe-logic",
239
+ "prompt": "src/a.js and src/b.js contain the same formatting logic copied twice. Move it into one shared function in src/format.js, use it from both files, and keep their output exactly the same.",
240
+ "files": {
241
+ "package.json": "{ \"type\": \"module\" }\n",
242
+ "src/a.js": "export function invoiceLine(item) {\n const amount = (Math.round(item.cents) / 100).toFixed(2);\n const label = item.name.length > 20 ? item.name.slice(0, 19) + '\u2026' : item.name;\n return `${label.padEnd(20)} $${amount.padStart(8)}`;\n}\n",
243
+ "src/b.js": "export function receiptLine(item) {\n const amount = (Math.round(item.cents) / 100).toFixed(2);\n const label = item.name.length > 20 ? item.name.slice(0, 19) + '\u2026' : item.name;\n return `${label.padEnd(20)} $${amount.padStart(8)}`;\n}\n",
244
+ "check.js": "import assert from 'node:assert';\nimport fs from 'node:fs';\nimport { invoiceLine } from './src/a.js';\nimport { receiptLine } from './src/b.js';\nconst it = { name: 'A very long product name here', cents: 123456 };\nassert.equal(invoiceLine(it), 'A very long product\u2026 $ 1234.56');\nassert.equal(receiptLine({ name: 'Tea', cents: 250 }), 'Tea $ 2.50');\nassert.ok(fs.existsSync('src/format.js'));\nfor (const f of ['src/a.js', 'src/b.js']) {\n const s = fs.readFileSync(f, 'utf8');\n assert.ok(/from '\\.\\/format\\.js'/.test(s), f + ' should use format.js');\n assert.ok(!s.includes('toFixed'), f + ' still has the copied logic');\n}\nconsole.log('ok');\n"
245
+ },
246
+ "check": "node check.js"
247
+ }
248
+ ]
249
+ }
package/index.js ADDED
@@ -0,0 +1,12 @@
1
+ export { Agent } from './src/agent.js';
2
+ export { Session, listSessions } from './src/session.js';
3
+ export { Permissions } from './src/permissions.js';
4
+ export { TOOLS, toolSchemas, executeToolCall } from './src/tools.js';
5
+ export { loadConfig } from './src/config.js';
6
+ export { streamChat } from './src/client.js';
7
+ export { buildSystemPrompt } from './src/prompt.js';
8
+ export { VERSION } from './src/version.js';
9
+ export { query, run, EventUI } from './src/sdk.js';
10
+ export { buildRepoMap } from './src/repomap.js';
11
+ export { runEval, compareEvals } from './src/eval.js';
12
+ export { parseToolCalls, repairJson } from './src/toolcalls.js';
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "@mumbrane/leto",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.19.0",
4
+ "description": "Leto: a coding agent for your terminal, built by Mumbrane",
5
+ "type": "module",
6
+ "main": "./index.js",
7
+ "exports": {
8
+ ".": "./index.js"
9
+ },
10
+ "bin": {
11
+ "leto": "./bin/leto.js",
12
+ "arrakis": "./bin/leto.js"
13
+ },
14
+ "files": [
15
+ "index.js",
16
+ "bin",
17
+ "src",
18
+ "vscode",
19
+ "evals/core"
20
+ ],
21
+ "engines": {
22
+ "node": ">=18.17"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/mumbrane/leto.git"
27
+ },
28
+ "license": "MIT",
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "scripts": {
33
+ "test": "node test/run.js"
34
+ },
35
+ "keywords": [
36
+ "ai",
37
+ "agent",
38
+ "coding-agent",
39
+ "cli",
40
+ "terminal"
41
+ ],
42
+ "dependencies": {
43
+ "@anthropic-ai/sdk": "^1.10.0"
44
+ }
45
+ }