feat: парсер .arp/.arps (АРПС 1.10, Smeta.RU) + MCP-tool + GLM-путь

Пункт 6 мастер-плана: .arp/.arps (294 файла) не читались. АРПС 1.10 — текстовый формат
(cp866, поля через '#'): тип 3=шапка (шифр/название/итог), тип 20=позиция (обоснование=
шифр, ед., наимен., стоимость). gge_tools.parse_arp_file + MCP-tool parse_arp_file +
.arp/.arps в ALLOWED обоих bridge + инлайн-чтение в GLM-пути. Объём-поле в АРПС неоднозначно —
по /sanity не выдумываю, беру надёжное (код/ед./наимен./итог). Юнит mutation-safe + серверный
real-тест на настоящем .arp (шифр 00-02-7-00-01Р, 70 позиций, итог 6.1М). APP_VERSION→2026-07-15f.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-07-15 21:02:39 +10:00
co-authored by Claude Opus 4.8
parent 3e9d832e19
commit 78f900660a
7 changed files with 192 additions and 3 deletions
+41
View File
@@ -294,6 +294,30 @@ def tool_parse_gsfx_file(*, filename: str, max_positions: int = 30) -> dict:
return data
def tool_parse_arp_file(*, filename: str, max_positions: int = 30) -> dict:
"""Распарсить одну .arp/.arps смету (АРПС 1.10 — Smeta.RU / ПК АВС, текстовый).
Возвращает: code, name, total (итог сметы), позиции (code=шифр, name, unit,
total=стоимость позиции). Родной формат обмена Smeta.RU — раньше не читался.
"""
user, tab = _user_tab()
work_dir = _work_dir(user, tab)
candidate = work_dir / filename
if not candidate.exists():
matches = list(work_dir.rglob(Path(filename).name))
if not matches:
return {"error": f"«{filename}» не найден в {user}/{tab}"}
candidate = matches[0]
from gge_tools import parse_arp_file
data = parse_arp_file(candidate)
if 'error' in data:
return data
if len(data['positions']) > max_positions:
data['positions_total'] = len(data['positions'])
data['positions'] = data['positions'][:max_positions]
data['positions_truncated'] = True
return data
def tool_update_xlsx_cells(*, filename: str, sheet: str,
updates: list, out_filename: str | None = None) -> dict:
"""Массовая запись ячеек в xlsx. Универсальный tool — годится для
@@ -514,6 +538,23 @@ TOOLS: dict[str, dict] = {
"required": ["filename"],
},
},
"parse_arp_file": {
"fn": tool_parse_arp_file,
"description": (
"Распарсить одну .arp/.arps смету (АРПС 1.10 — формат обмена Smeta.RU / "
"ПК АВС, текстовый). Возвращает: code (шифр), name, total (итог сметы, руб), "
"positions (code=шифр расценки, name, unit, total=стоимость позиции). "
"ИСПОЛЬЗУЙ для файлов .arp/.arps — родной формат Smeta.RU."
),
"inputSchema": {
"type": "object",
"properties": {
"filename": {"type": "string", "description": "Путь к .arp относительно work_dir (или basename)"},
"max_positions": {"type": "integer", "description": "Лимит позиций (default 30)"},
},
"required": ["filename"],
},
},
"update_xlsx_cells": {
"fn": tool_update_xlsx_cells,
"description": (