euron-code 1.8.4__tar.gz → 1.8.6__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.8.4 → euron_code-1.8.6}/CHANGELOG.md +21 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/PKG-INFO +5 -2
- {euron_code-1.8.4 → euron_code-1.8.6}/README.md +3 -1
- {euron_code-1.8.4 → euron_code-1.8.6}/pyproject.toml +2 -2
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/__init__.py +1 -1
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/agent.py +54 -9
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/permissions.py +42 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/repl.py +33 -16
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/ignore.py +75 -75
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_permissions.py +91 -91
- euron_code-1.8.6/tests/test_render_ghost.py +146 -0
- euron_code-1.8.6/tests/test_v186_bypass_and_waits.py +223 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v3_live_repl.py +4 -2
- {euron_code-1.8.4 → euron_code-1.8.6}/.gitignore +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/LICENSE +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/__main__.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/activity.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/api.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/attachments.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/auth.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/autoupdate.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/builtin_skills/build-from-reference/SKILL.md +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/builtin_skills/explain-codebase/SKILL.md +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/builtin_skills/review/SKILL.md +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/builtin_skills/test-writer/SKILL.md +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/cache.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/checkpoints.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/cli.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/codeindex.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/config.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/context.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/contextforge/LICENSE +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/contextforge/__init__.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/contextforge/text.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/contextforge/toolout.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/credentials.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/ctxstats.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/doctor.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/documents.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/dotnet.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/error_hints.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/errorlog.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/failures.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/friendly.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/frontmatter.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/hooks.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/keys.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/knowledge.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/licensing.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/llm/__init__.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/llm/anthropic.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/llm/base.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/llm/openai_compat.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/llm/setup.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/logo.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/markdown_view.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/memory.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/migration.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/modes.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/mvc5.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/osscache.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/ossgithub.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/pasteinput.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/pathfix.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/progress.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/project_setup.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/prompts.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/repomap.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/rules.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/security_scan.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/sessions.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/skills.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/taskstate.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/textsafe.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tls.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/__init__.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/background.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/base.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/db.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/document.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/erie.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/fs.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/normalize.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/oss.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/pathfind.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/port.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/reuse.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/search.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/shell.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/skill.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/symbols.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/task.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/todo.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/web.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/tools/websearch.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/transcript.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/trust.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/ui.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/update_check.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/usage_view.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/version_info.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/src/euron_code/webforms.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/conftest.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/fake_providers.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/helpers.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/measure_floor.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/mock_gateway.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/serve_helper.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/sim_long_session.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_agent_mock.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_api_shell.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_bench.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_bench_harness.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_cli_e2e.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_context_memory_sessions.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_dashboard_fixes.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_dashboard_fixes_102.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_db.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_erie.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_knowledge_security.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_markdown_view.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_oss_local.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_powershell_exit_codes.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_qa_attach_secrets.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_qa_long_task.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_qa_print_output.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_qa_reuse_unrelated.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_qa_yolo_outside.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_repl.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_reuse_honesty.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_search.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_textsafe.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_tools_fs.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_transcript_ui.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_update_check.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v111_user_reports.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v113_fix_path.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v11_byo.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v11_speed.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v11_tool_fixes.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v130_cut_writes.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v130_reliability.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v140_parity.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v152_migration.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v153_user_errors.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v155_user_errors.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v156_autoupdate.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v156_paste_and_edits.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v157_zero_errors.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v15_hosted_models.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v15_reuse_off_subagent_hooks.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v160_stop_scope_atomic.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v161_residual_errors.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v170_v2.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v180_rescue_research_permissions.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v181_silent_failures_verified.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v182_zero_errors.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v184_selfupdate_pep668.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v2_rules_skills_hooks.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v2_tokens_shortcuts.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v2_usage_headers.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v31_security.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v3_accounts_value_setup.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v3_activity.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v3_attachments.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v3_context.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v3_single_login.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v4.py +0 -0
- {euron_code-1.8.4 → euron_code-1.8.6}/tests/test_v5.py +0 -0
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.8.6 (2026-11-17)
|
|
4
|
+
|
|
5
|
+
- **`--dangerously-skip-permissions` stays on for the whole session, sub-agents included.** Shift+Tab, `/plan` off
|
|
6
|
+
and accepting a plan used to switch a bypass session back to "default" (or "accept edits"), and from then on
|
|
7
|
+
every edit asked, the sub-agents' edits too. Now Shift+Tab switches between bypass and plan only, leaving plan
|
|
8
|
+
mode goes back to bypass, and "(a)" after a plan means "go without asking". `/permissions mode default` still
|
|
9
|
+
turns bypass off when you want that. Paths outside the project and destructive commands still ask, as before.
|
|
10
|
+
- **Long waits for the model say what is happening.** The live line shows how long the current request has waited,
|
|
11
|
+
which try it is and the time in all ("waiting for the model 3m 12s, try 2, 5m 40s in all"), and after 2 and 5
|
|
12
|
+
minutes a line says the model is slow, that Esc stops and that your message is kept for /retry. Retries of one
|
|
13
|
+
request now stop after 10 minutes in all (before, waiting in a long queue could go on for much longer).
|
|
14
|
+
|
|
15
|
+
## 1.8.5 (2026-11-16)
|
|
16
|
+
|
|
17
|
+
- **The input box no longer jumps down and leaves copies of itself behind.** In Windows Terminal, VS Code and other
|
|
18
|
+
terminals, the lines around the `>` input were drawn one column short of the edge; when the terminal got a little
|
|
19
|
+
narrower (a window or panel resize, a scrollbar appearing) they were re-wrapped onto two rows and the next redraw
|
|
20
|
+
(often the next key, such as Space) left the old box on screen, so the cursor seemed to jump to a new line. The
|
|
21
|
+
rules and footer now keep 4 columns free, so small width changes no longer wrap them. New tests draw the prompt in a
|
|
22
|
+
terminal emulator and check that empty Enter / Space presses (also around a running task) leave a single box.
|
|
23
|
+
|
|
3
24
|
## 1.8.4 (2026-11-14)
|
|
4
25
|
|
|
5
26
|
- Updates itself on Linux and macOS system Pythons that refuse plain pip installs ("externally managed": recent
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: euron-code
|
|
3
|
-
Version: 1.8.
|
|
3
|
+
Version: 1.8.6
|
|
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>
|
|
@@ -55,6 +55,7 @@ Requires-Dist: psycopg[binary]>=3.1; extra == 'db'
|
|
|
55
55
|
Requires-Dist: pymysql>=1.0; extra == 'db'
|
|
56
56
|
Provides-Extra: dev
|
|
57
57
|
Requires-Dist: build>=1.0; extra == 'dev'
|
|
58
|
+
Requires-Dist: pyte>=0.8; extra == 'dev'
|
|
58
59
|
Requires-Dist: pytest>=7; extra == 'dev'
|
|
59
60
|
Provides-Extra: images
|
|
60
61
|
Requires-Dist: pillow>=9.0; extra == 'images'
|
|
@@ -336,7 +337,9 @@ how full the context is, what is left today and this week, and how long the sess
|
|
|
336
337
|
| plan | Shift+Tab twice, `/plan` | read-only; it proposes a plan, you decide when it may act |
|
|
337
338
|
| bypass | `euron --dangerously-skip-permissions` (or `--permission-mode bypassPermissions`, `--yolo`) | nothing asks. Only in a throwaway folder or container. Paths outside the project still ask |
|
|
338
339
|
|
|
339
|
-
Shift+Tab cycles default -> acceptEdits -> plan
|
|
340
|
+
Shift+Tab cycles default -> acceptEdits -> plan. In a session started with bypass it switches between bypass and
|
|
341
|
+
plan only, and leaving plan mode (Shift+Tab, `/plan`, accepting a plan with `a`) goes back to bypass, sub-agents
|
|
342
|
+
included. `/permissions mode default` turns bypass off when you want edits to ask again.
|
|
340
343
|
`--add-dir ../shared` lets it also work in another folder.
|
|
341
344
|
|
|
342
345
|
## Your code and your account
|
|
@@ -270,7 +270,9 @@ how full the context is, what is left today and this week, and how long the sess
|
|
|
270
270
|
| plan | Shift+Tab twice, `/plan` | read-only; it proposes a plan, you decide when it may act |
|
|
271
271
|
| bypass | `euron --dangerously-skip-permissions` (or `--permission-mode bypassPermissions`, `--yolo`) | nothing asks. Only in a throwaway folder or container. Paths outside the project still ask |
|
|
272
272
|
|
|
273
|
-
Shift+Tab cycles default -> acceptEdits -> plan
|
|
273
|
+
Shift+Tab cycles default -> acceptEdits -> plan. In a session started with bypass it switches between bypass and
|
|
274
|
+
plan only, and leaving plan mode (Shift+Tab, `/plan`, accepting a plan with `a`) goes back to bypass, sub-agents
|
|
275
|
+
included. `/permissions mode default` turns bypass off when you want edits to ask again.
|
|
274
276
|
`--add-dir ../shared` lets it also work in another folder.
|
|
275
277
|
|
|
276
278
|
## Your code and your account
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "euron-code"
|
|
7
|
-
version = "1.8.
|
|
7
|
+
version = "1.8.6"
|
|
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"
|
|
@@ -40,7 +40,7 @@ mysql = ["PyMySQL>=1.0"]
|
|
|
40
40
|
db = ["psycopg[binary]>=3.1", "PyMySQL>=1.0"]
|
|
41
41
|
images = ["Pillow>=9.0"]
|
|
42
42
|
browser = ["playwright>=1.40"]
|
|
43
|
-
dev = ["pytest>=7", "build>=1.0"]
|
|
43
|
+
dev = ["pytest>=7", "build>=1.0", "pyte>=0.8"]
|
|
44
44
|
|
|
45
45
|
[project.urls]
|
|
46
46
|
Homepage = "https://euron.one/code-agent"
|
|
@@ -20,7 +20,7 @@ from pathlib import Path
|
|
|
20
20
|
from typing import Any, Callable, Dict, List, Optional, Tuple
|
|
21
21
|
|
|
22
22
|
from euron_code import api, context, failures, licensing, memory, modes, progress, prompts, rules, skills, taskstate
|
|
23
|
-
from euron_code.activity import Activity, phase_from_comment, tool_label
|
|
23
|
+
from euron_code.activity import Activity, fmt_elapsed, phase_from_comment, tool_label
|
|
24
24
|
from euron_code.api import (BusyError, ContextTooLongError, EuronError, Interrupted, MidStreamError,
|
|
25
25
|
NetworkError, RateLimitedError)
|
|
26
26
|
from euron_code.checkpoints import Checkpoints
|
|
@@ -41,6 +41,12 @@ MIDSTREAM_BACKOFF = [1, 2, 4, 8, 15, 30] # automatic retries after a stream dro
|
|
|
41
41
|
# turn, up to about 10 minutes, instead of failing the request or a sub-agent's task (1.5.7)
|
|
42
42
|
QUEUE_BACKOFF = [2, 5, 10, 15, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
|
|
43
43
|
QUEUE_CODES = {"user_queue_full", "queue_timeout", "queue_full", "no_capacity"}
|
|
44
|
+
#: 1.8.6: the retries of one request stop after this much wall-clock time, waits AND the requests themselves
|
|
45
|
+
#: (ticket: ~14 minutes of "waiting for the model"; each queued try also waits up to 90 s at the gateway, so the
|
|
46
|
+
#: queue back-off alone could run ~45 minutes, not the "about 10" it promised)
|
|
47
|
+
RETRY_WALL_S = 600.0
|
|
48
|
+
#: a visible line while one request has waited this long for its first token (seconds)
|
|
49
|
+
STILL_WAITING_AT = (120.0, 300.0)
|
|
44
50
|
SUBAGENT_RESUMES = 2 # a sub-agent stopped by a busy server or a dropped connection continues this many times
|
|
45
51
|
MAX_TOOLS_PER_REQUEST = 128 # servers refuse more tool definitions than this in one request
|
|
46
52
|
#: tools that are never dropped when the list has to be cut to MAX_TOOLS_PER_REQUEST
|
|
@@ -1419,7 +1425,20 @@ class Agent:
|
|
|
1419
1425
|
dropped = 0
|
|
1420
1426
|
who = self.model_label
|
|
1421
1427
|
from euron_code import llm as _llm
|
|
1428
|
+
t0 = time.monotonic()
|
|
1429
|
+
tries = 0
|
|
1430
|
+
|
|
1431
|
+
def over_wall() -> bool:
|
|
1432
|
+
return time.monotonic() - t0 >= RETRY_WALL_S
|
|
1433
|
+
|
|
1434
|
+
def gave_up(e: EuronError) -> EuronError:
|
|
1435
|
+
return EuronError(
|
|
1436
|
+
f"The {who} has not answered for {fmt_elapsed(time.monotonic() - t0)} ({tries} tries). Your message "
|
|
1437
|
+
"is kept: send /retry to try again" + (", or switch model with /model." if self.uses_euron else "."),
|
|
1438
|
+
status=e.status, code=e.code)
|
|
1422
1439
|
while True:
|
|
1440
|
+
tries += 1
|
|
1441
|
+
self._retry_info = (tries, t0)
|
|
1423
1442
|
try:
|
|
1424
1443
|
return call()
|
|
1425
1444
|
except _llm.ProviderError:
|
|
@@ -1429,6 +1448,8 @@ class Agent:
|
|
|
1429
1448
|
# (no tool ran), so ask again, after a short pause.
|
|
1430
1449
|
if not e.retryable or dropped >= len(MIDSTREAM_BACKOFF):
|
|
1431
1450
|
raise
|
|
1451
|
+
if over_wall():
|
|
1452
|
+
raise gave_up(e) from None
|
|
1432
1453
|
wait = MIDSTREAM_BACKOFF[dropped]
|
|
1433
1454
|
dropped += 1
|
|
1434
1455
|
# one short status line, no error: the answer is asked for again from the same point
|
|
@@ -1455,6 +1476,8 @@ class Agent:
|
|
|
1455
1476
|
self._wait(min(float(wait), 120.0), "Rate limit reached (requests per minute)." if self.uses_euron
|
|
1456
1477
|
else f"{who}: rate limit reached.")
|
|
1457
1478
|
except BusyError as e:
|
|
1479
|
+
if over_wall():
|
|
1480
|
+
raise gave_up(e) from None
|
|
1458
1481
|
if str(e.code or "") in QUEUE_CODES:
|
|
1459
1482
|
# the queue is full or long: wait our turn (a sub-agent's task must not fail on this)
|
|
1460
1483
|
if queued >= len(QUEUE_BACKOFF):
|
|
@@ -1509,9 +1532,11 @@ class Agent:
|
|
|
1509
1532
|
self.compact(force=True)
|
|
1510
1533
|
# each try leaves more room: 65%, 50%, 35%, 30% of the window
|
|
1511
1534
|
self.fit_to_window(target=max(0.3, FIT_TARGET - 0.15 * compacted))
|
|
1512
|
-
except NetworkError:
|
|
1535
|
+
except NetworkError as e:
|
|
1513
1536
|
if net >= len(NETWORK_BACKOFF):
|
|
1514
1537
|
raise
|
|
1538
|
+
if over_wall():
|
|
1539
|
+
raise gave_up(e) from None
|
|
1515
1540
|
wait = NETWORK_BACKOFF[net]
|
|
1516
1541
|
net += 1
|
|
1517
1542
|
self._wait(wait, "Connection lost, reconnecting.")
|
|
@@ -1610,6 +1635,10 @@ class Agent:
|
|
|
1610
1635
|
|
|
1611
1636
|
def _wait(self, seconds: float, message: str) -> None:
|
|
1612
1637
|
self.ui.end_response()
|
|
1638
|
+
info = getattr(self, "_retry_info", None)
|
|
1639
|
+
if info is not None and time.monotonic() - info[1] >= 60:
|
|
1640
|
+
# 1.8.6: a long wait says how long it has been, not only the next countdown
|
|
1641
|
+
message = message.rstrip(".") + f" ({fmt_elapsed(time.monotonic() - info[1])} so far)."
|
|
1613
1642
|
self._phase(f"{message.rstrip('.')} - retrying in {seconds:.0f}s")
|
|
1614
1643
|
try:
|
|
1615
1644
|
self.ui.countdown(seconds, message, self.cancel)
|
|
@@ -1711,22 +1740,38 @@ class Agent:
|
|
|
1711
1740
|
shown = False
|
|
1712
1741
|
self.ui.begin_response()
|
|
1713
1742
|
started = time.monotonic()
|
|
1743
|
+
wait_state: Dict[str, Any] = {"base": None, "notes": 0}
|
|
1714
1744
|
|
|
1715
1745
|
def on_wait(comment: Optional[str] = None) -> None:
|
|
1716
1746
|
if shown:
|
|
1717
1747
|
return
|
|
1718
1748
|
phase = phase_from_comment(comment)
|
|
1719
1749
|
if phase:
|
|
1720
|
-
|
|
1721
|
-
self.ui.waiting(phase[0].upper() + phase[1:] + " (Esc to cancel)")
|
|
1722
|
-
return
|
|
1750
|
+
wait_state["base"] = phase
|
|
1723
1751
|
waited = time.monotonic() - started
|
|
1724
|
-
if waited
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1752
|
+
if not phase and waited <= 3:
|
|
1753
|
+
return
|
|
1754
|
+
# 1.8.6: the live line says how long this request has waited and which try it is
|
|
1755
|
+
# ("waiting for the model 3m 12s, try 2, 5m 40s in all"), not a bare "waiting for the model"
|
|
1756
|
+
tries, t0 = getattr(self, "_retry_info", None) or (1, started)
|
|
1757
|
+
extra = f", try {tries}, {fmt_elapsed(time.monotonic() - t0)} in all" if tries > 1 else ""
|
|
1758
|
+
clock = f" {fmt_elapsed(waited)}" if waited > 3 else ""
|
|
1759
|
+
self._phase(f"{wait_state['base'] or 'waiting for the model'}{clock}{extra}")
|
|
1760
|
+
if phase:
|
|
1761
|
+
self.ui.waiting(phase[0].upper() + phase[1:] + " (Esc to cancel)")
|
|
1762
|
+
else:
|
|
1728
1763
|
self.ui.waiting(f"Waiting for the {self.model_label}... {waited:.0f}s (queued; Esc to cancel)"
|
|
1729
1764
|
if self.uses_euron else f"Waiting for {self.model_label}... {waited:.0f}s (Esc to cancel)")
|
|
1765
|
+
n = wait_state["notes"]
|
|
1766
|
+
if n < len(STILL_WAITING_AT) and waited >= STILL_WAITING_AT[n]:
|
|
1767
|
+
wait_state["notes"] = n + 1
|
|
1768
|
+
who = "the " + self.model_label if self.uses_euron else self.model_label
|
|
1769
|
+
note = (f"Still waiting for {who} ({fmt_elapsed(waited)}{extra}): it is slow to answer right now. "
|
|
1770
|
+
"Esc stops; your message is kept and /retry continues it.")
|
|
1771
|
+
try:
|
|
1772
|
+
(self.ui.dim if not self.is_subagent else self.ui.warn)(note)
|
|
1773
|
+
except Exception:
|
|
1774
|
+
pass
|
|
1730
1775
|
|
|
1731
1776
|
interactive = getattr(self.ui, "interactive", False) and not self.is_subagent
|
|
1732
1777
|
# the live prompt reads the keyboard itself; a second reader would steal keys
|
|
@@ -41,6 +41,9 @@ def normalize_mode(mode: Optional[str]) -> str:
|
|
|
41
41
|
return m if m in MODES else "default"
|
|
42
42
|
|
|
43
43
|
CYCLE = ("default", "acceptEdits", "plan") # Shift+Tab order
|
|
44
|
+
#: Shift+Tab order in a session started with --dangerously-skip-permissions (1.8.6): bypass <-> plan, so the key
|
|
45
|
+
#: never drops bypass by accident (1.8.5: one press went bypass -> default and every edit asked again)
|
|
46
|
+
BYPASS_CYCLE = ("yolo", "plan")
|
|
44
47
|
|
|
45
48
|
SENSITIVE_PATTERNS = [
|
|
46
49
|
".env", ".env.*", "*.pem", "*.key", "id_rsa*", "id_ed25519*", "*.p12", "*.pfx",
|
|
@@ -414,9 +417,48 @@ class Permissions:
|
|
|
414
417
|
self.deny = list(deny or [])
|
|
415
418
|
self.session_allow: List[str] = []
|
|
416
419
|
self.mode = normalize_mode(mode)
|
|
420
|
+
#: started with --dangerously-skip-permissions (or --permission-mode bypassPermissions): set once, for the
|
|
421
|
+
#: whole session. Leaving plan mode (/plan, an accepted plan, Shift+Tab) goes back to bypass, never to
|
|
422
|
+
#: "default" (1.8.6, ticket: every sub-agent edit asked although the session was started in bypass mode).
|
|
423
|
+
self.bypass_session = self.mode == "yolo"
|
|
424
|
+
self._before_plan: Optional[str] = None
|
|
417
425
|
#: the user's choice: hard asks are asked every time, never remembered (/permissions ask-every-time)
|
|
418
426
|
self.ask_every_time = bool(ask_every_time)
|
|
419
427
|
|
|
428
|
+
# ---------------------------------------------------------- mode changes
|
|
429
|
+
def resting_mode(self) -> str:
|
|
430
|
+
"""The mode to return to when plan mode ends without a better answer."""
|
|
431
|
+
return "yolo" if self.bypass_session else "default"
|
|
432
|
+
|
|
433
|
+
def enter_plan(self) -> None:
|
|
434
|
+
if self.mode != "plan":
|
|
435
|
+
self._before_plan = self.mode
|
|
436
|
+
self.mode = "plan"
|
|
437
|
+
|
|
438
|
+
def leave_plan(self, to: Optional[str] = None) -> str:
|
|
439
|
+
"""End plan mode: `to` when given, else the mode before plan mode (bypass in a bypass session)."""
|
|
440
|
+
before = self._before_plan
|
|
441
|
+
self._before_plan = None
|
|
442
|
+
if to is None:
|
|
443
|
+
to = before if before and before != "plan" else self.resting_mode()
|
|
444
|
+
self.mode = normalize_mode(to)
|
|
445
|
+
return self.mode
|
|
446
|
+
|
|
447
|
+
def cycle(self) -> str:
|
|
448
|
+
"""Shift+Tab: default -> acceptEdits -> plan -> default; in a bypass session bypass <-> plan."""
|
|
449
|
+
if self.bypass_session:
|
|
450
|
+
if self.mode == "plan":
|
|
451
|
+
return self.leave_plan("yolo")
|
|
452
|
+
self.enter_plan()
|
|
453
|
+
return self.mode
|
|
454
|
+
if self.mode == "acceptEdits":
|
|
455
|
+
self.enter_plan()
|
|
456
|
+
return self.mode
|
|
457
|
+
if self.mode == "plan":
|
|
458
|
+
return self.leave_plan("default")
|
|
459
|
+
self.mode = "acceptEdits" if self.mode == "default" else "default"
|
|
460
|
+
return self.mode
|
|
461
|
+
|
|
420
462
|
def inside(self, path: Path) -> bool:
|
|
421
463
|
return is_inside(path, self.root) or any(is_inside(path, r) for r in self.extra_roots)
|
|
422
464
|
|
|
@@ -16,7 +16,6 @@ from rich.markup import escape
|
|
|
16
16
|
|
|
17
17
|
from euron_code import __version__, api, auth, config, hooks, llm, memory, prompts, repomap, rules, sessions, skills
|
|
18
18
|
from euron_code.agent import Agent, TurnResult
|
|
19
|
-
from euron_code.permissions import CYCLE
|
|
20
19
|
from euron_code.tools.ignore import ALWAYS_SKIP_DIRS
|
|
21
20
|
from euron_code.usage_view import (MODE_LABELS, estimate_value, fmt_int, money, reference_label, fmt_uptime, local_when, render_account, render_usage,
|
|
22
21
|
short, status_line, weekly_limit)
|
|
@@ -74,6 +73,10 @@ SLASH_COMMANDS = {
|
|
|
74
73
|
#: how /bug names an error kind (the report itself keeps the contract value)
|
|
75
74
|
BUG_KIND = {"gateway": "service"}
|
|
76
75
|
|
|
76
|
+
# Columns left free at the right of the rules and footer around the input, so a terminal that gets a little
|
|
77
|
+
# narrower never re-wraps them (see Repl._columns).
|
|
78
|
+
EDGE_SLACK = 4
|
|
79
|
+
|
|
77
80
|
MIDRUN_COMMANDS = {"/usage", "/version", "/users", "/effort", "/mode", "/attach", "/paste-image", "/reuse", "/reference", "/ps",
|
|
78
81
|
"/components", "/cost", "/context", "/status", "/model", "/help", "/todos", "/permissions",
|
|
79
82
|
"/whoami", "/bug", "/release-notes", "/config", "/expand"}
|
|
@@ -88,7 +91,7 @@ SHORTCUTS = [
|
|
|
88
91
|
("drag a file", "drop files or images into the terminal to attach them"),
|
|
89
92
|
("Ctrl+V", "paste an image from the clipboard (needs Pillow)"),
|
|
90
93
|
("# note", "save a note to memory (EURON.md)"),
|
|
91
|
-
("Shift+Tab", "cycle mode: default -> acceptEdits -> plan (
|
|
94
|
+
("Shift+Tab", "cycle mode: default -> acceptEdits -> plan (bypass <-> plan, if started with bypass)"),
|
|
92
95
|
("Esc Esc", "rewind the last turn (on an empty prompt); clears the line otherwise"),
|
|
93
96
|
("Esc / Ctrl-C", "interrupt the running task (queued messages come back to the input line)"),
|
|
94
97
|
("typing while busy", "/usage /cost /context /status /model /todos /permissions /help run at once; "
|
|
@@ -199,7 +202,7 @@ class Repl:
|
|
|
199
202
|
self.session = session
|
|
200
203
|
self.me_base_tokens = 0
|
|
201
204
|
self.started = started if started is not None else time.monotonic()
|
|
202
|
-
self.bypass_allowed = agent.permissions.
|
|
205
|
+
self.bypass_allowed = agent.permissions.bypass_session # bypass can be (re)entered only then
|
|
203
206
|
self._prompt = None
|
|
204
207
|
self._prefill = ""
|
|
205
208
|
# live mode (prompt_toolkit): one worker thread runs turns and other jobs in order
|
|
@@ -275,10 +278,7 @@ class Repl:
|
|
|
275
278
|
return estimate_value(t.session_prompt, t.session_completion, t.session_cached, (self.me or {}).get("value"))
|
|
276
279
|
|
|
277
280
|
def cycle_mode(self) -> str:
|
|
278
|
-
|
|
279
|
-
p = self.agent.permissions
|
|
280
|
-
p.mode = order[(order.index(p.mode) + 1) % len(order)] if p.mode in order else "default"
|
|
281
|
-
return p.mode
|
|
281
|
+
return self.agent.permissions.cycle()
|
|
282
282
|
|
|
283
283
|
def command_table(self) -> Dict[str, str]:
|
|
284
284
|
table = dict(SLASH_COMMANDS)
|
|
@@ -327,11 +327,18 @@ class Repl:
|
|
|
327
327
|
return g if isinstance(g, transcript.Glyphs) else transcript.UNICODE
|
|
328
328
|
|
|
329
329
|
def _columns(self) -> int:
|
|
330
|
+
"""Width of the rules and the footer around the input: the terminal width minus EDGE_SLACK.
|
|
331
|
+
|
|
332
|
+
1.8.5: drawn one column short of the edge, a narrowing of 2 columns (a window or panel resize, a
|
|
333
|
+
scrollbar showing up) made Windows Terminal / VS Code re-wrap every rule onto two rows; the redraw
|
|
334
|
+
then erased too few rows and each old box stayed on screen (stacked empty `>` boxes, CEO screenshot
|
|
335
|
+
2026-11-15). With the slack, small width changes never wrap a line."""
|
|
330
336
|
app = self._app()
|
|
331
337
|
try:
|
|
332
|
-
|
|
338
|
+
cols = int(app.output.get_size().columns)
|
|
333
339
|
except Exception:
|
|
334
|
-
|
|
340
|
+
cols = shutil.get_terminal_size((80, 24)).columns
|
|
341
|
+
return max(20, cols - EDGE_SLACK)
|
|
335
342
|
|
|
336
343
|
def _prompt_message(self):
|
|
337
344
|
"""Above the input: the live status line while a task runs, then a full-width rule, then
|
|
@@ -989,11 +996,14 @@ class Repl:
|
|
|
989
996
|
return None
|
|
990
997
|
|
|
991
998
|
def _after_plan(self) -> Optional[int]:
|
|
992
|
-
|
|
999
|
+
p = self.agent.permissions
|
|
1000
|
+
go = "(a) go without asking (bypass)" if p.bypass_session else "(a) accept edits and go"
|
|
1001
|
+
ans = self.ui.ask_text(f"Plan mode: {go}, (y) go and ask before each change, "
|
|
993
1002
|
"Enter to keep planning: ").strip().lower()
|
|
994
1003
|
if ans in ("a", "y"):
|
|
995
|
-
|
|
996
|
-
|
|
1004
|
+
# (a) in a session started with --dangerously-skip-permissions goes back to bypass (1.8.6)
|
|
1005
|
+
p.leave_plan(("yolo" if p.bypass_session else "acceptEdits") if ans == "a" else "default")
|
|
1006
|
+
self.ui.dim(f"Left plan mode (now {MODE_LABELS.get(p.mode, p.mode)}).")
|
|
997
1007
|
return self.turn("The plan is approved. Carry it out now, step by step, and verify the result.")
|
|
998
1008
|
return None
|
|
999
1009
|
|
|
@@ -1160,9 +1170,13 @@ class Repl:
|
|
|
1160
1170
|
return self._trust()
|
|
1161
1171
|
if cmd == "/plan":
|
|
1162
1172
|
p = self.agent.permissions
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1173
|
+
if p.mode == "plan":
|
|
1174
|
+
p.leave_plan() # back to the mode before plan mode (bypass, if the session started with it)
|
|
1175
|
+
else:
|
|
1176
|
+
p.enter_plan()
|
|
1177
|
+
self._status_cache = (0.0, "")
|
|
1178
|
+
self.ui.info(f"Permission mode: {MODE_LABELS.get(p.mode, p.mode)}"
|
|
1179
|
+
+ (" (read-only; the model will propose a plan)" if p.mode == "plan" else ""))
|
|
1166
1180
|
return None
|
|
1167
1181
|
if cmd == "/permissions":
|
|
1168
1182
|
return self._permissions(arg)
|
|
@@ -1890,7 +1904,10 @@ class Repl:
|
|
|
1890
1904
|
self.ui.warn("Bypass mode can only be used when Euron Code was started with "
|
|
1891
1905
|
"--dangerously-skip-permissions (or --permission-mode bypassPermissions).")
|
|
1892
1906
|
return None
|
|
1893
|
-
|
|
1907
|
+
if want == "plan":
|
|
1908
|
+
p.enter_plan()
|
|
1909
|
+
else:
|
|
1910
|
+
p.mode = want
|
|
1894
1911
|
self._status_cache = (0.0, "")
|
|
1895
1912
|
when = " (applies from the next tool call)" if self._running else ""
|
|
1896
1913
|
self.ui.info(f"Permission mode: {MODE_LABELS.get(p.mode, p.mode)}{when}")
|
|
@@ -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]
|