euron-code 1.9.3__tar.gz → 1.9.4__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.9.3 → euron_code-1.9.4}/CHANGELOG.md +20 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/PKG-INFO +1 -1
- {euron_code-1.9.3 → euron_code-1.9.4}/pyproject.toml +1 -1
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/__init__.py +1 -1
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/agent.py +1 -1
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/api.py +19 -2
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/documents.py +300 -38
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/prompts.py +2 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/__init__.py +2 -0
- euron_code-1.9.4/src/euron_code/tools/citations.py +263 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/document.py +1 -1
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/ignore.py +75 -75
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/transcript.py +1 -1
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_permissions.py +91 -91
- euron_code-1.9.4/tests/test_v194_citations.py +376 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v3_context.py +3 -1
- {euron_code-1.9.3 → euron_code-1.9.4}/.gitignore +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/LICENSE +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/README.md +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/__main__.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/activity.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/attachments.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/auth.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/autoupdate.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/builtin_skills/build-from-reference/SKILL.md +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/builtin_skills/explain-codebase/SKILL.md +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/builtin_skills/review/SKILL.md +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/builtin_skills/test-writer/SKILL.md +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/cache.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/checkpoints.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/cli.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/codeindex.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/config.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/context.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/contextforge/LICENSE +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/contextforge/__init__.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/contextforge/text.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/contextforge/toolout.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/credentials.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/ctxstats.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/doctor.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/dotnet.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/error_hints.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/errorlog.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/failures.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/friendly.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/frontmatter.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/hooks.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/keys.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/knowledge.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/licensing.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/llm/__init__.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/llm/anthropic.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/llm/base.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/llm/openai_compat.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/llm/setup.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/logo.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/markdown_view.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/memory.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/migration.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/modes.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/mvc5.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/osscache.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/ossgithub.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/pasteinput.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/pathfix.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/permissions.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/progress.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/project_setup.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/repl.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/repomap.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/rules.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/security_scan.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/sessions.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/skills.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/taskstate.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/textsafe.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tls.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/background.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/base.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/db.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/erie.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/fs.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/normalize.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/oss.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/pagecheck.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/pathfind.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/port.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/reuse.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/search.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/shell.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/skill.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/symbols.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/task.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/template.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/todo.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/web.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/tools/websearch.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/trust.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/ui.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/update_check.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/usage_view.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/version_info.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/src/euron_code/webforms.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/conftest.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/fake_providers.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/helpers.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/measure_floor.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/mock_gateway.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/serve_helper.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/sim_long_session.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_agent_mock.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_api_shell.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_bench.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_bench_harness.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_cli_e2e.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_context_memory_sessions.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_dashboard_fixes.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_dashboard_fixes_102.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_db.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_erie.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_knowledge_security.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_markdown_view.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_oss_local.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_powershell_exit_codes.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_qa_attach_secrets.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_qa_long_task.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_qa_print_output.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_qa_reuse_unrelated.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_qa_yolo_outside.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_render_ghost.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_repl.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_reuse_honesty.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_search.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_textsafe.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_tools_fs.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_transcript_ui.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_update_check.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v111_user_reports.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v113_fix_path.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v11_byo.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v11_speed.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v11_tool_fixes.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v130_cut_writes.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v130_reliability.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v140_parity.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v152_migration.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v153_user_errors.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v155_user_errors.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v156_autoupdate.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v156_paste_and_edits.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v157_zero_errors.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v15_hosted_models.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v15_reuse_off_subagent_hooks.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v160_stop_scope_atomic.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v161_residual_errors.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v170_v2.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v180_rescue_research_permissions.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v181_silent_failures_verified.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v182_zero_errors.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v184_selfupdate_pep668.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v186_bypass_and_waits.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v187_sleep_wake.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v188_typed_cli_commands.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v189_edit_partial.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v190_refund_fixes.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v191_page_assets.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v2_rules_skills_hooks.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v2_tokens_shortcuts.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v2_usage_headers.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v31_security.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v3_accounts_value_setup.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v3_activity.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v3_attachments.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v3_live_repl.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v3_single_login.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v4.py +0 -0
- {euron_code-1.9.3 → euron_code-1.9.4}/tests/test_v5.py +0 -0
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.9.4 (2026-11-23)
|
|
4
|
+
|
|
5
|
+
- **Word documents are read in full.** `read_document` now takes `range` for .docx (lines of the extracted text,
|
|
6
|
+
like a text file: `"201-400"`, `"400-"`); before, every read of a long Word file showed the same first ~6k tokens,
|
|
7
|
+
so the end of the document (its References) was never reached. Every cut result says exactly where to read on
|
|
8
|
+
(`range="181-"` and the total line count for Word, text, JSON and notebooks; `page="5-"` for PDF and slides;
|
|
9
|
+
`sheet` + `range` for Excel; `range` for CSV) and, when the document has a References / Bibliography section,
|
|
10
|
+
the line or page where it starts. A line or page longer than the cap no longer makes the hint repeat itself.
|
|
11
|
+
- Word: superscript citation marks are kept (`MALDI-TOF MS^{1,3}`, not `MS1,3`), subscripts as `_{2}`; footnotes
|
|
12
|
+
and endnotes are read and listed under `## Footnotes` / `## Endnotes` with their `[^n]` marks in the text;
|
|
13
|
+
content controls (Word's own citations and bibliography) are no longer skipped.
|
|
14
|
+
- **New `audit_citations` tool.** One call audits every reference of a manuscript (.docx, .pdf, .txt, .md) with
|
|
15
|
+
Euron's citation audit service: a status per reference (VERIFIED, METADATA_MISMATCH, UNRESOLVED,
|
|
16
|
+
POSSIBLY_FABRICATED, CONFIRMED_FABRICATION, retracted), optional claim support, and an Excel and a PDF report
|
|
17
|
+
written next to the manuscript (never over an existing file). A reference that is not found is UNRESOLVED, never
|
|
18
|
+
"fabricated".
|
|
19
|
+
- Euron Code no longer checks references one by one with web searches, never writes replacement references from
|
|
20
|
+
memory or placeholders such as "[Original ref 1]", and stops when a document could not be read in full. A
|
|
21
|
+
conversation summary keeps check results as unverified claims, not decisions.
|
|
22
|
+
|
|
3
23
|
## 1.9.3 (2026-11-22)
|
|
4
24
|
|
|
5
25
|
- An answer cut off after its first words ("I see", "The") is asked again like an empty one, instead of ending the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: euron-code
|
|
3
|
-
Version: 1.9.
|
|
3
|
+
Version: 1.9.4
|
|
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>
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "euron-code"
|
|
7
|
-
version = "1.9.
|
|
7
|
+
version = "1.9.4"
|
|
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"
|
|
@@ -58,7 +58,7 @@ MAX_TOOLS_PER_REQUEST = 128 # servers refuse more tool definitions than this in
|
|
|
58
58
|
CORE_TOOLS = ("read_file", "write_file", "edit_file", "multi_edit", "list_dir", "glob", "grep", "bash", "todo_write",
|
|
59
59
|
"task", "skill", "read_document", "find_symbol", "delete_file", "move_file", "start_background_process",
|
|
60
60
|
"read_process_output", "stop_process", "check_app", "fix_page_assets", "web_fetch", "web_search", "db_query", "port_page",
|
|
61
|
-
"create_mvc5_project")
|
|
61
|
+
"create_mvc5_project", "audit_citations")
|
|
62
62
|
SESSION_IN_USE_WAIT = 3 # a 409 right after a restart is usually this computer's own previous session
|
|
63
63
|
FIT_TARGET = 0.8 # never send a prompt above 80% of the window (estimate); shrink the history first
|
|
64
64
|
# Compaction (1.1.0). Thresholds are fractions of the CONVERSATION room (usable window minus the fixed floor:
|
|
@@ -611,8 +611,25 @@ class Client:
|
|
|
611
611
|
body: Dict[str, Any] = {"query": query, "maxResults": max_results}
|
|
612
612
|
if domains:
|
|
613
613
|
body["domains"] = domains
|
|
614
|
-
|
|
615
|
-
|
|
614
|
+
return self._json("POST", "/v1/research", json=body, headers=self._service_headers(), timeout=60.0)
|
|
615
|
+
|
|
616
|
+
def _service_headers(self) -> Dict[str, str]:
|
|
617
|
+
"""The client / session / task headers of a side service call (research, citation audit); auth is added
|
|
618
|
+
by _request."""
|
|
619
|
+
return {k: v for k, v in self._chat_headers().items() if k.startswith("X-Euron-") and k != "X-Euron-Takeover"}
|
|
620
|
+
|
|
621
|
+
def citations_audit_start(self, file_name: str, data: bytes, claims: bool = True) -> Dict[str, Any]:
|
|
622
|
+
"""POST /v1/citations/audit (1.9.4): start (or find, for the same file) a server-side audit of a
|
|
623
|
+
manuscript's references. Answers 202 (or 200 for an existing job) {jobId, status, stage, ...}."""
|
|
624
|
+
import base64
|
|
625
|
+
body = {"fileName": file_name, "fileBase64": base64.b64encode(data).decode("ascii"), "claims": bool(claims)}
|
|
626
|
+
return self._json("POST", "/v1/citations/audit", json=body, headers=self._service_headers(), timeout=120.0)
|
|
627
|
+
|
|
628
|
+
def citations_audit_status(self, job_id: str) -> Dict[str, Any]:
|
|
629
|
+
"""GET /v1/citations/audit/<jobId>: the job's stage, and when done its results and exports."""
|
|
630
|
+
from urllib.parse import quote
|
|
631
|
+
return self._json("GET", "/v1/citations/audit/" + quote(str(job_id), safe=""),
|
|
632
|
+
headers=self._service_headers(), timeout=60.0)
|
|
616
633
|
|
|
617
634
|
# ------------------------------------------------------------ open source (V5 section 1)
|
|
618
635
|
def oss_search(self, query: str, kind: str = "repos", language: Optional[str] = None,
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Word (.docx), Excel (.xlsx/.xlsm), PowerPoint (.pptx) are read with zipfile + XML (stdlib), PDF with
|
|
4
4
|
pypdf, plus CSV/TSV, JSON, YAML, notebooks and any text file. Every result is capped (about 6k tokens
|
|
5
|
-
by default) and says what was cut and how to read
|
|
5
|
+
by default) and says what was cut and exactly how to read on: the `read_document` page/sheet/range that continues
|
|
6
|
+
it (Word, text, JSON and notebooks by line, PDF and slides by page, sheets and CSV by row) and, when the document
|
|
7
|
+
has one, where its references section starts. Word keeps superscript (`^{1,3}`), subscript (`_{2}`), footnote and
|
|
8
|
+
endnote marks (`[^1]`) and appends the notes themselves.
|
|
6
9
|
Unknown binaries get a one-line description and no bytes.
|
|
7
10
|
"""
|
|
8
11
|
|
|
@@ -87,26 +90,132 @@ def _parse_range(spec: Optional[str], total: int) -> Tuple[int, int]:
|
|
|
87
90
|
|
|
88
91
|
# ---------------------------------------------------------------- Word
|
|
89
92
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
_VALIGN = {"superscript": "^", "subscript": "_"}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _docx_char_styles(z: zipfile.ZipFile) -> Dict[str, str]:
|
|
97
|
+
"""Character style id -> 'superscript' / 'subscript' (citation styles such as EndNote's set it there)."""
|
|
98
|
+
try:
|
|
99
|
+
root = ET.fromstring(z.read("word/styles.xml"))
|
|
100
|
+
except (KeyError, ET.ParseError):
|
|
101
|
+
return {}
|
|
102
|
+
own: Dict[str, str] = {}
|
|
103
|
+
based: Dict[str, str] = {}
|
|
104
|
+
for st in root.iter(W + "style"):
|
|
105
|
+
sid = st.get(W + "styleId") or ""
|
|
106
|
+
va = st.find(f"{W}rPr/{W}vertAlign")
|
|
107
|
+
if va is not None:
|
|
108
|
+
own[sid] = va.get(W + "val") or ""
|
|
109
|
+
b = st.find(W + "basedOn")
|
|
110
|
+
if b is not None:
|
|
111
|
+
based[sid] = b.get(W + "val") or ""
|
|
112
|
+
out = dict(own)
|
|
113
|
+
for sid in based:
|
|
114
|
+
cur, hops = sid, 0
|
|
115
|
+
while cur not in own and cur in based and hops < 8:
|
|
116
|
+
cur, hops = based[cur], hops + 1
|
|
117
|
+
if cur in own:
|
|
118
|
+
out[sid] = own[cur]
|
|
119
|
+
return out
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def _docx_text(el, styles: Optional[Dict[str, str]] = None, note_ids: Optional[Dict[str, str]] = None) -> str:
|
|
123
|
+
"""Text of a paragraph (or any element): superscript runs as ^{...}, subscript as _{...}, footnote and
|
|
124
|
+
endnote reference marks as [^id]."""
|
|
125
|
+
styles = styles or {}
|
|
126
|
+
note_ids = note_ids if note_ids is not None else {"foot": "", "end": ""}
|
|
127
|
+
out: List[str] = []
|
|
128
|
+
buf: List[str] = []
|
|
129
|
+
state = [""] # the vertical alignment of what is in buf
|
|
130
|
+
|
|
131
|
+
def flush() -> None:
|
|
132
|
+
s = "".join(buf)
|
|
133
|
+
mark = _VALIGN.get(state[0])
|
|
134
|
+
out.append(mark + "{" + s + "}" if mark and s.strip() else s)
|
|
135
|
+
buf.clear()
|
|
136
|
+
|
|
137
|
+
def put(piece: str, mode: str) -> None:
|
|
138
|
+
if mode != state[0]:
|
|
139
|
+
flush()
|
|
140
|
+
state[0] = mode
|
|
141
|
+
buf.append(piece)
|
|
142
|
+
|
|
143
|
+
for r in el.iter(W + "r"):
|
|
144
|
+
mode = ""
|
|
145
|
+
rpr = r.find(W + "rPr")
|
|
146
|
+
if rpr is not None:
|
|
147
|
+
va = rpr.find(W + "vertAlign")
|
|
148
|
+
if va is not None:
|
|
149
|
+
mode = va.get(W + "val") or ""
|
|
150
|
+
else:
|
|
151
|
+
rs = rpr.find(W + "rStyle")
|
|
152
|
+
if rs is not None:
|
|
153
|
+
mode = styles.get(rs.get(W + "val") or "", "")
|
|
154
|
+
if mode not in _VALIGN:
|
|
155
|
+
mode = ""
|
|
156
|
+
for node in r:
|
|
157
|
+
tag = node.tag
|
|
158
|
+
if tag == W + "t":
|
|
159
|
+
put(node.text or "", mode)
|
|
160
|
+
elif tag == W + "tab":
|
|
161
|
+
put("\t", "")
|
|
162
|
+
elif tag in (W + "br", W + "cr"):
|
|
163
|
+
put("\n", "")
|
|
164
|
+
elif tag == W + "noBreakHyphen":
|
|
165
|
+
put("-", mode)
|
|
166
|
+
elif tag == W + "footnoteReference":
|
|
167
|
+
put(f"[^{note_ids['foot']}{node.get(W + 'id')}]", "")
|
|
168
|
+
elif tag == W + "endnoteReference":
|
|
169
|
+
put(f"[^{note_ids['end']}{node.get(W + 'id')}]", "")
|
|
170
|
+
flush()
|
|
99
171
|
return "".join(out)
|
|
100
172
|
|
|
101
173
|
|
|
174
|
+
def _docx_blocks(parent):
|
|
175
|
+
"""The paragraphs and tables of a body, with content controls (w:sdt, Word's own citations and
|
|
176
|
+
bibliography) and custom XML opened up instead of skipped."""
|
|
177
|
+
for child in list(parent if parent is not None else []):
|
|
178
|
+
if child.tag == W + "sdt":
|
|
179
|
+
yield from _docx_blocks(child.find(W + "sdtContent"))
|
|
180
|
+
elif child.tag == W + "customXml":
|
|
181
|
+
yield from _docx_blocks(child)
|
|
182
|
+
else:
|
|
183
|
+
yield child
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def _docx_notes(z: zipfile.ZipFile, part: str, tag: str, styles: Dict[str, str],
|
|
187
|
+
note_ids: Dict[str, str], kind: str) -> List[str]:
|
|
188
|
+
try:
|
|
189
|
+
root = ET.fromstring(z.read(part))
|
|
190
|
+
except KeyError:
|
|
191
|
+
return []
|
|
192
|
+
out = []
|
|
193
|
+
for fn in root.iter(W + tag):
|
|
194
|
+
if (fn.get(W + "type") or "normal") != "normal":
|
|
195
|
+
continue # separators
|
|
196
|
+
paras = [_docx_text(p, styles, note_ids).strip() for p in fn.iter(W + "p")]
|
|
197
|
+
text = " ".join(p for p in paras if p)
|
|
198
|
+
if text:
|
|
199
|
+
out.append(f"[^{note_ids[kind]}{fn.get(W + 'id')}]: {text}")
|
|
200
|
+
return out
|
|
201
|
+
|
|
202
|
+
|
|
102
203
|
def extract_docx(path: Path) -> str:
|
|
103
204
|
with zipfile.ZipFile(path) as z:
|
|
104
205
|
root = ET.fromstring(z.read("word/document.xml"))
|
|
206
|
+
styles = _docx_char_styles(z)
|
|
207
|
+
note_ids = {"foot": "", "end": "e"} # [^3]; endnotes [^e3] only when footnotes exist too
|
|
208
|
+
foot = _docx_notes(z, "word/footnotes.xml", "footnote", styles, note_ids, "foot")
|
|
209
|
+
end = _docx_notes(z, "word/endnotes.xml", "endnote", styles, note_ids, "end")
|
|
210
|
+
if not (foot and end):
|
|
211
|
+
note_ids["end"] = ""
|
|
212
|
+
if end:
|
|
213
|
+
end = [re.sub(r"^\[\^e", "[^", x) for x in end]
|
|
105
214
|
body = root.find(W + "body")
|
|
106
215
|
lines: List[str] = []
|
|
107
|
-
for child in
|
|
216
|
+
for child in _docx_blocks(body):
|
|
108
217
|
if child.tag == W + "p":
|
|
109
|
-
text = _docx_text(child).strip()
|
|
218
|
+
text = _docx_text(child, styles, note_ids).strip()
|
|
110
219
|
if not text:
|
|
111
220
|
continue
|
|
112
221
|
style = child.find(f"{W}pPr/{W}pStyle")
|
|
@@ -121,8 +230,13 @@ def extract_docx(path: Path) -> str:
|
|
|
121
230
|
else:
|
|
122
231
|
lines.append(text)
|
|
123
232
|
elif child.tag == W + "tbl":
|
|
124
|
-
rows = [[_docx_text(tc).strip() for tc in tr.findall(W + "tc")]
|
|
233
|
+
rows = [[_docx_text(tc, styles, note_ids).strip() for tc in tr.findall(W + "tc")]
|
|
234
|
+
for tr in child.findall(W + "tr")]
|
|
125
235
|
lines += [""] + md_table(rows) + [""]
|
|
236
|
+
if foot:
|
|
237
|
+
lines += ["", "## Footnotes"] + foot
|
|
238
|
+
if end:
|
|
239
|
+
lines += ["", "## Endnotes"] + end
|
|
126
240
|
return "\n".join(lines).strip()
|
|
127
241
|
|
|
128
242
|
|
|
@@ -206,11 +320,13 @@ def extract_xlsx(path: Path, sheet: Optional[str] = None, rng: Optional[str] = N
|
|
|
206
320
|
|
|
207
321
|
# ---------------------------------------------------------------- PowerPoint
|
|
208
322
|
|
|
209
|
-
def extract_pptx(path: Path, rng: Optional[str] = None) -> str:
|
|
323
|
+
def extract_pptx(path: Path, rng: Optional[str] = None, meta: Optional[Dict[str, int]] = None) -> str:
|
|
210
324
|
with zipfile.ZipFile(path) as z:
|
|
211
325
|
names = sorted((n for n in z.namelist() if re.fullmatch(r"ppt/slides/slide\d+\.xml", n)),
|
|
212
326
|
key=lambda n: int(re.search(r"(\d+)", n.rsplit("/", 1)[1]).group(1)))
|
|
213
327
|
a, b = _parse_range(rng, len(names) or 1) if rng else (1, len(names))
|
|
328
|
+
if meta is not None:
|
|
329
|
+
meta.update(total=len(names), a=a, b=min(b, len(names)))
|
|
214
330
|
out = [f"Presentation {path.name}: {len(names)} slide(s)"]
|
|
215
331
|
for i in range(a, b + 1):
|
|
216
332
|
if i > len(names):
|
|
@@ -229,7 +345,7 @@ def extract_pptx(path: Path, rng: Optional[str] = None) -> str:
|
|
|
229
345
|
|
|
230
346
|
# ---------------------------------------------------------------- PDF
|
|
231
347
|
|
|
232
|
-
def extract_pdf(path: Path, rng: Optional[str] = None) -> str:
|
|
348
|
+
def extract_pdf(path: Path, rng: Optional[str] = None, meta: Optional[Dict[str, int]] = None) -> str:
|
|
233
349
|
try:
|
|
234
350
|
from pypdf import PdfReader
|
|
235
351
|
except ImportError:
|
|
@@ -240,6 +356,8 @@ def extract_pdf(path: Path, rng: Optional[str] = None) -> str:
|
|
|
240
356
|
except Exception as e:
|
|
241
357
|
raise DocumentError(f"Could not open the PDF: {type(e).__name__}: {e}")
|
|
242
358
|
a, b = _parse_range(rng, n or 1) if rng else (1, n)
|
|
359
|
+
if meta is not None:
|
|
360
|
+
meta.update(total=n, a=a, b=min(b, n))
|
|
243
361
|
out = [f"PDF {path.name}: {n} page(s)"]
|
|
244
362
|
for i in range(a, b + 1):
|
|
245
363
|
if i > n:
|
|
@@ -248,6 +366,8 @@ def extract_pdf(path: Path, rng: Optional[str] = None) -> str:
|
|
|
248
366
|
text = (reader.pages[i - 1].extract_text() or "").strip()
|
|
249
367
|
except Exception:
|
|
250
368
|
text = "(text could not be extracted from this page)"
|
|
369
|
+
if meta is not None and find_references_line(text.splitlines()):
|
|
370
|
+
meta["refs"] = i
|
|
251
371
|
out.append(f"\n## Page {i}\n" + (text or "(no text on this page; it may be a scanned image)"))
|
|
252
372
|
return "\n".join(out)
|
|
253
373
|
|
|
@@ -329,40 +449,182 @@ def describe_binary(path: Path) -> str:
|
|
|
329
449
|
return f"{path.name}: binary file ({mime}, {human_size(path.stat().st_size)}); its bytes were not attached."
|
|
330
450
|
|
|
331
451
|
|
|
452
|
+
#: a references / bibliography heading on a line of its own ("References", "7. REFERENCES", "## Bibliography:")
|
|
453
|
+
_REF_HEAD = re.compile(r"(?i)(?:(?:\d+(?:\.\d+)*|[ivx]+)\.?\s+)?(?:references(?: and notes)?|bibliography|"
|
|
454
|
+
r"literature cited|works cited|reference list|cited literature)\s*:?")
|
|
455
|
+
|
|
456
|
+
#: how to read on from a line: (position in the whole file, read_document arguments, where in words)
|
|
457
|
+
Resume = Tuple[int, str, str]
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
def find_references_line(lines: List[str]) -> Optional[int]:
|
|
461
|
+
"""1-based line of the last references / bibliography heading (the last one: a contents list names it too)."""
|
|
462
|
+
for i in range(len(lines) - 1, -1, -1):
|
|
463
|
+
s = lines[i].strip().lstrip("#").strip().strip("*_").strip()
|
|
464
|
+
if 0 < len(s) <= 40 and _REF_HEAD.fullmatch(s):
|
|
465
|
+
return i + 1
|
|
466
|
+
return None
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
def _fit(lines: List[str], limit: int) -> Tuple[List[str], int]:
|
|
470
|
+
"""The lines that fit in `limit` characters, and the index of the first line not shown in full. A line
|
|
471
|
+
that does not fit is shown in part when that leaves out a lot (or when nothing else would be shown)."""
|
|
472
|
+
shown: List[str] = []
|
|
473
|
+
used = 0
|
|
474
|
+
for i, ln in enumerate(lines):
|
|
475
|
+
add = len(ln) + (1 if shown else 0)
|
|
476
|
+
if used + add > limit:
|
|
477
|
+
room = limit - used - (1 if shown else 0)
|
|
478
|
+
if not shown or room > limit * 0.4:
|
|
479
|
+
shown.append(ln[:max(0, room)])
|
|
480
|
+
return shown, i
|
|
481
|
+
shown.append(ln)
|
|
482
|
+
used += add
|
|
483
|
+
return shown, len(lines)
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
def _finish(text: str, resumes: Optional[List[Resume]], cap_tokens: int, name: str,
|
|
487
|
+
more: Optional[Resume] = None, refs: Optional[Resume] = None, span: str = "") -> str:
|
|
488
|
+
"""Cap `text` and say exactly where to read on. resumes[i]: how to read on from line i of `text`; `more`:
|
|
489
|
+
what follows this read (a range / page was given and the file goes on); `refs`: where the references
|
|
490
|
+
start; `span`: what this read covers, e.g. "Lines 1-400 of 812"."""
|
|
491
|
+
lines = text.split("\n")
|
|
492
|
+
limit = int(cap_tokens * CHARS_PER_TOKEN)
|
|
493
|
+
|
|
494
|
+
def refs_note(after: Optional[Resume]) -> str:
|
|
495
|
+
if refs and (after is None or refs[0] > after[0]):
|
|
496
|
+
return f" References start at {refs[2]}: read_document {refs[1]}."
|
|
497
|
+
return ""
|
|
498
|
+
|
|
499
|
+
if len(text) <= limit:
|
|
500
|
+
if more:
|
|
501
|
+
return text + f"\n\n[{span}. Read on at {more[2]}: read_document {more[1]}.{refs_note(more)}]"
|
|
502
|
+
return text
|
|
503
|
+
shown, k = _fit(lines, limit)
|
|
504
|
+
body = "\n".join(shown)
|
|
505
|
+
head = f"\n\n[... cut at about {cap_tokens:,} tokens; {len(text) - len(body):,} more characters not shown."
|
|
506
|
+
if not resumes or len(resumes) != len(lines):
|
|
507
|
+
return body + head + f" Use read_document on {name} with page/sheet/range to read more.]"
|
|
508
|
+
nxt: Optional[Resume] = resumes[k] if k < len(resumes) else more
|
|
509
|
+
note = ""
|
|
510
|
+
if nxt is not None and nxt[1] == resumes[0][1]:
|
|
511
|
+
# reading on from there would show this same text again: go on from the next position instead
|
|
512
|
+
where = nxt[2][0].upper() + nxt[2][1:]
|
|
513
|
+
note = f" {where} is longer than this cap, so only its start is shown (max_tokens up to 12000 shows more)."
|
|
514
|
+
nxt = next((r for r in resumes[k + 1:] if r[1] != nxt[1]), more)
|
|
515
|
+
if nxt is None:
|
|
516
|
+
return body + head + note + refs_note(None) + "]"
|
|
517
|
+
return body + head + note + f" Read on at {nxt[2]}: read_document {nxt[1]} on {name}." + refs_note(nxt) + "]"
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
def _read_lines(text: str, rng: Optional[str], cap_tokens: int, name: str) -> str:
|
|
521
|
+
"""A text-like result read by line: `range` picks lines of it (1-based, inclusive), as for text files."""
|
|
522
|
+
lines = text.split("\n")
|
|
523
|
+
total = len(lines)
|
|
524
|
+
a, b = _parse_range(rng, max(total, 1)) if rng else (1, total)
|
|
525
|
+
if a > total:
|
|
526
|
+
raise DocumentError(f"{name} has {total} lines as text; range {rng!r} starts after the end.")
|
|
527
|
+
resumes = [(i, f'range="{i}-"', f"line {i} of {total}") for i in range(a, b + 1)]
|
|
528
|
+
more = (b + 1, f'range="{b + 1}-"', f"line {b + 1} of {total}") if b < total else None
|
|
529
|
+
r = find_references_line(lines)
|
|
530
|
+
refs = (r, f'range="{r}-"', f"line {r}") if r else None
|
|
531
|
+
return _finish("\n".join(lines[a - 1:b]), resumes, cap_tokens, name, more=more, refs=refs,
|
|
532
|
+
span=f"Lines {a}-{b} of {total}")
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
def _range_start(rng: Optional[str]) -> int:
|
|
536
|
+
m = re.match(r"\s*(\d+)", str(rng or ""))
|
|
537
|
+
return max(1, int(m.group(1))) if m else 1
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
def _paged_resumes(text: str, unit: str, meta: Dict[str, int]) -> List[Resume]:
|
|
541
|
+
"""PDF pages / slides: every line reads on from the page it is on."""
|
|
542
|
+
cur, total = meta.get("a", 1), meta.get("total", 0)
|
|
543
|
+
head = re.compile(r"## " + unit.capitalize() + r" (\d+)\b")
|
|
544
|
+
out: List[Resume] = []
|
|
545
|
+
for ln in text.split("\n"):
|
|
546
|
+
m = head.match(ln)
|
|
547
|
+
if m:
|
|
548
|
+
cur = int(m.group(1))
|
|
549
|
+
out.append((cur, f'page="{cur}-"', f"{unit} {cur} of {total}"))
|
|
550
|
+
return out
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
def _xlsx_resumes(text: str, rng: Optional[str]) -> List[Resume]:
|
|
554
|
+
"""Every table line reads on from its own row of its sheet (a range applies to each sheet read)."""
|
|
555
|
+
start = _range_start(rng)
|
|
556
|
+
lines = text.split("\n")
|
|
557
|
+
sheet_head = re.compile(r"## Sheet (.+?): \d+ rows x")
|
|
558
|
+
first = next((m.group(1) for m in map(sheet_head.match, lines) if m), "")
|
|
559
|
+
no, name, j, row = 1, first, -1, start
|
|
560
|
+
out: List[Resume] = []
|
|
561
|
+
seen = False
|
|
562
|
+
for ln in lines:
|
|
563
|
+
m = sheet_head.match(ln)
|
|
564
|
+
if m:
|
|
565
|
+
no, name, j, row = (no + 1 if seen else 1), m.group(1), 0, start
|
|
566
|
+
seen = True
|
|
567
|
+
elif seen and ln.startswith("|"):
|
|
568
|
+
row = start + max(0, j - 1) # the table's first line is row `start`, the second its separator
|
|
569
|
+
j += 1
|
|
570
|
+
out.append((no * 10_000_000 + row, f'sheet="{name}" range="{row}-"', f"row {row} of sheet {name}"))
|
|
571
|
+
return out
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
def _csv_resumes(text: str, rng: Optional[str]) -> List[Resume]:
|
|
575
|
+
"""Every table line reads on from its data row (the header and the separator come first)."""
|
|
576
|
+
start = _range_start(rng)
|
|
577
|
+
out: List[Resume] = []
|
|
578
|
+
j, cur = 0, start
|
|
579
|
+
for ln in text.split("\n"):
|
|
580
|
+
if ln.startswith("|"):
|
|
581
|
+
cur = start + max(0, j - 2)
|
|
582
|
+
j += 1
|
|
583
|
+
out.append((cur, f'range="{cur}-"', f"data row {cur}"))
|
|
584
|
+
return out
|
|
585
|
+
|
|
586
|
+
|
|
332
587
|
def extract(path: Path, cap_tokens: int = DEFAULT_CAP_TOKENS, page: Optional[str] = None,
|
|
333
588
|
sheet: Optional[str] = None, rng: Optional[str] = None) -> str:
|
|
334
|
-
"""Compact text for one file. Raises DocumentError for unreadable files.
|
|
589
|
+
"""Compact text for one file. Raises DocumentError for unreadable files. A cut result ends with the
|
|
590
|
+
read_document arguments that continue it and, when the document has a references section, where it
|
|
591
|
+
starts."""
|
|
335
592
|
path = Path(path)
|
|
336
593
|
if not path.is_file():
|
|
337
594
|
raise DocumentError(f"File not found: {path}")
|
|
338
595
|
if path.stat().st_size > MAX_DOC_BYTES:
|
|
339
596
|
raise DocumentError(f"{path.name} is {human_size(path.stat().st_size)}; too large to read.")
|
|
340
597
|
ext = path.suffix.lower()
|
|
341
|
-
|
|
598
|
+
name = path.name
|
|
342
599
|
try:
|
|
343
600
|
if ext == ".docx":
|
|
344
|
-
|
|
345
|
-
|
|
601
|
+
return _read_lines(extract_docx(path), rng, cap_tokens, name)
|
|
602
|
+
if ext in (".xlsx", ".xlsm"):
|
|
346
603
|
text = extract_xlsx(path, sheet=sheet, rng=rng)
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
604
|
+
return _finish(text, _xlsx_resumes(text, rng), cap_tokens, name)
|
|
605
|
+
if ext in (".pptx", ".pdf"):
|
|
606
|
+
meta: Dict[str, int] = {}
|
|
607
|
+
unit = "slide" if ext == ".pptx" else "page"
|
|
608
|
+
if ext == ".pptx":
|
|
609
|
+
text = extract_pptx(path, rng=page or rng, meta=meta)
|
|
610
|
+
else:
|
|
611
|
+
text = extract_pdf(path, rng=page or rng, meta=meta)
|
|
612
|
+
total, b = meta.get("total", 0), meta.get("b", 0)
|
|
613
|
+
more = (b + 1, f'page="{b + 1}-"', f"{unit} {b + 1} of {total}") if b < total else None
|
|
614
|
+
rp = meta.get("refs")
|
|
615
|
+
refs = (rp, f'page="{rp}-"', f"{unit} {rp}") if rp else None
|
|
616
|
+
return _finish(text, _paged_resumes(text, unit, meta), cap_tokens, name, more=more, refs=refs,
|
|
617
|
+
span=f"{unit.capitalize()}s {meta.get('a', 1)}-{b} of {total}")
|
|
618
|
+
if ext in (".csv", ".tsv"):
|
|
352
619
|
text = extract_csv(path, rng=rng)
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
if rng:
|
|
363
|
-
lines = text.splitlines()
|
|
364
|
-
a, b = _parse_range(rng, max(len(lines), 1))
|
|
365
|
-
text = "\n".join(lines[a - 1:b])
|
|
620
|
+
return _finish(text, _csv_resumes(text, rng), cap_tokens, name)
|
|
621
|
+
if ext == ".ipynb":
|
|
622
|
+
return _read_lines(extract_ipynb(path), rng, cap_tokens, name)
|
|
623
|
+
if ext == ".json":
|
|
624
|
+
return _read_lines(extract_json(path), rng, cap_tokens, name)
|
|
625
|
+
data = path.read_bytes()
|
|
626
|
+
if b"\x00" in data[:8192]:
|
|
627
|
+
return describe_binary(path)
|
|
628
|
+
return _read_lines(data.decode("utf-8", errors="replace"), rng, cap_tokens, name)
|
|
366
629
|
except (zipfile.BadZipFile, KeyError, ET.ParseError) as e:
|
|
367
630
|
raise DocumentError(f"{path.name} does not look like a valid {ext} file ({type(e).__name__}).")
|
|
368
|
-
return cap(text, cap_tokens, hint)
|
|
@@ -30,6 +30,7 @@ CORE = """You are Euron Code, an AI coding agent that works inside the user's pr
|
|
|
30
30
|
- Big task (5 or more distinct steps): first a short numbered plan with todo_write, then do it, one item in_progress at a time, marking items completed as you go; update it in the same step as your next tool call, never as a step of its own. Stop when the list is done.
|
|
31
31
|
- Independent parts of a big build (for example a Dockerfile and a training script) can go to sub-agents: call task several times in one step (up to 3 run at once), each with mode "write" and its own `paths`. Not for a small app of a few files (HTML/CSS/JS, one script): write those yourself, in parts.
|
|
32
32
|
- Building a new app in an empty folder: you may call find_reusable once (1-8 components). Not for existing projects, small edits, bug fixes or questions.
|
|
33
|
+
- Citations and references: to audit or verify the references of a manuscript, call audit_citations once for the whole file; never web_search references one by one. A reference that is not found is unverified, never fabricated: only the status CONFIRMED_FABRICATION from audit_citations means fabricated. Never invent replacement references, authors or DOIs, and never write placeholders such as "[Original ref 1]" where the original citation text belongs; copy it from the file. If a document could not be read in full (for example its references section was never reached), say so and stop instead of auditing it.
|
|
33
34
|
- Use the details the user gave (name, photo, email, links) exactly; never leave placeholders like "Your Name" or Lorem ipsum.
|
|
34
35
|
- Reuse with care: your own scaffold is always the base. Reuse a reference file only when it does the same job in the same language and framework, is small, and you can see it is correct; copy the smallest set of files with oss_adopt (it keeps the licence header) and adapt them, or record hand adaptations with add_third_party_notice. Never clone or copy a whole repository, and never pull in a reference's dependencies or build setup. If adopted code does not build after two fixes, delete it and write that part yourself. Skip reuse for ordinary app code; cite sources in your summary. At most about 3 searches and 5 reads.
|
|
35
36
|
- For UI: use the component system the project already has; otherwise adapt a permissive kit you found. Copy layout and structure, then adapt; do not hand-write CSS from scratch.
|
|
@@ -99,6 +100,7 @@ COMPACT = """You are summarising a coding session so it can continue in a fresh
|
|
|
99
100
|
4. Commands and results: tests, builds and their latest status.
|
|
100
101
|
5. Last error: the most recent error or failing output, quoted briefly, if any.
|
|
101
102
|
6. Open todos and the immediate next step.
|
|
103
|
+
Results of checks and lookups (references verified, facts searched) are unverified claims, not decisions: record what the tool returned (its name, counts and statuses, word for word) and never upgrade them ("not found" is not "fabricated").
|
|
102
104
|
Do not invent anything. Do not call tools. Plain text or Markdown, at most about 350 words: dense, no repetition."""
|
|
103
105
|
|
|
104
106
|
# The same summary asked at the END of the conversation itself (Euron model): the request then shares
|
|
@@ -7,6 +7,7 @@ from typing import Any, Dict, List, Optional
|
|
|
7
7
|
|
|
8
8
|
from euron_code.tools.base import Tool, ToolContext, ToolError, ToolResult, truncate
|
|
9
9
|
from euron_code.tools.background import CheckApp, ReadProcessOutput, StartBackgroundProcess, StopProcess
|
|
10
|
+
from euron_code.tools.citations import AuditCitations
|
|
10
11
|
from euron_code.tools.db import DbQuery
|
|
11
12
|
from euron_code.tools.document import ReadDocument
|
|
12
13
|
from euron_code.tools.fs import DeleteFile, EditFile, ListDir, MoveFile, MultiEdit, ReadFile, WriteFile
|
|
@@ -57,6 +58,7 @@ def default_tools(settings: Dict[str, Any], subagents: bool = True) -> List[Tool
|
|
|
57
58
|
if settings.get("webSearch", True):
|
|
58
59
|
tools.append(WebSearch()) # 1.8.0, appended: keeps the prefix stable
|
|
59
60
|
tools.append(FixPageAssets()) # 1.9.1, appended: keeps the prefix stable
|
|
61
|
+
tools.append(AuditCitations()) # 1.9.4, appended: keeps the prefix stable
|
|
60
62
|
return _without_reuse(tools, settings)
|
|
61
63
|
|
|
62
64
|
|