euron-code 0.5.2__tar.gz → 0.7.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.
- {euron_code-0.5.2 → euron_code-0.7.0}/CHANGELOG.md +38 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/PKG-INFO +20 -1
- {euron_code-0.5.2 → euron_code-0.7.0}/README.md +19 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/pyproject.toml +1 -1
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/__init__.py +1 -1
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/activity.py +24 -13
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/agent.py +15 -2
- euron_code-0.7.0/src/euron_code/builtin_skills/build-from-reference/SKILL.md +30 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/cli.py +43 -2
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/config.py +3 -1
- euron_code-0.7.0/src/euron_code/licensing.py +155 -0
- euron_code-0.7.0/src/euron_code/markdown_view.py +331 -0
- euron_code-0.7.0/src/euron_code/osscache.py +608 -0
- euron_code-0.7.0/src/euron_code/ossgithub.py +352 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/prompts.py +1 -1
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/repl.py +113 -32
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/__init__.py +3 -2
- euron_code-0.7.0/src/euron_code/tools/oss.py +611 -0
- euron_code-0.7.0/src/euron_code/transcript.py +368 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/ui.py +161 -16
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/conftest.py +13 -0
- euron_code-0.7.0/tests/test_markdown_view.py +94 -0
- euron_code-0.7.0/tests/test_oss_local.py +524 -0
- euron_code-0.7.0/tests/test_transcript_ui.py +269 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_v3_activity.py +2 -2
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_v3_live_repl.py +19 -2
- euron_code-0.5.2/src/euron_code/builtin_skills/build-from-reference/SKILL.md +0 -28
- euron_code-0.5.2/src/euron_code/licensing.py +0 -67
- euron_code-0.5.2/src/euron_code/tools/oss.py +0 -178
- {euron_code-0.5.2 → euron_code-0.7.0}/.gitignore +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/LICENSE +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/__main__.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/api.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/attachments.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/auth.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/builtin_skills/explain-codebase/SKILL.md +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/builtin_skills/review/SKILL.md +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/builtin_skills/test-writer/SKILL.md +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/cache.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/checkpoints.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/context.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/contextforge/LICENSE +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/contextforge/__init__.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/contextforge/text.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/contextforge/toolout.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/credentials.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/doctor.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/documents.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/error_hints.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/errorlog.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/frontmatter.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/hooks.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/keys.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/memory.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/permissions.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/project_setup.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/repomap.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/rules.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/sessions.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/skills.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/textsafe.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/background.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/base.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/db.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/document.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/erie.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/fs.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/ignore.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/reuse.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/search.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/shell.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/skill.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/symbols.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/task.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/todo.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/tools/web.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/trust.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/src/euron_code/usage_view.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/helpers.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/mock_gateway.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/serve_helper.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_agent_mock.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_api_shell.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_bench.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_cli_e2e.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_context_memory_sessions.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_db.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_erie.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_permissions.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_powershell_exit_codes.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_qa_attach_secrets.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_qa_long_task.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_qa_print_output.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_qa_reuse_unrelated.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_qa_yolo_outside.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_repl.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_search.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_textsafe.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_tools_fs.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_v2_rules_skills_hooks.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_v2_tokens_shortcuts.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_v2_usage_headers.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_v31_security.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_v3_accounts_value_setup.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_v3_attachments.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_v3_context.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_v3_single_login.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_v4.py +0 -0
- {euron_code-0.5.2 → euron_code-0.7.0}/tests/test_v5.py +0 -0
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0 (2026-11-06)
|
|
4
|
+
|
|
5
|
+
Answers are formatted, not raw Markdown.
|
|
6
|
+
|
|
7
|
+
- Tables are drawn as boxed grids that fit the terminal: columns sized to their content, long cells
|
|
8
|
+
wrapped, `:---:` alignment honoured, header in bold. Too narrow for a grid, each row is shown as
|
|
9
|
+
`header: value` lines.
|
|
10
|
+
- **Bold**, *italic*, `code`, ~~strike~~ and links show as styles instead of their markers.
|
|
11
|
+
- Headings, bullet and numbered lists (nested, wrapped under their text), task lists, block quotes and
|
|
12
|
+
horizontal rules are laid out for the terminal.
|
|
13
|
+
- Fenced code is syntax-highlighted and keeps its indentation.
|
|
14
|
+
- Works with `NO_COLOR` and ASCII terminals (`+-|` borders). `euron -p` output is unchanged.
|
|
15
|
+
|
|
16
|
+
## 0.6.0 (2026-11-06)
|
|
17
|
+
|
|
18
|
+
A new look for the interactive session.
|
|
19
|
+
|
|
20
|
+
- Each tool call is a block: `● Bash(npm test)` with its output indented under it. Long output shows
|
|
21
|
+
its first lines and `… +58 lines (ctrl+o to expand)`; Ctrl+O (or `/expand [n]`) prints it in full.
|
|
22
|
+
- Edits show as a numbered diff with added lines on green and removed lines on red.
|
|
23
|
+
- Answers start with a `●` bullet; while Euron Code works, a status line above the input shows what it is
|
|
24
|
+
doing, the time so far and the tokens received.
|
|
25
|
+
- The input sits in a box with a footer: the permission mode on the left (`▸▸ auto-approve on`), with
|
|
26
|
+
`esc to interrupt` while a task runs, and the model, context and today's tokens on the right.
|
|
27
|
+
- `!command` output uses the same block. `euron -p` output is unchanged.
|
|
28
|
+
|
|
29
|
+
Reuse from all of GitHub, on your own computer.
|
|
30
|
+
|
|
31
|
+
- Open-source search now asks GitHub directly from your machine (your own allowance; code search too
|
|
32
|
+
with `gh auth login` or `GITHUB_TOKEN`). The token goes only to GitHub, never to Euron, and is never
|
|
33
|
+
printed. When GitHub is offline or rate limited, Euron's service answers as before.
|
|
34
|
+
- New tools: `oss_fetch` downloads a reference once at a pinned commit into `~/.euron/cache/oss` and
|
|
35
|
+
indexes it; `oss_grep` and `oss_read` then work from your disk; `oss_adopt` copies the files worth
|
|
36
|
+
reusing with their licence header, copies LICENSE / NOTICE and updates `THIRD_PARTY_NOTICES.md`.
|
|
37
|
+
- Licences are checked in code from GitHub's licence detection, and again in the downloaded licence text
|
|
38
|
+
(Commons Clause and non-commercial riders are refused).
|
|
39
|
+
- `euron cache` (list, size, clear). The cache keeps 2 GB by default, least recently used out first.
|
|
40
|
+
|
|
3
41
|
## 0.5.2 (2026-11-05)
|
|
4
42
|
|
|
5
43
|
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.
|
|
3
|
+
Version: 0.7.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.
|
|
7
|
+
version = "0.7.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,6 +1,8 @@
|
|
|
1
1
|
"""The live activity line shown while the agent works, e.g.
|
|
2
2
|
|
|
3
|
-
|
|
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 = ["
|
|
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
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
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
|
|
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
|
-
|
|
179
|
-
|
|
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"{
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|