euron-code 0.5.2__tar.gz → 0.6.0__tar.gz

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 (107) hide show
  1. {euron_code-0.5.2 → euron_code-0.6.0}/CHANGELOG.md +25 -0
  2. {euron_code-0.5.2 → euron_code-0.6.0}/PKG-INFO +20 -1
  3. {euron_code-0.5.2 → euron_code-0.6.0}/README.md +19 -0
  4. {euron_code-0.5.2 → euron_code-0.6.0}/pyproject.toml +1 -1
  5. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/__init__.py +1 -1
  6. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/activity.py +24 -13
  7. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/agent.py +15 -2
  8. euron_code-0.6.0/src/euron_code/builtin_skills/build-from-reference/SKILL.md +30 -0
  9. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/cli.py +43 -2
  10. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/config.py +3 -1
  11. euron_code-0.6.0/src/euron_code/licensing.py +155 -0
  12. euron_code-0.6.0/src/euron_code/osscache.py +608 -0
  13. euron_code-0.6.0/src/euron_code/ossgithub.py +352 -0
  14. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/prompts.py +1 -1
  15. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/repl.py +113 -32
  16. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/__init__.py +3 -2
  17. euron_code-0.6.0/src/euron_code/tools/oss.py +611 -0
  18. euron_code-0.6.0/src/euron_code/transcript.py +368 -0
  19. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/ui.py +153 -13
  20. {euron_code-0.5.2 → euron_code-0.6.0}/tests/conftest.py +13 -0
  21. euron_code-0.6.0/tests/test_oss_local.py +524 -0
  22. euron_code-0.6.0/tests/test_transcript_ui.py +269 -0
  23. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_v3_activity.py +2 -2
  24. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_v3_live_repl.py +19 -2
  25. euron_code-0.5.2/src/euron_code/builtin_skills/build-from-reference/SKILL.md +0 -28
  26. euron_code-0.5.2/src/euron_code/licensing.py +0 -67
  27. euron_code-0.5.2/src/euron_code/tools/oss.py +0 -178
  28. {euron_code-0.5.2 → euron_code-0.6.0}/.gitignore +0 -0
  29. {euron_code-0.5.2 → euron_code-0.6.0}/LICENSE +0 -0
  30. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/__main__.py +0 -0
  31. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/api.py +0 -0
  32. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/attachments.py +0 -0
  33. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/auth.py +0 -0
  34. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/builtin_skills/explain-codebase/SKILL.md +0 -0
  35. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/builtin_skills/review/SKILL.md +0 -0
  36. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/builtin_skills/test-writer/SKILL.md +0 -0
  37. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/cache.py +0 -0
  38. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/checkpoints.py +0 -0
  39. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/context.py +0 -0
  40. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/contextforge/LICENSE +0 -0
  41. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/contextforge/__init__.py +0 -0
  42. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/contextforge/text.py +0 -0
  43. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/contextforge/toolout.py +0 -0
  44. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/credentials.py +0 -0
  45. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/doctor.py +0 -0
  46. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/documents.py +0 -0
  47. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/error_hints.py +0 -0
  48. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/errorlog.py +0 -0
  49. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/frontmatter.py +0 -0
  50. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/hooks.py +0 -0
  51. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/keys.py +0 -0
  52. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/memory.py +0 -0
  53. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/permissions.py +0 -0
  54. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/project_setup.py +0 -0
  55. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/repomap.py +0 -0
  56. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/rules.py +0 -0
  57. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/sessions.py +0 -0
  58. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/skills.py +0 -0
  59. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/textsafe.py +0 -0
  60. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/background.py +0 -0
  61. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/base.py +0 -0
  62. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/db.py +0 -0
  63. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/document.py +0 -0
  64. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/erie.py +0 -0
  65. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/fs.py +0 -0
  66. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/ignore.py +0 -0
  67. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/reuse.py +0 -0
  68. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/search.py +0 -0
  69. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/shell.py +0 -0
  70. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/skill.py +0 -0
  71. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/symbols.py +0 -0
  72. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/task.py +0 -0
  73. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/todo.py +0 -0
  74. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/tools/web.py +0 -0
  75. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/trust.py +0 -0
  76. {euron_code-0.5.2 → euron_code-0.6.0}/src/euron_code/usage_view.py +0 -0
  77. {euron_code-0.5.2 → euron_code-0.6.0}/tests/helpers.py +0 -0
  78. {euron_code-0.5.2 → euron_code-0.6.0}/tests/mock_gateway.py +0 -0
  79. {euron_code-0.5.2 → euron_code-0.6.0}/tests/serve_helper.py +0 -0
  80. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_agent_mock.py +0 -0
  81. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_api_shell.py +0 -0
  82. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_bench.py +0 -0
  83. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_cli_e2e.py +0 -0
  84. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_context_memory_sessions.py +0 -0
  85. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_db.py +0 -0
  86. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_erie.py +0 -0
  87. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_permissions.py +0 -0
  88. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_powershell_exit_codes.py +0 -0
  89. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_qa_attach_secrets.py +0 -0
  90. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_qa_long_task.py +0 -0
  91. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_qa_print_output.py +0 -0
  92. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_qa_reuse_unrelated.py +0 -0
  93. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_qa_yolo_outside.py +0 -0
  94. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_repl.py +0 -0
  95. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_search.py +0 -0
  96. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_textsafe.py +0 -0
  97. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_tools_fs.py +0 -0
  98. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_v2_rules_skills_hooks.py +0 -0
  99. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_v2_tokens_shortcuts.py +0 -0
  100. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_v2_usage_headers.py +0 -0
  101. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_v31_security.py +0 -0
  102. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_v3_accounts_value_setup.py +0 -0
  103. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_v3_attachments.py +0 -0
  104. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_v3_context.py +0 -0
  105. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_v3_single_login.py +0 -0
  106. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_v4.py +0 -0
  107. {euron_code-0.5.2 → euron_code-0.6.0}/tests/test_v5.py +0 -0
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0 (2026-11-06)
4
+
5
+ A new look for the interactive session.
6
+
7
+ - Each tool call is a block: `● Bash(npm test)` with its output indented under it. Long output shows
8
+ its first lines and `… +58 lines (ctrl+o to expand)`; Ctrl+O (or `/expand [n]`) prints it in full.
9
+ - Edits show as a numbered diff with added lines on green and removed lines on red.
10
+ - Answers start with a `●` bullet; while Euron Code works, a status line above the input shows what it is
11
+ doing, the time so far and the tokens received.
12
+ - The input sits in a box with a footer: the permission mode on the left (`▸▸ auto-approve on`), with
13
+ `esc to interrupt` while a task runs, and the model, context and today's tokens on the right.
14
+ - `!command` output uses the same block. `euron -p` output is unchanged.
15
+
16
+ Reuse from all of GitHub, on your own computer.
17
+
18
+ - Open-source search now asks GitHub directly from your machine (your own allowance; code search too
19
+ with `gh auth login` or `GITHUB_TOKEN`). The token goes only to GitHub, never to Euron, and is never
20
+ printed. When GitHub is offline or rate limited, Euron's service answers as before.
21
+ - New tools: `oss_fetch` downloads a reference once at a pinned commit into `~/.euron/cache/oss` and
22
+ indexes it; `oss_grep` and `oss_read` then work from your disk; `oss_adopt` copies the files worth
23
+ reusing with their licence header, copies LICENSE / NOTICE and updates `THIRD_PARTY_NOTICES.md`.
24
+ - Licences are checked in code from GitHub's licence detection, and again in the downloaded licence text
25
+ (Commons Clause and non-commercial riders are refused).
26
+ - `euron cache` (list, size, clear). The cache keeps 2 GB by default, least recently used out first.
27
+
3
28
  ## 0.5.2 (2026-11-05)
