Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

Fix PR review agent issues: remove thin wrapper, fix multi-segment domain refs

Louis Choqueleb0773275e57
diff --git a/.badges/tests.json b/.badges/tests.json
index d2538cbe8..62578c95e 100644
--- a/.badges/tests.json
+++ b/.badges/tests.json
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"label": "tests",
- "message": "4028",
+ "message": "4030",
"color": "blue",
"cacheSeconds": 300
}
\ No newline at end of file
diff --git a/pipelex/builder/concept/concept_spec.py b/pipelex/builder/concept/concept_spec.py
index 3ae765054..a4a856c06 100644
--- a/pipelex/builder/concept/concept_spec.py
+++ b/pipelex/builder/concept/concept_spec.py
@@ -262,7 +262,7 @@ class ConceptSpec(StructuredContent):
def validate_concept_code(cls, value: str) -> str:
# Split first to handle domain.ConceptCode format
if "." in value:
- domain, concept_code = value.split(".")
+ domain, concept_code = value.rsplit(".", 1)
# Only normalize the concept code part (not the domain)
normalized_concept_code = normalize_to_ascii(concept_code)
diff --git a/pipelex/cli/agent_cli/commands/pipe_cmd.py b/pipelex/cli/agent_cli/commands/pipe_cmd.py
index 2fb9dc4ef..30e3b5fb0 100644
--- a/pipelex/cli/agent_cli/commands/pipe_cmd.py
+++ b/pipelex/cli/agent_cli/commands/pipe_cmd.py
@@ -155,14 +155,6 @@ def _add_type_specific_fields(pipe_spec: PipeSpec, pipe_table: tomlkit.TOMLDocum
pipe_table.add("function_name", pipe_spec.function_name)
-def _parse_pipe_spec_from_json(pipe_type: str, spec_data: dict[str, Any]) -> PipeSpec:
- """Parse and validate a PipeSpec from JSON data.
-
- Thin wrapper around parse_pipe_spec from pipe_ops for backward compatibility.
- """
- return parse_pipe_spec(pipe_type, spec_data)
-
-
def pipe_cmd(
pipe_type: Annotated[
str | None,
@@ -249,7 +241,7 @@ def pipe_cmd(
# Validate and convert spec
try:
- pipe_spec = _parse_pipe_spec_from_json(resolved_pipe_type, spec_data)
+ pipe_spec = parse_pipe_spec(resolved_pipe_type, spec_data)
toml_content = _pipe_spec_to_toml(pipe_spec)
print(toml_content, end="" if toml_content.endswith("\n") else "\n")
diff --git a/tests/unit/pipelex/builder/concept/test_data.py b/tests/unit/pipelex/builder/concept/test_data.py
index 9aaf981d3..ddd7478dc 100644
--- a/tests/unit/pipelex/builder/concept/test_data.py
+++ b/tests/unit/pipelex/builder/concept/test_data.py
@@ -378,6 +378,20 @@ class ConceptCodeValidationTestCases:
"domain_v1.ConceptNameV2",
)
+ # Test case: multi-segment domain path -> splits on last dot
+ MULTI_SEGMENT_DOMAIN = (
+ "multi_segment_domain",
+ "legal.contracts.Invoice",
+ "legal.contracts.Invoice",
+ )
+
+ # Test case: multi-segment domain with snake_case concept -> PascalCase
+ MULTI_SEGMENT_DOMAIN_SNAKE = (
+ "multi_segment_domain_snake",
+ "legal.contracts.non_compete_clause",
+ "legal.contracts.NonCompeteClause",
+ )
+
TEST_CASES: ClassVar[list[tuple[str, str, str]]] = [
SNAKE_CASE_NO_DOMAIN,
PASCAL_CASE_NO_DOMAIN,
@@ -388,4 +402,6 @@ class ConceptCodeValidationTestCases:
MULTIPLE_UNDERSCORES,
WITH_NUMBERS_SNAKE,
WITH_NUMBERS_DOMAIN_SNAKE,
+ MULTI_SEGMENT_DOMAIN,
+ MULTI_SEGMENT_DOMAIN_SNAKE,
]
diff --git a/tests/unit/pipelex/cli/test_pipe_cmd.py b/tests/unit/pipelex/cli/test_pipe_cmd.py
index 5f0b2fddf..14f09f498 100644
--- a/tests/unit/pipelex/cli/test_pipe_cmd.py
+++ b/tests/unit/pipelex/cli/test_pipe_cmd.py
@@ -3,16 +3,16 @@
parse_pipe_spec tolerance tests (aliases, output dict, etc.) live in
tests/unit/pipelex/builder/operations/test_parse_pipe_spec.py.
pipe_spec_to_toml tests live in tests/unit/pipelex/builder/operations/test_pipe_spec_to_toml.py.
-This file tests CLI-layer concerns: pipe_type extraction from JSON,
-and the CLI-specific TOML serialization (_pipe_spec_to_toml which uses format_toml_string).
+This file tests CLI-layer concerns: TOML serialization (_pipe_spec_to_toml which uses format_toml_string)
+and integration of parse_pipe_spec with the CLI output path.
"""
from __future__ import annotations
from typing import Any, ClassVar
+from pipelex.builder.operations.pipe_ops import parse_pipe_spec
from pipelex.cli.agent_cli.commands.pipe_cmd import (
- _parse_pipe_spec_from_json, # noqa: PLC2701 # pyright: ignore[reportPrivateUsage]
_pipe_spec_to_toml, # noqa: PLC2701 # pyright: ignore[reportPrivateUsage]
)
@@ -43,23 +43,23 @@ class TestCliPipeCmd:
"prompt": "Write about @text",
}
pipe_type = spec.pop("type")
- result = _parse_pipe_spec_from_json(pipe_type, spec)
+ result = parse_pipe_spec(pipe_type, spec)
assert result.pipe_code == "test"
# -- CLI TOML serialization (uses format_toml_string) -----------------
def test_llm_model_appears_in_toml(self) -> None:
- spec = _parse_pipe_spec_from_json("PipeLLM", {**self._BASE_LLM})
+ spec = parse_pipe_spec("PipeLLM", {**self._BASE_LLM})
toml = _pipe_spec_to_toml(spec)
assert 'model = "$writing-creative"' in toml
def test_llm_different_model_in_toml(self) -> None:
- spec = _parse_pipe_spec_from_json("PipeLLM", {**self._BASE_LLM, "model": "$engineering-structured"})
+ spec = parse_pipe_spec("PipeLLM", {**self._BASE_LLM, "model": "$engineering-structured"})
toml = _pipe_spec_to_toml(spec)
assert 'model = "$engineering-structured"' in toml
def test_extract_model_in_toml(self) -> None:
- spec = _parse_pipe_spec_from_json(
+ spec = parse_pipe_spec(
"PipeExtract",
{
"pipe_code": "my_extract",
@@ -73,7 +73,7 @@ class TestCliPipeCmd:
assert 'model = "@default-extract-document"' in toml
def test_img_gen_model_in_toml(self) -> None:
- spec = _parse_pipe_spec_from_json(
+ spec = parse_pipe_spec(
"PipeImgGen",
{
"pipe_code": "my_img_gen",
@@ -88,18 +88,18 @@ class TestCliPipeCmd:
assert 'model = "$gen-image"' in toml
def test_toml_contains_pipe_section(self) -> None:
- spec = _parse_pipe_spec_from_json("PipeLLM", {**self._BASE_LLM})
+ spec = parse_pipe_spec("PipeLLM", {**self._BASE_LLM})
toml = _pipe_spec_to_toml(spec)
assert "[pipe.my_llm_pipe]" in toml
assert 'type = "PipeLLM"' in toml
def test_toml_contains_prompt(self) -> None:
- spec = _parse_pipe_spec_from_json("PipeLLM", {**self._BASE_LLM})
+ spec = parse_pipe_spec("PipeLLM", {**self._BASE_LLM})
toml = _pipe_spec_to_toml(spec)
assert 'prompt = "Write about @text"' in toml
def test_sequence_toml_has_steps(self) -> None:
- spec = _parse_pipe_spec_from_json(
+ spec = parse_pipe_spec(
"PipeSequence",
{
"pipe_code": "my_seq",
@@ -118,7 +118,7 @@ class TestCliPipeCmd:
def test_llm_no_model_omits_model_in_toml(self) -> None:
"""When model is None, no model line should appear in the TOML."""
- spec = _parse_pipe_spec_from_json(
+ spec = parse_pipe_spec(
"PipeLLM",
{
"pipe_code": "my_pipe",
@@ -143,7 +143,7 @@ class TestCliPipeCmd:
"output": {"type": "ImgGenPrompt"},
"prompt": "Generate a creative image prompt based on @idea",
}
- result = _parse_pipe_spec_from_json("PipeLLM", spec)
+ result = parse_pipe_spec("PipeLLM", spec)
assert result.model == "$writing-creative" # type: ignore[attr-defined]
assert result.output == "ImgGenPrompt"
@@ -157,7 +157,7 @@ class TestCliPipeCmd:
"output": {"type": "ImgGenPrompt"},
"prompt": "Generate a creative image prompt based on @idea",
}
- result = _parse_pipe_spec_from_json("PipeLLM", spec)
+ result = parse_pipe_spec("PipeLLM", spec)
toml = _pipe_spec_to_toml(result)
assert 'model = "$writing-creative"' in toml
assert 'output = "ImgGenPrompt"' in toml