euron-code 1.1.1__tar.gz → 1.1.3__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-1.1.1 → euron_code-1.1.3}/CHANGELOG.md +15 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/PKG-INFO +18 -3
- {euron_code-1.1.1 → euron_code-1.1.3}/README.md +17 -2
- {euron_code-1.1.1 → euron_code-1.1.3}/pyproject.toml +1 -1
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/__init__.py +1 -1
- euron_code-1.1.3/src/euron_code/__main__.py +7 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/api.py +2 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/cli.py +25 -3
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/doctor.py +17 -0
- euron_code-1.1.3/src/euron_code/pathfix.py +246 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/ignore.py +75 -75
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_permissions.py +91 -91
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v111_user_reports.py +16 -0
- euron_code-1.1.3/tests/test_v113_fix_path.py +205 -0
- euron_code-1.1.1/src/euron_code/__main__.py +0 -4
- {euron_code-1.1.1 → euron_code-1.1.3}/.gitignore +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/LICENSE +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/activity.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/agent.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/attachments.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/auth.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/builtin_skills/build-from-reference/SKILL.md +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/builtin_skills/explain-codebase/SKILL.md +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/builtin_skills/review/SKILL.md +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/builtin_skills/test-writer/SKILL.md +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/cache.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/checkpoints.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/config.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/context.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/contextforge/LICENSE +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/contextforge/__init__.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/contextforge/text.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/contextforge/toolout.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/credentials.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/documents.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/error_hints.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/errorlog.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/frontmatter.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/hooks.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/keys.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/knowledge.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/licensing.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/llm/__init__.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/llm/anthropic.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/llm/base.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/llm/openai_compat.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/llm/setup.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/logo.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/markdown_view.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/memory.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/osscache.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/ossgithub.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/permissions.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/project_setup.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/prompts.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/repl.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/repomap.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/rules.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/security_scan.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/sessions.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/skills.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/textsafe.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/__init__.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/background.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/base.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/db.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/document.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/erie.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/fs.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/normalize.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/oss.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/pathfind.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/reuse.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/search.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/shell.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/skill.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/symbols.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/task.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/todo.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/tools/web.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/transcript.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/trust.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/ui.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/update_check.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/usage_view.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/src/euron_code/version_info.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/conftest.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/fake_providers.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/helpers.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/measure_floor.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/mock_gateway.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/serve_helper.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/sim_long_session.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_agent_mock.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_api_shell.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_bench.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_cli_e2e.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_context_memory_sessions.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_dashboard_fixes.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_dashboard_fixes_102.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_db.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_erie.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_knowledge_security.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_markdown_view.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_oss_local.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_powershell_exit_codes.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_qa_attach_secrets.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_qa_long_task.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_qa_print_output.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_qa_reuse_unrelated.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_qa_yolo_outside.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_repl.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_reuse_honesty.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_search.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_textsafe.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_tools_fs.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_transcript_ui.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_update_check.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v11_byo.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v11_speed.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v11_tool_fixes.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v2_rules_skills_hooks.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v2_tokens_shortcuts.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v2_usage_headers.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v31_security.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v3_accounts_value_setup.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v3_activity.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v3_attachments.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v3_context.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v3_live_repl.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v3_single_login.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v4.py +0 -0
- {euron_code-1.1.1 → euron_code-1.1.3}/tests/test_v5.py +0 -0
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.3 (2026-11-08)
|
|
4
|
+
|
|
5
|
+
- "'euron' is not recognized" (Windows) or "euron: command not found" right after `pip install euron-code`:
|
|
6
|
+
pip put the `euron` command in a Scripts folder that is not on your PATH. New `python -m euron_code fix-path`
|
|
7
|
+
finds that folder and adds it to your user PATH (Windows; no admin, the system PATH is not touched, safe to
|
|
8
|
+
run twice) or prints the line to add to your shell profile (macOS, Linux). Open a new terminal afterwards.
|
|
9
|
+
- `python -m euron_code` (or `py -m euron_code` on Windows) does everything `euron` does, e.g.
|
|
10
|
+
`python -m euron_code login`, and says once how to fix PATH when `euron` is not on it.
|
|
11
|
+
- `euron doctor` has a PATH check.
|
|
12
|
+
|
|
13
|
+
## 1.1.2 (2026-11-07)
|
|
14
|
+
|
|
15
|
+
- A connection that drops in the middle of an answer ("The response stopped part-way ... WinError 10054") now
|
|
16
|
+
also switches Euron Code to IPv4, so the automatic retry of that step takes the working route.
|
|
17
|
+
|
|
3
18
|
## 1.1.1 (2026-11-07)
|
|
4
19
|
|
|
5
20
|
Fixes from support tickets.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: euron-code
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.3
|
|
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>
|
|
@@ -89,6 +89,21 @@ One idea. One prompt. Endless possibilities.
|
|
|
89
89
|
pip install euron-code
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
+
Or let one command install it and put `euron` on your PATH:
|
|
93
|
+
|
|
94
|
+
```powershell
|
|
95
|
+
# Windows PowerShell
|
|
96
|
+
irm https://euron.one/code-agent/install.ps1 | iex
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# macOS / Linux
|
|
101
|
+
curl -fsSL https://euron.one/code-agent/install.sh | sh
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
If the terminal then says `'euron' is not recognized` or `euron: command not found`, run
|
|
105
|
+
`python -m euron_code fix-path` and open a new terminal (see Troubleshooting).
|
|
106
|
+
|
|
92
107
|
**2. Run it in your project folder:**
|
|
93
108
|
|
|
94
109
|
```bash
|
|
@@ -717,7 +732,7 @@ in the editor straight away. Tips:
|
|
|
717
732
|
- On Windows the integrated terminal is PowerShell by default; Euron Code runs commands with
|
|
718
733
|
PowerShell too. To use Git Bash instead: `euron config set shell bash`.
|
|
719
734
|
- If `euron` is not found after `pip install`, the Python `Scripts` folder is not on your PATH.
|
|
720
|
-
|
|
735
|
+
Run `python -m euron_code fix-path` once, then restart VS Code. `python -m euron_code` works meanwhile.
|
|
721
736
|
- Keep your edits saved before asking Euron Code to change the same file.
|
|
722
737
|
|
|
723
738
|
## Troubleshooting
|
|
@@ -741,7 +756,7 @@ number; inside a session use `/version` or `/status`.
|
|
|
741
756
|
| `Cannot reach Euron Code ... WinError 10054` (connection forcibly closed) | your network reset the connection (often a broken IPv6 route, a VPN, a proxy or an antivirus web shield). 1.1.1 and later retry and switch to IPv4 by themselves; you can force it with `EURON_IPV4=1`. If it still fails, allow euron.one in the VPN/antivirus and run `euron doctor` |
|
|
742
757
|
| `pip install -U euron-code` did not change the version | pip updated a different Python. `euron version` prints the exact upgrade command for the Python that runs `euron` |
|
|
743
758
|
| `Client_Requirement_Document.docx looks like a binary file` | fixed in 1.1.1: Word, Excel, PowerPoint and PDF files are read as text |
|
|
744
|
-
| `euron: command not found` |
|
|
759
|
+
| `'euron' is not recognized as the name of a cmdlet` (Windows) or `euron: command not found` | pip put the `euron` command in a Scripts folder that is not on your PATH. Run `python -m euron_code fix-path` (on Windows `py -m euron_code fix-path` works too), then close and reopen the terminal. Right away, `python -m euron_code login` and `python -m euron_code` do everything `euron` does |
|
|
745
760
|
| garbled colours on old Windows consoles | use Windows Terminal or VS Code's terminal |
|
|
746
761
|
|
|
747
762
|
`euron doctor` checks Python, the connection, your login and plan, ripgrep (faster search; optional)
|
|
@@ -23,6 +23,21 @@ One idea. One prompt. Endless possibilities.
|
|
|
23
23
|
pip install euron-code
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
Or let one command install it and put `euron` on your PATH:
|
|
27
|
+
|
|
28
|
+
```powershell
|
|
29
|
+
# Windows PowerShell
|
|
30
|
+
irm https://euron.one/code-agent/install.ps1 | iex
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# macOS / Linux
|
|
35
|
+
curl -fsSL https://euron.one/code-agent/install.sh | sh
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If the terminal then says `'euron' is not recognized` or `euron: command not found`, run
|
|
39
|
+
`python -m euron_code fix-path` and open a new terminal (see Troubleshooting).
|
|
40
|
+
|
|
26
41
|
**2. Run it in your project folder:**
|
|
27
42
|
|
|
28
43
|
```bash
|
|
@@ -651,7 +666,7 @@ in the editor straight away. Tips:
|
|
|
651
666
|
- On Windows the integrated terminal is PowerShell by default; Euron Code runs commands with
|
|
652
667
|
PowerShell too. To use Git Bash instead: `euron config set shell bash`.
|
|
653
668
|
- If `euron` is not found after `pip install`, the Python `Scripts` folder is not on your PATH.
|
|
654
|
-
|
|
669
|
+
Run `python -m euron_code fix-path` once, then restart VS Code. `python -m euron_code` works meanwhile.
|
|
655
670
|
- Keep your edits saved before asking Euron Code to change the same file.
|
|
656
671
|
|
|
657
672
|
## Troubleshooting
|
|
@@ -675,7 +690,7 @@ number; inside a session use `/version` or `/status`.
|
|
|
675
690
|
| `Cannot reach Euron Code ... WinError 10054` (connection forcibly closed) | your network reset the connection (often a broken IPv6 route, a VPN, a proxy or an antivirus web shield). 1.1.1 and later retry and switch to IPv4 by themselves; you can force it with `EURON_IPV4=1`. If it still fails, allow euron.one in the VPN/antivirus and run `euron doctor` |
|
|
676
691
|
| `pip install -U euron-code` did not change the version | pip updated a different Python. `euron version` prints the exact upgrade command for the Python that runs `euron` |
|
|
677
692
|
| `Client_Requirement_Document.docx looks like a binary file` | fixed in 1.1.1: Word, Excel, PowerPoint and PDF files are read as text |
|
|
678
|
-
| `euron: command not found` |
|
|
693
|
+
| `'euron' is not recognized as the name of a cmdlet` (Windows) or `euron: command not found` | pip put the `euron` command in a Scripts folder that is not on your PATH. Run `python -m euron_code fix-path` (on Windows `py -m euron_code fix-path` works too), then close and reopen the terminal. Right away, `python -m euron_code login` and `python -m euron_code` do everything `euron` does |
|
|
679
694
|
| garbled colours on old Windows consoles | use Windows Terminal or VS Code's terminal |
|
|
680
695
|
|
|
681
696
|
`euron doctor` checks Python, the connection, your login and plan, ripgrep (faster search; optional)
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "euron-code"
|
|
7
|
-
version = "1.1.
|
|
7
|
+
version = "1.1.3"
|
|
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"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""`python -m euron_code ...` does everything `euron ...` does. It works even when pip put the `euron` command in
|
|
2
|
+
a folder that is not on PATH ("'euron' is not recognized"); `python -m euron_code fix-path` then fixes PATH."""
|
|
3
|
+
|
|
4
|
+
from euron_code.cli import main
|
|
5
|
+
|
|
6
|
+
if __name__ == "__main__":
|
|
7
|
+
raise SystemExit(main(via_module=True))
|
|
@@ -624,6 +624,8 @@ class Client:
|
|
|
624
624
|
except httpx.HTTPError as e:
|
|
625
625
|
# retry only while nothing came back: the request never reached the model, or was refused
|
|
626
626
|
if "resp" in holder or not is_dropped_connection(e) or attempt == len(NET_RETRY_WAITS) or (cancel is not None and cancel.is_set()):
|
|
627
|
+
if is_dropped_connection(e):
|
|
628
|
+
self._after_drop() # the agent's retry of this step goes over IPv4
|
|
627
629
|
if isinstance(e, httpx.TimeoutException):
|
|
628
630
|
q.put(("error", NetworkError("The connection to Euron Code timed out.")))
|
|
629
631
|
else:
|
|
@@ -18,7 +18,8 @@ from euron_code import __version__, api, auth, config, credentials, llm, session
|
|
|
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", "cache", "models", "version"
|
|
21
|
+
SUBCOMMANDS = ("login", "logout", "whoami", "usage", "users", "doctor", "config", "init", "trust", "cache", "models", "version",
|
|
22
|
+
"fix-path")
|
|
22
23
|
STARTED = __import__("time").monotonic() # session uptime counts from here
|
|
23
24
|
|
|
24
25
|
|
|
@@ -52,7 +53,8 @@ def main_parser() -> argparse.ArgumentParser:
|
|
|
52
53
|
p = argparse.ArgumentParser(
|
|
53
54
|
prog="euron",
|
|
54
55
|
description="Euron Code: an AI coding agent in your terminal (Euron Plus and Super 30).",
|
|
55
|
-
epilog="Commands: euron login [--force] | logout | whoami | version | usage | init | doctor |
|
|
56
|
+
epilog="Commands: euron login [--force] | logout | whoami | version | usage | init | doctor | fix-path | "
|
|
57
|
+
"config get|set|unset|list | "
|
|
56
58
|
"cache list|size|clear | models list|add|remove|use. "
|
|
57
59
|
"Run `euron` with no arguments for an interactive session.",
|
|
58
60
|
)
|
|
@@ -120,9 +122,26 @@ def sub_parser(cmd: str) -> argparse.ArgumentParser:
|
|
|
120
122
|
return p
|
|
121
123
|
|
|
122
124
|
|
|
123
|
-
def
|
|
125
|
+
def _path_hint(argv: List[str]) -> None:
|
|
126
|
+
"""Run as `python -m euron_code` because `euron` is not found? Say once per run how to fix that for good."""
|
|
127
|
+
if argv[:1] == ["fix-path"] or "--output-format" in argv:
|
|
128
|
+
return
|
|
129
|
+
try:
|
|
130
|
+
if not sys.stderr.isatty():
|
|
131
|
+
return
|
|
132
|
+
from euron_code import pathfix
|
|
133
|
+
tip = pathfix.hint()
|
|
134
|
+
if tip:
|
|
135
|
+
print(tip, file=sys.stderr)
|
|
136
|
+
except Exception:
|
|
137
|
+
pass
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def main(argv: Optional[List[str]] = None, via_module: bool = False) -> int:
|
|
124
141
|
_fix_windows_console()
|
|
125
142
|
argv = list(sys.argv[1:] if argv is None else argv)
|
|
143
|
+
if via_module:
|
|
144
|
+
_path_hint(argv)
|
|
126
145
|
try:
|
|
127
146
|
if argv and argv[0] in ("version", "-v"): # `euron version`: version, Python, newer release on PyPI
|
|
128
147
|
from euron_code import version_info
|
|
@@ -213,6 +232,9 @@ def run_subcommand(cmd: str, args) -> int:
|
|
|
213
232
|
if cmd == "doctor":
|
|
214
233
|
from euron_code.doctor import doctor
|
|
215
234
|
return doctor(ui)
|
|
235
|
+
if cmd == "fix-path":
|
|
236
|
+
from euron_code import pathfix
|
|
237
|
+
return pathfix.fix_path(out=print)
|
|
216
238
|
if cmd == "config":
|
|
217
239
|
return run_config(ui, args)
|
|
218
240
|
if cmd == "cache":
|
|
@@ -17,6 +17,22 @@ from euron_code.tools.shell import detect_shell
|
|
|
17
17
|
OK, WARN, FAIL = "ok", "warn", "fail"
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
def path_check() -> Tuple[str, str, str]:
|
|
21
|
+
"""Is the folder with the `euron` command on PATH? ("'euron' is not recognized" after pip install)"""
|
|
22
|
+
try:
|
|
23
|
+
from euron_code import pathfix
|
|
24
|
+
d, here, later = pathfix.status()
|
|
25
|
+
except Exception as e:
|
|
26
|
+
return ("PATH", WARN, f"could not check: {type(e).__name__}")
|
|
27
|
+
if not d:
|
|
28
|
+
return ("PATH", WARN, "the euron command was not found for this Python; `python -m euron_code` works")
|
|
29
|
+
if here:
|
|
30
|
+
return ("PATH", OK, d)
|
|
31
|
+
if later:
|
|
32
|
+
return ("PATH", WARN, f"{d} is on your PATH for new terminals; open a new terminal")
|
|
33
|
+
return ("PATH", WARN, f"{d} is not on PATH, so `euron` is not found. Fix: python -m euron_code fix-path")
|
|
34
|
+
|
|
35
|
+
|
|
20
36
|
def run_checks() -> List[Tuple[str, str, str]]:
|
|
21
37
|
checks: List[Tuple[str, str, str]] = []
|
|
22
38
|
v = sys.version_info
|
|
@@ -24,6 +40,7 @@ def run_checks() -> List[Tuple[str, str, str]]:
|
|
|
24
40
|
f"{platform.python_version()} ({sys.executable})"))
|
|
25
41
|
checks.append(("euron-code", OK, __version__))
|
|
26
42
|
checks.append(("Platform", OK, f"{platform.system()} {platform.release()} {platform.machine()}"))
|
|
43
|
+
checks.append(path_check())
|
|
27
44
|
url = config.base_url()
|
|
28
45
|
if os.environ.get("EURON_CODE_API"): # a developer override; the default is not shown
|
|
29
46
|
checks.append(("API base URL", OK, f"{url} (EURON_CODE_API)"))
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"""`euron fix-path` / `python -m euron_code fix-path`: put the folder that holds the `euron` command on PATH.
|
|
2
|
+
|
|
3
|
+
The most common install problem (support tickets, 2026-11): `pip install euron-code` succeeds, then PowerShell
|
|
4
|
+
says "The term 'euron' is not recognized". pip put `euron.exe` in a Scripts folder that is not on PATH, either
|
|
5
|
+
`%APPDATA%\\Python\\Python3XX\\Scripts` (a user install) or the Microsoft Store Python's
|
|
6
|
+
`...\\LocalCache\\local-packages\\Python3XX\\Scripts`. `python -m euron_code` always works; this module finds that
|
|
7
|
+
folder and adds it to the *user* PATH (never the system PATH, never needs admin). On macOS and Linux it prints
|
|
8
|
+
the line to add to the shell profile instead of editing it.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import os
|
|
14
|
+
import sys
|
|
15
|
+
import sysconfig
|
|
16
|
+
from typing import Iterable, List, Optional, Tuple
|
|
17
|
+
|
|
18
|
+
COMMAND = "euron"
|
|
19
|
+
DIST = "euron-code"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _norm(p: str) -> str:
|
|
23
|
+
p = os.path.expandvars(os.path.expanduser((p or "").strip().strip('"')))
|
|
24
|
+
return os.path.normcase(os.path.normpath(p)) if p else ""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _exe_names() -> Tuple[str, ...]:
|
|
28
|
+
return (COMMAND + ".exe", COMMAND) if os.name == "nt" else (COMMAND,)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _has_command(folder: str) -> bool:
|
|
32
|
+
return bool(folder) and any(os.path.isfile(os.path.join(folder, n)) for n in _exe_names())
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _user_scheme() -> str:
|
|
36
|
+
try:
|
|
37
|
+
return sysconfig.get_preferred_scheme("user") # type: ignore[attr-defined] # 3.10+
|
|
38
|
+
except Exception:
|
|
39
|
+
return f"{os.name}_user"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def candidate_dirs() -> List[str]:
|
|
43
|
+
"""Where pip may have put the `euron` command for the Python that is running, most likely first."""
|
|
44
|
+
out: List[str] = []
|
|
45
|
+
|
|
46
|
+
def add(p: Optional[str]) -> None:
|
|
47
|
+
if p and _norm(p) not in {_norm(x) for x in out}:
|
|
48
|
+
out.append(os.path.normpath(p))
|
|
49
|
+
|
|
50
|
+
for scheme in (None, _user_scheme(), f"{os.name}_user"):
|
|
51
|
+
try:
|
|
52
|
+
add(sysconfig.get_path("scripts") if scheme is None else sysconfig.get_path("scripts", scheme))
|
|
53
|
+
except Exception:
|
|
54
|
+
pass
|
|
55
|
+
try: # what pip recorded at install time, wherever that was
|
|
56
|
+
from importlib import metadata
|
|
57
|
+
for f in metadata.distribution(DIST).files or []:
|
|
58
|
+
if os.path.basename(str(f)).lower() in {n.lower() for n in _exe_names()}:
|
|
59
|
+
add(os.path.dirname(os.path.abspath(str(f.locate()))))
|
|
60
|
+
except Exception:
|
|
61
|
+
pass
|
|
62
|
+
return out
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def scripts_dir() -> Optional[str]:
|
|
66
|
+
"""The folder that actually holds the `euron` command, or None when none of the candidates has it."""
|
|
67
|
+
for d in candidate_dirs():
|
|
68
|
+
if _has_command(d):
|
|
69
|
+
return d
|
|
70
|
+
return None
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _split(path_value: str, sep: str = os.pathsep) -> List[str]:
|
|
74
|
+
return [p for p in (path_value or "").split(sep) if p.strip()]
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _contains(entries: Iterable[str], folder: str) -> bool:
|
|
78
|
+
want = _norm(folder)
|
|
79
|
+
return any(_norm(e) == want for e in entries)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def in_process_path(folder: str) -> bool:
|
|
83
|
+
return _contains(_split(os.environ.get("PATH", "")), folder)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# ---------------------------------------------------------------- Windows registry (user PATH)
|
|
87
|
+
|
|
88
|
+
ENV_KEY = "Environment"
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _winreg():
|
|
92
|
+
import winreg # only on Windows; tests pass a fake
|
|
93
|
+
return winreg
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def read_user_path(winreg=None) -> Tuple[str, Optional[int]]:
|
|
97
|
+
"""The user PATH from HKCU\\Environment as (value, registry type); ("", None) when there is none."""
|
|
98
|
+
winreg = winreg or _winreg()
|
|
99
|
+
try:
|
|
100
|
+
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, ENV_KEY, 0, winreg.KEY_READ) as k:
|
|
101
|
+
value, kind = winreg.QueryValueEx(k, "Path")
|
|
102
|
+
return str(value or ""), kind
|
|
103
|
+
except FileNotFoundError:
|
|
104
|
+
return "", None
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def in_user_path(folder: str, winreg=None) -> bool:
|
|
108
|
+
try:
|
|
109
|
+
return _contains(_split(read_user_path(winreg)[0], ";"), folder)
|
|
110
|
+
except Exception:
|
|
111
|
+
return False
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
SYSTEM_ENV_KEY = r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def in_system_path(folder: str, winreg=None) -> bool:
|
|
118
|
+
"""Read-only check of the machine PATH (an all-users Python install puts Scripts there)."""
|
|
119
|
+
try:
|
|
120
|
+
winreg = winreg or _winreg()
|
|
121
|
+
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, SYSTEM_ENV_KEY, 0, winreg.KEY_READ) as k:
|
|
122
|
+
return _contains(_split(str(winreg.QueryValueEx(k, "Path")[0] or ""), ";"), folder)
|
|
123
|
+
except Exception:
|
|
124
|
+
return False
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def add_to_user_path(folder: str, winreg=None) -> bool:
|
|
128
|
+
"""Append `folder` to the user PATH in HKCU\\Environment. Returns False when it was already there.
|
|
129
|
+
|
|
130
|
+
Reads and writes the registry directly: `setx PATH` cuts the value at 1024 characters and mixes the system
|
|
131
|
+
PATH into the user one. The existing value type is kept (REG_EXPAND_SZ keeps %VARIABLES% working).
|
|
132
|
+
"""
|
|
133
|
+
winreg = winreg or _winreg()
|
|
134
|
+
current, kind = read_user_path(winreg)
|
|
135
|
+
entries = _split(current, ";") # the registry value is ";"-separated, whatever os.pathsep says
|
|
136
|
+
if _contains(entries, folder):
|
|
137
|
+
return False
|
|
138
|
+
new_value = ";".join(entries + [folder])
|
|
139
|
+
with winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, ENV_KEY, 0, winreg.KEY_SET_VALUE) as k:
|
|
140
|
+
winreg.SetValueEx(k, "Path", 0, kind if kind is not None else winreg.REG_EXPAND_SZ, new_value)
|
|
141
|
+
return True
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def broadcast_environment_change() -> None:
|
|
145
|
+
"""Tell Explorer (and terminals started from it) that the environment changed, as the Settings app does."""
|
|
146
|
+
try:
|
|
147
|
+
import ctypes
|
|
148
|
+
from ctypes import wintypes
|
|
149
|
+
result = wintypes.DWORD()
|
|
150
|
+
ctypes.windll.user32.SendMessageTimeoutW(0xFFFF, 0x001A, 0, "Environment", 0x0002, 5000,
|
|
151
|
+
ctypes.byref(result))
|
|
152
|
+
except Exception:
|
|
153
|
+
pass
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
# ---------------------------------------------------------------- what to tell the user
|
|
157
|
+
|
|
158
|
+
def _python_cmd() -> str:
|
|
159
|
+
"""The other usual name of Python: the Windows launcher `py`, or `python3` on macOS and Linux."""
|
|
160
|
+
return "py" if os.name == "nt" else "python3"
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def _is_windows() -> bool:
|
|
164
|
+
return os.name == "nt"
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _in_venv() -> bool:
|
|
168
|
+
return getattr(sys, "base_prefix", sys.prefix) != sys.prefix
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def shell_profile() -> Tuple[str, str]:
|
|
172
|
+
"""(profile file, line format) for the user's shell on macOS / Linux."""
|
|
173
|
+
shell = os.path.basename(os.environ.get("SHELL", ""))
|
|
174
|
+
if shell == "fish":
|
|
175
|
+
return "~/.config/fish/config.fish", "fish_add_path {dir}"
|
|
176
|
+
if shell == "zsh":
|
|
177
|
+
return "~/.zshrc", 'export PATH="{dir}:$PATH"'
|
|
178
|
+
if shell == "bash" and sys.platform == "darwin":
|
|
179
|
+
return "~/.bash_profile", 'export PATH="{dir}:$PATH"'
|
|
180
|
+
return ("~/.bashrc" if shell == "bash" else "~/.profile"), 'export PATH="{dir}:$PATH"'
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def status() -> Tuple[Optional[str], bool, bool]:
|
|
184
|
+
"""(scripts dir or None, on PATH in this terminal, on PATH for new terminals)."""
|
|
185
|
+
d = scripts_dir()
|
|
186
|
+
if not d:
|
|
187
|
+
return None, False, False
|
|
188
|
+
here = in_process_path(d)
|
|
189
|
+
later = here or (os.name == "nt" and (in_user_path(d) or in_system_path(d)))
|
|
190
|
+
return d, here, later
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def hint() -> Optional[str]:
|
|
194
|
+
"""One line for `python -m euron_code` when the `euron` command is not on PATH yet, else None."""
|
|
195
|
+
try:
|
|
196
|
+
d, here, later = status()
|
|
197
|
+
except Exception:
|
|
198
|
+
return None
|
|
199
|
+
if not d or here:
|
|
200
|
+
return None
|
|
201
|
+
if later:
|
|
202
|
+
return "Tip: the euron command is set up; open a new terminal to use it."
|
|
203
|
+
return (f"Tip: the euron command is not on your PATH yet. Run `python -m euron_code fix-path` once "
|
|
204
|
+
f"(or `{_python_cmd()} -m euron_code fix-path`) so `euron` works in every terminal.")
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def fix_path(out=print) -> int:
|
|
208
|
+
"""The `fix-path` command. Idempotent: running it twice changes nothing the second time."""
|
|
209
|
+
d = scripts_dir()
|
|
210
|
+
if not d:
|
|
211
|
+
out("Could not find the folder that holds the euron command for this Python "
|
|
212
|
+
f"({sys.executable}).")
|
|
213
|
+
out(f"Reinstall it with: {_python_cmd()} -m pip install --upgrade euron-code")
|
|
214
|
+
out("Until then, `python -m euron_code` works everywhere `euron` does, e.g. `python -m euron_code login`.")
|
|
215
|
+
return 1
|
|
216
|
+
out(f"The euron command is in: {d}")
|
|
217
|
+
if _in_venv():
|
|
218
|
+
out("This Python is a virtual environment: activate it and `euron` is on PATH there. "
|
|
219
|
+
"Nothing was changed.")
|
|
220
|
+
return 0
|
|
221
|
+
if _is_windows():
|
|
222
|
+
try:
|
|
223
|
+
added = False if in_system_path(d) else add_to_user_path(d)
|
|
224
|
+
except Exception as e:
|
|
225
|
+
out(f"Could not update your PATH: {type(e).__name__}: {e}")
|
|
226
|
+
out("Add the folder above yourself: Start > 'Edit environment variables for your account' > Path > "
|
|
227
|
+
"New. Or keep using `python -m euron_code`.")
|
|
228
|
+
return 1
|
|
229
|
+
if not in_process_path(d):
|
|
230
|
+
os.environ["PATH"] = os.environ.get("PATH", "").rstrip(os.pathsep) + os.pathsep + d
|
|
231
|
+
if added:
|
|
232
|
+
broadcast_environment_change()
|
|
233
|
+
out("Added it to your user PATH (no admin needed; the system PATH was not touched).")
|
|
234
|
+
else:
|
|
235
|
+
out("It is already on your PATH. Nothing to change.")
|
|
236
|
+
out("Close this terminal (and VS Code, if you use its terminal), open a new one, then run: euron login")
|
|
237
|
+
return 0
|
|
238
|
+
if in_process_path(d):
|
|
239
|
+
out("It is already on your PATH. Nothing to change. Run: euron login")
|
|
240
|
+
return 0
|
|
241
|
+
profile, fmt = shell_profile()
|
|
242
|
+
line = fmt.format(dir=d)
|
|
243
|
+
out(f"Add this line to {profile}, then open a new terminal:")
|
|
244
|
+
out(f" {line}")
|
|
245
|
+
out(f"For example: echo '{line}' >> {profile}")
|
|
246
|
+
return 0
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
"""Best-effort ignore rules for the Python fallbacks of glob/grep/list_dir."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import fnmatch
|
|
6
|
-
import os
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
from typing import Iterator, List, Tuple
|
|
9
|
-
|
|
10
|
-
ALWAYS_SKIP_DIRS = {
|
|
11
|
-
".git", ".hg", ".svn", "node_modules", "__pycache__", ".venv", "venv", "env", ".tox",
|
|
12
|
-
".mypy_cache", ".pytest_cache", ".ruff_cache", ".next", ".nuxt", "dist", "build",
|
|
13
|
-
".idea", ".gradle", "target", ".cache", "coverage", ".turbo", ".parcel-cache",
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class GitIgnore:
|
|
18
|
-
"""A small subset of .gitignore: root .gitignore, simple globs, dir patterns, negation ignored."""
|
|
19
|
-
|
|
20
|
-
def __init__(self, root: Path):
|
|
21
|
-
self.root = root
|
|
22
|
-
self.patterns: List[Tuple[str, bool]] = [] # (pattern, dir_only)
|
|
23
|
-
try:
|
|
24
|
-
with open(root / ".gitignore", "r", encoding="utf-8", errors="replace") as f:
|
|
25
|
-
for line in f:
|
|
26
|
-
line = line.strip()
|
|
27
|
-
if not line or line.startswith("#") or line.startswith("!"):
|
|
28
|
-
continue
|
|
29
|
-
dir_only = line.endswith("/")
|
|
30
|
-
self.patterns.append((line.strip("/"), dir_only))
|
|
31
|
-
except OSError:
|
|
32
|
-
pass
|
|
33
|
-
|
|
34
|
-
def ignored(self, rel_posix: str, is_dir: bool) -> bool:
|
|
35
|
-
name = rel_posix.rsplit("/", 1)[-1]
|
|
36
|
-
for pat, dir_only in self.patterns:
|
|
37
|
-
if dir_only and not is_dir:
|
|
38
|
-
continue
|
|
39
|
-
if "/" in pat:
|
|
40
|
-
if fnmatch.fnmatch(rel_posix, pat.lstrip("/")) or fnmatch.fnmatch(rel_posix, pat.lstrip("/") + "/*"):
|
|
41
|
-
return True
|
|
42
|
-
elif fnmatch.fnmatch(name, pat):
|
|
43
|
-
return True
|
|
44
|
-
return False
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def walk_files(base: Path, root: Path) -> Iterator[Path]:
|
|
48
|
-
gi = GitIgnore(root)
|
|
49
|
-
for dirpath, dirnames, filenames in os.walk(base):
|
|
50
|
-
dp = Path(dirpath)
|
|
51
|
-
keep = []
|
|
52
|
-
for d in dirnames:
|
|
53
|
-
if d in ALWAYS_SKIP_DIRS:
|
|
54
|
-
continue
|
|
55
|
-
try:
|
|
56
|
-
rel = (dp / d).relative_to(root).as_posix()
|
|
57
|
-
except ValueError:
|
|
58
|
-
rel = d
|
|
59
|
-
if gi.ignored(rel, True):
|
|
60
|
-
continue
|
|
61
|
-
keep.append(d)
|
|
62
|
-
dirnames[:] = sorted(keep)
|
|
63
|
-
for fn in sorted(filenames):
|
|
64
|
-
p = dp / fn
|
|
65
|
-
try:
|
|
66
|
-
rel = p.relative_to(root).as_posix()
|
|
67
|
-
except ValueError:
|
|
68
|
-
rel = fn
|
|
69
|
-
if gi.ignored(rel, False):
|
|
70
|
-
continue
|
|
71
|
-
yield p
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def is_binary_bytes(data: bytes) -> bool:
|
|
75
|
-
return b"\x00" in data[:8192]
|
|
1
|
+
"""Best-effort ignore rules for the Python fallbacks of glob/grep/list_dir."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import fnmatch
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Iterator, List, Tuple
|
|
9
|
+
|
|
10
|
+
ALWAYS_SKIP_DIRS = {
|
|
11
|
+
".git", ".hg", ".svn", "node_modules", "__pycache__", ".venv", "venv", "env", ".tox",
|
|
12
|
+
".mypy_cache", ".pytest_cache", ".ruff_cache", ".next", ".nuxt", "dist", "build",
|
|
13
|
+
".idea", ".gradle", "target", ".cache", "coverage", ".turbo", ".parcel-cache",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class GitIgnore:
|
|
18
|
+
"""A small subset of .gitignore: root .gitignore, simple globs, dir patterns, negation ignored."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, root: Path):
|
|
21
|
+
self.root = root
|
|
22
|
+
self.patterns: List[Tuple[str, bool]] = [] # (pattern, dir_only)
|
|
23
|
+
try:
|
|
24
|
+
with open(root / ".gitignore", "r", encoding="utf-8", errors="replace") as f:
|
|
25
|
+
for line in f:
|
|
26
|
+
line = line.strip()
|
|
27
|
+
if not line or line.startswith("#") or line.startswith("!"):
|
|
28
|
+
continue
|
|
29
|
+
dir_only = line.endswith("/")
|
|
30
|
+
self.patterns.append((line.strip("/"), dir_only))
|
|
31
|
+
except OSError:
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
def ignored(self, rel_posix: str, is_dir: bool) -> bool:
|
|
35
|
+
name = rel_posix.rsplit("/", 1)[-1]
|
|
36
|
+
for pat, dir_only in self.patterns:
|
|
37
|
+
if dir_only and not is_dir:
|
|
38
|
+
continue
|
|
39
|
+
if "/" in pat:
|
|
40
|
+
if fnmatch.fnmatch(rel_posix, pat.lstrip("/")) or fnmatch.fnmatch(rel_posix, pat.lstrip("/") + "/*"):
|
|
41
|
+
return True
|
|
42
|
+
elif fnmatch.fnmatch(name, pat):
|
|
43
|
+
return True
|
|
44
|
+
return False
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def walk_files(base: Path, root: Path) -> Iterator[Path]:
|
|
48
|
+
gi = GitIgnore(root)
|
|
49
|
+
for dirpath, dirnames, filenames in os.walk(base):
|
|
50
|
+
dp = Path(dirpath)
|
|
51
|
+
keep = []
|
|
52
|
+
for d in dirnames:
|
|
53
|
+
if d in ALWAYS_SKIP_DIRS:
|
|
54
|
+
continue
|
|
55
|
+
try:
|
|
56
|
+
rel = (dp / d).relative_to(root).as_posix()
|
|
57
|
+
except ValueError:
|
|
58
|
+
rel = d
|
|
59
|
+
if gi.ignored(rel, True):
|
|
60
|
+
continue
|
|
61
|
+
keep.append(d)
|
|
62
|
+
dirnames[:] = sorted(keep)
|
|
63
|
+
for fn in sorted(filenames):
|
|
64
|
+
p = dp / fn
|
|
65
|
+
try:
|
|
66
|
+
rel = p.relative_to(root).as_posix()
|
|
67
|
+
except ValueError:
|
|
68
|
+
rel = fn
|
|
69
|
+
if gi.ignored(rel, False):
|
|
70
|
+
continue
|
|
71
|
+
yield p
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def is_binary_bytes(data: bytes) -> bool:
|
|
75
|
+
return b"\x00" in data[:8192]
|