Optimize XML AI structure package for Codex
This commit is contained in:
@@ -1730,11 +1730,18 @@ def test_ai_structure_prepare_writes_ai_ready_package(tmp_path: Path):
|
||||
assert (output / "manifest.json").exists()
|
||||
assert (output / "normalized_project.json").exists()
|
||||
assert (output / "sir_snapshot.json").exists()
|
||||
assert (output / "project_layout.json").exists()
|
||||
assert (output / "compact_objects.json").exists()
|
||||
assert (output / "compact_modules.json").exists()
|
||||
assert (codex_package / "AGENTS.md").exists()
|
||||
assert (codex_package / "README.md").exists()
|
||||
assert (codex_package / "context" / "CODEX_START_HERE.md").exists()
|
||||
assert (codex_package / "context" / "project-brief.md").exists()
|
||||
assert (codex_package / "context" / "project-overview.md").exists()
|
||||
assert (codex_package / "indexes" / "codex-navigation.json").exists()
|
||||
assert (codex_package / "indexes" / "project-layout.json").exists()
|
||||
assert (codex_package / "indexes" / "objects-compact.json").exists()
|
||||
assert (codex_package / "indexes" / "modules-compact.json").exists()
|
||||
assert (codex_package / "indexes" / "objects.json").exists()
|
||||
assert (codex_package / "indexes" / "source-map.json").exists()
|
||||
assert (codex_package / "raw" / "normalized_project.json").exists()
|
||||
@@ -1745,9 +1752,13 @@ def test_ai_structure_prepare_writes_ai_ready_package(tmp_path: Path):
|
||||
module_docs = "\n".join(path.read_text(encoding="utf-8") for path in (codex_package / "modules").glob("*.md"))
|
||||
assert "Локальный исходник: `source/Интеграция.bsl`" in module_docs
|
||||
assert "Эта папка сгенерирована SFERA для Codex" in (codex_package / "AGENTS.md").read_text(encoding="utf-8")
|
||||
assert "локальную папку `source/`" in (codex_package / "AGENTS.md").read_text(encoding="utf-8")
|
||||
assert "Перенесите эту папку целиком в проект Codex" in (codex_package / "README.md").read_text(encoding="utf-8")
|
||||
assert "выборочная копия нужных исходников" in (codex_package / "AGENTS.md").read_text(encoding="utf-8")
|
||||
assert "compact-индексы" in (codex_package / "README.md").read_text(encoding="utf-8")
|
||||
assert "Рассматривайте модули, формы и команды как части объектов 1С-владельцев" in (output / "ai_context.md").read_text(encoding="utf-8")
|
||||
compact_objects = json.loads((codex_package / "indexes" / "objects-compact.json").read_text(encoding="utf-8"))
|
||||
assert any(item["qualified_name"] == "Справочник.Контрагенты" for item in compact_objects)
|
||||
brief = (codex_package / "context" / "project-brief.md").read_text(encoding="utf-8")
|
||||
assert "Brief: ai-demo" in brief
|
||||
|
||||
page = client.get("/html5/projects/ai-demo/ai-structure")
|
||||
assert_html5_response_contract(
|
||||
@@ -1788,6 +1799,54 @@ def test_ai_structure_prepare_writes_ai_ready_package(tmp_path: Path):
|
||||
assert_html5_response_contract(html5_smb_without_credentials, "ошибка", "логин и пароль SMB")
|
||||
|
||||
|
||||
def test_ai_structure_prepare_understands_configuration_and_extension_folders(tmp_path: Path):
|
||||
source = tmp_path / "xml-export"
|
||||
config = source / "Конфигурация"
|
||||
extension = source / "CRM"
|
||||
config.mkdir(parents=True)
|
||||
extension.mkdir(parents=True)
|
||||
output = tmp_path / "ai-out-layout"
|
||||
(config / "metadata.xml").write_text(
|
||||
"""
|
||||
<Configuration>
|
||||
<Catalog name="Контрагенты" qualifiedName="Справочник.Контрагенты" />
|
||||
</Configuration>
|
||||
""",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(extension / "РасширениеCRM.mdo").write_text(
|
||||
"""
|
||||
<mdclass:ConfigurationExtension xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass/extension">
|
||||
<name>CRM</name>
|
||||
<version>1.0</version>
|
||||
<catalogs>
|
||||
<name>КонтрагентыCRM</name>
|
||||
</catalogs>
|
||||
</mdclass:ConfigurationExtension>
|
||||
""",
|
||||
encoding="utf-8",
|
||||
)
|
||||
client = TestClient(app)
|
||||
|
||||
response = client.post(
|
||||
"/ai-structure/prepare",
|
||||
json={"project_id": "ai-layout", "input_path": str(source), "output_path": str(output)},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
payload = response.json()
|
||||
assert payload["status"] == "ready"
|
||||
assert payload["source_layout"]["main_configuration_root"] == "Конфигурация"
|
||||
assert payload["source_layout"]["extension_roots"] == ["CRM"]
|
||||
assert payload["normalized"]["extensions"] == 1
|
||||
codex_package = output / payload["codex_package_folder"]
|
||||
layout = json.loads((codex_package / "indexes" / "project-layout.json").read_text(encoding="utf-8"))
|
||||
assert layout["kind"] == "configuration_with_extensions"
|
||||
assert layout["main_configuration_root"] == "Конфигурация"
|
||||
compact_objects = json.loads((codex_package / "indexes" / "objects-compact.json").read_text(encoding="utf-8"))
|
||||
assert any(item["extension"] == "CRM" for item in compact_objects)
|
||||
|
||||
|
||||
def test_ai_structure_prepare_reports_cf_cfe_export_required(tmp_path: Path):
|
||||
source = tmp_path / "cf-source"
|
||||
output = tmp_path / "cf-out"
|
||||
|
||||
Reference in New Issue
Block a user