4
29
 
5
30
  Security and reliability fixes from pre-launch testing.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: euron-code
3
- Version: 0.5.2
3
+ Version: 0.6.0
4
4
  Summary: Euron Code: an agentic coding assistant in your terminal for Euron Plus and Super 30 students.
5
5
  Project-URL: Homepage, https://euron.one/code-agent
6
6
  Author-email: Euron <contact@euron.one>
@@ -240,6 +240,25 @@ again. MPL-2.0 files stay separate files under their own licence. Every reused s
240
240
  your project's `THIRD_PARTY_NOTICES.md`, and the completion report lists it (`Reused: owner/repo/path
241
241
  (MIT)`).
242
242
 
243
+ ### All of GitHub, from your own computer
244
+
245
+ Euron Code searches all public repositories on GitHub directly from your machine, so you get your own
246
+ GitHub allowance (and code search too when you are signed in with `gh auth login` or set `GITHUB_TOKEN`;
247
+ the token is only ever sent to GitHub, never to Euron, and never printed). A chosen reference is
248
+ downloaded once at a pinned commit into `~/.euron/cache/oss`, indexed on your computer, and reused in
249
+ later sessions: searching it and reading parts of it needs no network and no tokens. `oss_adopt` copies
250
+ the few files that are worth reusing into your project with their licence header, copies the LICENSE
251
+ (and NOTICE for Apache-2.0) to `third_party/licenses/`, and records repo, commit, licence and files in
252
+ `THIRD_PARTY_NOTICES.md`. The licence comes from GitHub's licence detection and is checked in code: a
253
+ repo with no detected licence, NOASSERTION, GPL, AGPL, LGPL, SSPL, BUSL, a non-commercial licence or a
254
+ Commons Clause rider is refused.
255
+
256
+ `euron cache` lists what is cached, `euron cache size` shows the total, `euron cache clear [owner/name]`
257
+ removes it. The cache keeps up to 2 GB (least recently used first out; `reuse.cacheMaxMB`) and at most
258
+ 50 MB per repo (`reuse.repoMaxMB`). `reuse.local false` (or `EURON_OSS_LOCAL=0`) asks Euron's service
259
+ instead of GitHub; when GitHub is offline or its rate limit is reached, Euron Code falls back to it by
260
+ itself. Full walk-through: [docs/USE_CASES_REUSE.md](docs/USE_CASES_REUSE.md).
261
+
243
262
  ## Limits and value
244
263
 
245
264
  Your plan has a token allowance per **day**, **week**, **month** and **year**, the same for Euron Plus
@@ -174,6 +174,25 @@ again. MPL-2.0 files stay separate files under their own licence. Every reused s
174
174
  your project's `THIRD_PARTY_NOTICES.md`, and the completion report lists it (`Reused: owner/repo/path
175
175
  (MIT)`).
176
176
 
177
+ ### All of GitHub, from your own computer
178
+
179
+ Euron Code searches all public repositories on GitHub directly from your machine, so you get your own
180
+ GitHub allowance (and code search too when you are signed in with `gh auth login` or set `GITHUB_TOKEN`;
181
+ the token is only ever sent to GitHub, never to Euron, and never printed). A chosen reference is
182
+ downloaded once at a pinned commit into `~/.euron/cache/oss`, indexed on your computer, and reused in
183
+ later sessions: searching it and reading parts of it needs no network and no tokens. `oss_adopt` copies
184
+ the few files that are worth reusing into your project with their licence header, copies the LICENSE
185
+ (and NOTICE for Apache-2.0) to `third_party/licenses/`, and records repo, commit, licence and files in
186
+ `THIRD_PARTY_NOTICES.md`. The licence comes from GitHub's licence detection and is checked in code: a
187
+ repo with no detected licence, NOASSERTION, GPL, AGPL, LGPL, SSPL, BUSL, a non-commercial licence or a
188
+ Commons Clause rider is refused.
189
+
190
+ `euron cache` lists what is cached, `euron cache size` shows the total, `euron cache clear [owner/name]`
191
+ removes it. The cache keeps up to 2 GB (least recently used first out; `reuse.cacheMaxMB`) and at most
192
+ 50 MB per repo (`reuse.repoMaxMB`). `reuse.local false` (or `EURON_OSS_LOCAL=0`) asks Euron's service
193
+ instead of GitHub; when GitHub is offline or its rate limit is reached, Euron Code falls back to it by
194
+ itself. Full walk-through: [docs/USE_CASES_REUSE.md](docs/USE_CASES_REUSE.md).
195
+
177
196
  ## Limits and value
178
197
 
179
198
  Your plan has a token allowance per **day**, **week**, **month** and **year**, the same for Euron Plus
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "euron-code"
7
- version = "0.5.2"
7
+ version = "0.6.0"
8
8
  description = "Euron Code: an agentic coding assistant in your terminal for Euron Plus and Super 30 students."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -1,3 +1,3 @@
1
1
  """Euron Code: an agentic coding assistant for the terminal."""
2
2
 
3
- __version__ = "0.5.2"
3
+ __version__ = "0.6.0"
@@ -1,6 +1,8 @@
1
1
  """The live activity line shown while the agent works, e.g.
2
2
 
3
- ✻ Brewing… (14s · ↑ 3.2k ↓ 418 tokens · running pytest -q 6s · esc to interrupt)
3
+ ⠹ Building… (14s · ↓ 418 tokens · running pytest -q 6s)
4
+
5
+ (the interactive prompt shows "esc to interrupt" in its footer; other displays add it to the line)
4
6
 
5
7
  The agent updates one Activity object from whatever thread runs the turn; the UI only reads it
6
8
  (`render()`), from the prompt_toolkit loop or a ticker thread. Counters are guarded by a lock.
@@ -19,15 +21,16 @@ import threading
19
21
  import time
20
22
  from typing import Any, Dict, Optional
21
23
 
22
- GLYPHS = ["·", "✢", "✳", "✶", "✻", "✽", "✻", "✶", "✳", "✢"]
23
- ASCII_GLYPHS = [".", "o", "O", "@", "*", "@", "O", "o"]
24
+ GLYPHS = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
25
+ ASCII_GLYPHS = ["|", "/", "-", "\\"]
24
26
 
27
+ #: Euron's own working verbs: what a learner and an engineer actually do
25
28
  VERBS = [
26
- "Pondering", "Brewing", "Tinkering", "Weaving", "Compiling thoughts", "Mulling", "Crafting",
27
- "Sketching", "Untangling", "Assembling", "Polishing", "Reasoning", "Exploring", "Distilling",
28
- "Composing", "Calibrating", "Simmering", "Forging", "Puzzling", "Sculpting", "Orchestrating",
29
- "Percolating", "Refining", "Wrangling", "Considering", "Charting", "Threading", "Kneading",
30
- "Tuning", "Musing", "Conjuring", "Shaping",
29
+ "Building", "Thinking", "Compiling", "Debugging", "Refactoring", "Testing", "Indexing", "Tracing",
30
+ "Profiling", "Linting", "Reviewing", "Planning", "Drafting", "Scaffolding", "Wiring up", "Benchmarking",
31
+ "Optimising", "Iterating", "Analysing", "Reading the docs", "Mapping the repo", "Writing tests",
32
+ "Checking edge cases", "Studying", "Practising", "Solving", "Structuring", "Modelling", "Deploying",
33
+ "Shipping", "Learning", "Pairing", "Prototyping", "Validating",
31
34
  ]
32
35
 
33
36
  QUEUED = re.compile(r"queued,\s*(\d+)\s*ahead", re.IGNORECASE)
@@ -87,6 +90,7 @@ class Activity:
87
90
  def __init__(self, ascii: Optional[bool] = None, verb_seconds: float = 4.0, frame_seconds: float = 0.12,
88
91
  rng: Optional[random.Random] = None, clock=time.monotonic):
89
92
  self.ascii = (not supports_unicode()) if ascii is None else ascii
93
+ self.animate = True # False: a still glyph (NO_COLOR asks for a calm, plain display)
90
94
  self.verb_seconds = verb_seconds
91
95
  self.frame_seconds = frame_seconds
92
96
  self.rng = rng or random.Random()
@@ -166,6 +170,8 @@ class Activity:
166
170
 
167
171
  def glyph(self, now: Optional[float] = None) -> str:
168
172
  frames = ASCII_GLYPHS if self.ascii else GLYPHS
173
+ if not self.animate:
174
+ return frames[4 % len(frames)]
169
175
  n = int(self.elapsed(now) / self.frame_seconds)
170
176
  return frames[n % len(frames)]
171
177
 
@@ -173,17 +179,18 @@ class Activity:
173
179
  n = int(self.elapsed(now) / self.verb_seconds)
174
180
  return VERBS[(self._verb_offset + n) % len(VERBS)]
175
181
 
176
- def render(self, now: Optional[float] = None, hint: bool = True) -> str:
182
+ def parts(self, now: Optional[float] = None, hint: bool = True):
183
+ """(glyph, "Verb…", "(elapsed · ↓ tokens · what)") for a renderer that colours each part."""
177
184
  now = self.clock() if now is None else now
178
- sent, recv = self.tokens
179
- up, down = ("^", "v") if self.ascii else ("↑", "↓")
185
+ _, recv = self.tokens
186
+ down = "v" if self.ascii else "↓"
180
187
  dots = "..." if self.ascii else "…"
181
188
  with self._lock:
182
189
  tool, tool_t0 = self.tool, self.tool_t0
183
190
  what = tool or self.phase
184
191
  if tool and now - tool_t0 >= 2:
185
192
  what += f" {fmt_elapsed(now - tool_t0)}"
186
- parts = [fmt_elapsed(self.elapsed(now)), f"{up} {fmt_tokens(sent)} {down} {fmt_tokens(recv)} tokens"]
193
+ parts = [fmt_elapsed(self.elapsed(now)), f"{down} {fmt_tokens(recv)} tokens"]
187
194
  if what:
188
195
  parts.append(what)
189
196
  if self.queued:
@@ -191,4 +198,8 @@ class Activity:
191
198
  if hint:
192
199
  parts.append("esc to interrupt")
193
200
  sep = " - " if self.ascii else " · "
194
- return f"{self.glyph(now)} {self.verb(now)}{dots} (" + sep.join(parts) + ")"
201
+ return self.glyph(now), self.verb(now) + dots, "(" + sep.join(parts) + ")"
202
+
203
+ def render(self, now: Optional[float] = None, hint: bool = True) -> str:
204
+ glyph, verb, detail = self.parts(now, hint=hint)
205
+ return f"{glyph} {verb} {detail}"
@@ -47,7 +47,7 @@ REPEAT_STOP_AT = 8
47
47
  SEARCH_BUDGET = 4 # reference searches per request before a "pick one" note
48
48
  READ_BUDGET = 6 # reference file reads per request
49
49
  SEARCH_TOOLS = ("euron_reuse_search", "oss_search")
50
- READ_TOOLS = ("euron_reuse_read", "oss_read", "oss_tree")
50
+ READ_TOOLS = ("euron_reuse_read", "oss_read", "oss_tree", "oss_grep")
51
51
  _LIC_RE = re.compile(r"\[(MIT|Apache-2\.0|BSD-[23]-Clause|ISC|0BSD|Unlicense|MPL-2\.0|CC0-1\.0|Zlib)\]|licence (\S+)")
52
52
  DEFAULT_STEP_BUDGET = 60
53
53
  _EXIT_RE = re.compile(r"^Exit code: (-?\d+)")
@@ -895,7 +895,7 @@ class Agent:
895
895
  "references from these results and read only the files you need.]")
896
896
  elif name in READ_TOOLS:
897
897
  n = self._calls[("budget", "read")] = self._calls.get(("budget", "read"), 0) + 1
898
- if name != "oss_tree" and args.get("repo") and args.get("path"):
898
+ if name not in ("oss_tree", "oss_grep") and args.get("repo") and args.get("path"):
899
899
  m = _LIC_RE.search(content.split("\n", 2)[0] + " " + content.split("\n", 2)[1]
900
900
  if "\n" in content else content)
901
901
  lic = (m.group(1) or m.group(2)) if m else "?"
@@ -907,6 +907,17 @@ class Agent:
907
907
  "read, record it with add_third_party_notice, and write only what is missing.]")
908
908
  return note
909
909
 
910
+ def _record_adoption(self, args: Dict[str, Any], content: str) -> None:
911
+ """oss_adopt copied files: each is reused code for the report and the -p JSON."""
912
+ reused = self.ledger.setdefault("reused", [])
913
+ m = _LIC_RE.search(content.partition("\n")[0])
914
+ lic = (m.group(1) or m.group(2)) if m else "?"
915
+ paths = args.get("paths") if isinstance(args.get("paths"), list) else [args.get("paths")]
916
+ for p in paths:
917
+ item = (str(args.get("repo")), str(p), lic)
918
+ if p and item not in reused:
919
+ reused.append(item)
920
+
910
921
  def files_changed(self) -> List[str]:
911
922
  return list(dict.fromkeys(rel for _, rel in self.ledger["edits"]))
912
923
 
@@ -1141,6 +1152,8 @@ class Agent:
1141
1152
  if result.is_error and not content.startswith(("Error", "Exit code")):
1142
1153
  content = "Error: " + content
1143
1154
  self._record(name, req, content, result.is_error)
1155
+ if not result.is_error and name == "oss_adopt":
1156
+ self._record_adoption(args, content)
1144
1157
  if not result.is_error and (name in SEARCH_TOOLS or name in READ_TOOLS):
1145
1158
  content += self._record_reuse(name, args, content)
1146
1159
  self._note_component_read(name, args)
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: build-from-reference
3
+ description: Build an app, feature, page or UI from existing permissive open-source code instead of from scratch. Use for every "build me X" request and for any UI work.
4
+ ---
5
+
6
+ # Build from a reference
7
+
8
+ Goal: $ARGUMENTS
9
+
10
+ Less time, fewer tokens: reuse first, generate only what is missing. Budget: about 4 searches and 6 file reads
11
+ before you write anything.
12
+
13
+ 1. **Look at the project first.** Which framework, component library and styling does it already use
14
+ (package.json, existing components, Tailwind/MUI/shadcn, ...)? Prefer what is there.
15
+ 2. **Search Euron's repos:** `euron_reuse_search` with a short query (for UI use `language: "typescript"`).
16
+ 3. **Then all of GitHub:** `oss_search` (kind=repos, a few keywords, never code) searches from this computer and
17
+ returns the top 5 with licence and why. Only MIT, Apache-2.0, BSD, ISC, 0BSD, Unlicense, MPL-2.0, CC0 and Zlib
18
+ may be used; the tools enforce it. If a tool says a licence is not permitted, drop that source completely.
19
+ 4. **Fetch one reference:** `oss_fetch` downloads it once into the local cache and indexes it (later sessions
20
+ reuse it). Find the 2-6 files that matter with `oss_grep` and read only the lines you need with `oss_read`.
21
+ 5. **Adopt the smallest set of files:** `oss_adopt` copies them into the project with their licence header,
22
+ copies LICENSE (and NOTICE for Apache-2.0) and updates THIRD_PARTY_NOTICES.md. Then adapt them to the
23
+ project's conventions; do not regenerate them. MPL-2.0 files stay separate files under MPL.
24
+ 6. **Hand adaptations** (you rewrote rather than copied): record the source once with `add_third_party_notice`.
25
+ Skip all of this for trivial code.
26
+ 7. **Generate only what is missing**, then run the project (tests, `start_background_process` + `check_app`
27
+ for apps) to verify.
28
+
29
+ Finish with: what you built, `Reused: owner/repo/path (licence)` for each source, and how you verified it.
30
+ If oss_fetch cannot download (offline, rate limited), oss_tree / oss_read still work through Euron.
@@ -18,7 +18,7 @@ from euron_code import __version__, api, auth, config, credentials, sessions
18
18
  from euron_code.ui import UI, QuietUI
19
19
 
20
20
  EXIT_OK, EXIT_ERROR, EXIT_USAGE, EXIT_NO_PLUS, EXIT_AUTH, EXIT_QUOTA, EXIT_MAX_TURNS, EXIT_INT = 0, 1, 2, 3, 4, 5, 6, 130
21
- SUBCOMMANDS = ("login", "logout", "whoami", "usage", "users", "doctor", "config", "init", "trust")
21
+ SUBCOMMANDS = ("login", "logout", "whoami", "usage", "users", "doctor", "config", "init", "trust", "cache")
22
22
  STARTED = __import__("time").monotonic() # session uptime counts from here
23
23
 
24
24
 
@@ -52,7 +52,8 @@ def main_parser() -> argparse.ArgumentParser:
52
52
  p = argparse.ArgumentParser(
53
53
  prog="euron",
54
54
  description="Euron Code: an AI coding agent in your terminal (Euron Plus and Super 30).",
55
- epilog="Commands: euron login [--force] | logout | whoami | usage | init | doctor | config get|set|unset|list. "
55
+ epilog="Commands: euron login [--force] | logout | whoami | usage | init | doctor | config get|set|unset|list | "
56
+ "cache list|size|clear. "
56
57
  "Run `euron` with no arguments for an interactive session.",
57
58
  )
58
59
  p.add_argument("prompt", nargs="?", help="Initial prompt (with -p: the one-shot prompt).")
@@ -97,6 +98,10 @@ def sub_parser(cmd: str) -> argparse.ArgumentParser:
97
98
  if cmd == "trust":
98
99
  p.add_argument("-y", "--yes", action="store_true", help="Trust without asking.")
99
100
  p.add_argument("--revoke", action="store_true", help="Stop trusting this project.")
101
+ if cmd == "cache":
102
+ p.add_argument("action", nargs="?", default="list", choices=["list", "size", "clear", "path"])
103
+ p.add_argument("repo", nargs="?", help="With clear: only this owner/name.")
104
+ p.add_argument("--json", action="store_true")
100
105
  if cmd == "config":
101
106
  p.add_argument("action", choices=["get", "set", "unset", "list", "path"])
102
107
  p.add_argument("key", nargs="?")
@@ -185,6 +190,8 @@ def run_subcommand(cmd: str, args) -> int:
185
190
  return doctor(ui)
186
191
  if cmd == "config":
187
192
  return run_config(ui, args)
193
+ if cmd == "cache":
194
+ return run_cache(ui, args)
188
195
  client = _need_client(ui)
189
196
  try:
190
197
  if cmd == "users":
@@ -216,6 +223,40 @@ def run_subcommand(cmd: str, args) -> int:
216
223
  return EXIT_USAGE
217
224
 
218
225
 
226
+ def run_cache(ui, args) -> int:
227
+ """`euron cache [list|size|clear [owner/name]|path]`: the local open-source cache (no login needed)."""
228
+ from euron_code import osscache, ossgithub
229
+ cap, repo_cap = osscache.limits(config.load_settings(config.find_project_root()))
230
+ if args.action == "path":
231
+ print(osscache.cache_root())
232
+ return EXIT_OK
233
+ if args.action == "clear":
234
+ n = osscache.clear(args.repo)
235
+ ui.info(f"Removed {n} cached repo(s)" + (f" for {args.repo}" if args.repo else "") + ".")
236
+ return EXIT_OK
237
+ rows = osscache.entries()
238
+ total = osscache.total_size()
239
+ if args.json:
240
+ print(json.dumps({"path": str(osscache.cache_root()), "bytes": total, "capBytes": cap, "repos": rows},
241
+ indent=2))
242
+ return EXIT_OK
243
+ ui.info(f"Open-source cache: {osscache.cache_root()}")
244
+ ui.info(f"{len(rows)} repo(s), {total / osscache.MB:.1f} MB of {cap / osscache.MB:.0f} MB "
245
+ f"(per repo up to {repo_cap / osscache.MB:.0f} MB; least recently used are removed first)")
246
+ ui.dim(f"GitHub token: {ossgithub.token_source()}")
247
+ if args.action == "size":
248
+ return EXIT_OK
249
+ import datetime as _dt
250
+ for e in rows:
251
+ used = _dt.datetime.fromtimestamp(float(e.get("last_used") or 0)).strftime("%Y-%m-%d %H:%M")
252
+ ui.plain(f" {e.get('repo')}@{str(e.get('sha'))[:7]} [{e.get('license')}] {e.get('files')} files, "
253
+ f"{int(e.get('disk') or 0) / osscache.MB:.1f} MB, last used {used}"
254
+ + (" (partial)" if e.get("partial") else ""))
255
+ if not rows:
256
+ ui.dim(" (empty: repos appear here after Euron Code fetches a reference)")
257
+ return EXIT_OK
258
+
259
+
219
260
  def run_trust(ui, root: Path, args) -> int:
220
261
  from euron_code import trust
221
262
  if args.revoke:
@@ -38,7 +38,9 @@ DEFAULTS: Dict[str, Any] = {
38
38
  "attachmentMaxTokens": 6000, # per attached document / folder digest
39
39
  "maxStepsPerPrompt": 60, # model steps per request before asking to continue (-p: exit 6)
40
40
  "verifyNudge": True, # ask the model once to check an unverified change
41
- "reuse": {"enabled": True, "external": True}, # ERIE: find_reusable / reuse searches; external = GitHub
41
+ # ERIE: find_reusable / reuse searches; external = GitHub; local = ask GitHub from this computer and keep
42
+ # fetched repos in ~/.euron/cache/oss (cacheMaxMB total, LRU; repoMaxMB per repo)
43
+ "reuse": {"enabled": True, "external": True, "local": True, "cacheMaxMB": 2048, "repoMaxMB": 50},
42
44
  "errorReporting": True, # send scrubbed error reports to Euron (V5); EURON_NO_ERROR_REPORTS=1 also turns it off
43
45
  "bashTimeout": 120,
44
46
  "shell": None, # None -> auto (PowerShell/cmd on Windows, bash/sh elsewhere)
@@ -0,0 +1,155 @@
1
+ """Licence rules for reusing open-source code (V5 contract section 1).
2
+
3
+ Only these SPDX ids may be copied from: MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, 0BSD, Unlicense,
4
+ MPL-2.0, CC0-1.0, Zlib. Never GPL / AGPL / LGPL / SSPL or anything unlicensed or unknown. MPL-2.0 is
5
+ file-level copyleft: an MPL file stays MPL, keeps its header, and is not mixed into other files.
6
+ The gateway already filters; the client checks again so a bad answer can never slip through.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import datetime as _dt
12
+ from pathlib import Path
13
+ from typing import Optional
14
+
15
+ ALLOWED = {"MIT", "Apache-2.0", "BSD-2-Clause", "BSD-3-Clause", "ISC", "0BSD", "Unlicense", "MPL-2.0", "CC0-1.0",
16
+ "Zlib"}
17
+ FILE_COPYLEFT = {"MPL-2.0"}
18
+ _CANON = {k.lower(): k for k in ALLOWED}
19
+ NOTICES_FILE = "THIRD_PARTY_NOTICES.md"
20
+
21
+
22
+ def canonical(spdx: Optional[str]) -> str:
23
+ s = str(spdx or "").strip()
24
+ return _CANON.get(s.lower(), s)
25
+
26
+
27
+ def is_permitted(spdx: Optional[str]) -> bool:
28
+ return canonical(spdx) in ALLOWED
29
+
30
+
31
+ def is_file_copyleft(spdx: Optional[str]) -> bool:
32
+ return canonical(spdx) in FILE_COPYLEFT
33
+
34
+
35
+ def usage_note(spdx: Optional[str]) -> str:
36
+ lic = canonical(spdx) or "unknown"
37
+ if not is_permitted(lic):
38
+ return f"Licence {lic} is NOT permitted: do not copy or adapt this code."
39
+ if is_file_copyleft(lic):
40
+ return (f"Licence {lic} (file-level copyleft): keep copied files as separate MPL-2.0 files with their header; "
41
+ "do not paste MPL code into the student's own files.")
42
+ return f"Licence {lic}: you may adapt it; keep the copyright / licence notice and record it in {NOTICES_FILE}."
43
+
44
+
45
+ def add_notice(root: Path, source: str, license_id: str, url: str = "", files: str = "", note: str = "") -> Path:
46
+ """Append one entry to the project's THIRD_PARTY_NOTICES.md (created on first use)."""
47
+ path = root / NOTICES_FILE
48
+ lic = canonical(license_id)
49
+ if not is_permitted(lic):
50
+ raise ValueError(f"{lic or 'unknown'} is not a permitted licence; this code must not be reused.")
51
+ existing = path.read_text(encoding="utf-8") if path.exists() else ""
52
+ head = "" if existing else (
53
+ "# Third-party notices\n\nThis project reuses code from these open-source projects. Each keeps its own "
54
+ "licence.\n")
55
+ entry = [f"\n## {source}\n", f"- Licence: {lic}"]
56
+ if url:
57
+ entry.append(f"- Source: {url}")
58
+ if files:
59
+ entry.append(f"- Used in: {files}")
60
+ if note:
61
+ entry.append(f"- Notes: {note}")
62
+ entry.append(f"- Added: {_dt.date.today().isoformat()} by Euron Code")
63
+ if f"## {source}\n" in existing: # already recorded: do not duplicate the entry
64
+ return path
65
+ with open(path, "a", encoding="utf-8") as f:
66
+ f.write(head + "\n".join(entry) + "\n")
67
+ return path
68
+
69
+
70
+ MPL_HEADER = ("This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of "
71
+ "the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.")
72
+ _COMMENT = {
73
+ ".py": "#", ".rb": "#", ".sh": "#", ".bash": "#", ".r": "#", ".pl": "#", ".yaml": "#", ".yml": "#",
74
+ ".toml": "#", ".ps1": "#", ".js": "//", ".jsx": "//", ".ts": "//", ".tsx": "//", ".mjs": "//", ".cjs": "//",
75
+ ".java": "//", ".kt": "//", ".kts": "//", ".scala": "//", ".go": "//", ".rs": "//", ".c": "//", ".h": "//",
76
+ ".cc": "//", ".cpp": "//", ".hpp": "//", ".cs": "//", ".swift": "//", ".dart": "//", ".php": "//",
77
+ ".css": "/*", ".scss": "//", ".less": "//", ".sql": "--", ".lua": "--", ".hs": "--", ".html": "<!--",
78
+ ".vue": "<!--", ".svelte": "<!--", ".xml": "<!--", ".md": "<!--",
79
+ }
80
+
81
+
82
+ def has_licence_header(text: str) -> bool:
83
+ head = "\n".join(text.splitlines()[:30]).lower()
84
+ return any(w in head for w in ("license", "licence", "copyright", "spdx-license-identifier", "(c) "))
85
+
86
+
87
+ def attribution_header(suffix: str, lines: list) -> str:
88
+ """`lines` as a comment block for a file with this suffix ('' when the type has no comment syntax)."""
89
+ c = _COMMENT.get(suffix.lower())
90
+ if c is None:
91
+ return ""
92
+ if c == "/*":
93
+ return "/*\n" + "\n".join(f" * {ln}" for ln in lines) + "\n */\n"
94
+ if c == "<!--":
95
+ return "<!--\n" + "\n".join(f" {ln}" for ln in lines) + "\n-->\n"
96
+ return "\n".join(f"{c} {ln}" for ln in lines) + "\n"
97
+
98
+
99
+ def with_attribution(text: str, suffix: str, repo: str, sha: str, license_id: str, src_path: str) -> str:
100
+ """The file's text as adopted: unchanged when it already carries a licence / copyright header
101
+ (that header is kept as is); otherwise a short attribution comment is added at the top (after a
102
+ shebang). MPL-2.0 files always carry the MPL notice."""
103
+ lic = canonical(license_id)
104
+ lines = [f"Adapted from https://github.com/{repo}/blob/{sha}/{src_path}",
105
+ f"SPDX-License-Identifier: {lic}. See {NOTICES_FILE}."]
106
+ if is_file_copyleft(lic) and "mozilla public license" not in text[:3000].lower():
107
+ lines = [MPL_HEADER] + lines
108
+ elif has_licence_header(text):
109
+ return text
110
+ block = attribution_header(suffix, lines)
111
+ if not block:
112
+ return text
113
+ if text.startswith("#!"):
114
+ first, _, rest = text.partition("\n")
115
+ return first + "\n" + block + rest
116
+ return block + text
117
+
118
+
119
+ def record_adoption(root: Path, repo: str, sha: str, license_id: str, files: list, licence_copy: str = "",
120
+ notice_copy: str = "") -> Path:
121
+ """Add or update `repo`'s entry in THIRD_PARTY_NOTICES.md: source at the pinned commit, licence, the
122
+ files adopted (source -> destination), where the licence text was copied, and the MPL note."""
123
+ lic = canonical(license_id)
124
+ if not is_permitted(lic):
125
+ raise ValueError(f"{lic or 'unknown'} is not a permitted licence; this code must not be reused.")
126
+ path = root / NOTICES_FILE
127
+ existing = path.read_text(encoding="utf-8") if path.exists() else ""
128
+ if not existing:
129
+ existing = ("# Third-party notices\n\nThis project reuses code from these open-source projects. Each keeps "
130
+ "its own licence.\n")
131
+ heading = f"## {repo}\n"
132
+ old_files: list = []
133
+ if heading in existing:
134
+ start = existing.index(heading)
135
+ nxt = existing.find("\n## ", start + len(heading))
136
+ section = existing[start: nxt + 1 if nxt != -1 else len(existing)]
137
+ for ln in section.splitlines():
138
+ if ln.startswith(" - "):
139
+ old_files.append(ln[4:])
140
+ existing = existing[:start].rstrip("\n") + "\n" + (existing[nxt + 1:] if nxt != -1 else "")
141
+ merged = list(dict.fromkeys(old_files + list(files)))
142
+ entry = [f"\n{heading.rstrip()}", f"- Licence: {lic}", f"- Source: https://github.com/{repo}/tree/{sha}",
143
+ f"- Commit: {sha}"]
144
+ if licence_copy:
145
+ entry.append(f"- Licence text: {licence_copy}")
146
+ if notice_copy:
147
+ entry.append(f"- NOTICE: {notice_copy}")
148
+ if is_file_copyleft(lic):
149
+ entry.append("- Notes: MPL-2.0 is file-level copyleft. These files stay under MPL-2.0 with their notice; "
150
+ "changes to them must be shared under MPL-2.0. The rest of the project keeps its own licence.")
151
+ entry.append("- Files (source -> project):")
152
+ entry += [f" - {f}" for f in merged]
153
+ entry.append(f"- Updated: {_dt.date.today().isoformat()} by Euron Code")
154
+ path.write_text(existing.rstrip("\n") + "\n" + "\n".join(entry) + "\n", encoding="utf-8")
155
+ return path