Skip to content

Official Codebase of 3DCodeVerse

Python

single-shot: the output format is stated once, in singleshot_format.md

gaoypenge6c70f61be03
diff --git a/harness/codeverse3d/tracks/generation.py b/harness/codeverse3d/tracks/generation.py
index 13a24a70..c34836f7 100644
--- a/harness/codeverse3d/tracks/generation.py
+++ b/harness/codeverse3d/tracks/generation.py
@@ -5,7 +5,7 @@
the workspace is materialised once per run (AGENTS.md + MCP config), then
``agent.run(AgentJob)``. Truth is on disk: ``ok`` means files changed.
* **Single-shot path** — ``agent_id = "single-shot:<provider>:<model>"``: one
- ``ChatRequest`` whose answer is a multi-file envelope (``SINGLE_SHOT_FORMAT``),
+ ``ChatRequest`` whose answer is a multi-file envelope (``prompts/system/singleshot_format.md``),
parsed by ``parse_multifile`` and written under the allowed roots. This is
handled here (not in the agents registry) because it is not an agent.
@@ -67,17 +67,6 @@ ALLOWED_ROOTS: tuple[str, ...] = ("src/", "public/")
#: where an out-of-workspace task image is copied so a vendor CLI can read it (D9, like the cookbook)
IMAGES_DIR = ".3dcode/images"
-SINGLE_SHOT_FORMAT = """OUTPUT FORMAT (exactly this, nothing else around it):
-For EVERY file you create or fully rewrite, emit one block:
-
-=== FILE: <relative path, e.g. src/parts/seat.js> ===
-<complete file contents — the whole file, not a diff>
-=== END FILE ===
-
-Rules: paths are relative to the workspace root and must start with src/ (or public/);
-emit the COMPLETE contents of each file (no "...rest unchanged"); no prose outside the blocks;
-no markdown fences inside a block (plain code). Files you do not emit are left untouched."""
-
class GenerationError(RuntimeError):
"""Raised when the generator cannot produce usable files (bad envelope, agent crash)."""
@@ -98,7 +87,7 @@ _FENCE_PATH_HINT = re.compile(
def parse_multifile(text: str, *, expected_files: list[str] | None = None) -> dict[str, str]:
- """Parse ``SINGLE_SHOT_FORMAT`` → ``{path: content}``.
+ """Parse the ``system/singleshot_format.md`` envelope → ``{path: content}``.
Tolerant to: a fenced block wrapping a file body; an answer that is ONE fenced
block when exactly one entry file is expected; fenced blocks preceded by a line
diff --git a/harness/codeverse3d/tracks/prompting.py b/harness/codeverse3d/tracks/prompting.py
index 3dfe0d41..800f8fe7 100644
--- a/harness/codeverse3d/tracks/prompting.py
+++ b/harness/codeverse3d/tracks/prompting.py
@@ -33,7 +33,6 @@ from codeverse3d.tracks.depth import (
depth_budget,
interfaces_text,
)
-from codeverse3d.tracks.generation import SINGLE_SHOT_FORMAT
if TYPE_CHECKING:
from codeverse3d.prompts.sections import Section
@@ -293,7 +292,7 @@ def base_prompt_context(ctx: RunContext, **extra: Any) -> dict[str, Any]:
"cookbook_excerpt": ctx.cookbook_text,
"tool_cards": ctx.tool_cards,
"single_shot": ctx.single_shot,
- "output_format": SINGLE_SHOT_FORMAT if ctx.single_shot else AGENT_OUTPUT_RULES,
+ "output_format": SINGLE_SHOT_OUTPUT if ctx.single_shot else AGENT_OUTPUT_RULES,
"spec_prompt": ctx.spec.prompt,
"constraints": constraints_text(ctx.spec),
"object_name": object_name,
@@ -520,6 +519,10 @@ def measurement_vs_plan(
return "\n".join(lines + gate_lines)
+#: the format itself is stated once, in the system prompt ``generate_files`` appends
+#: (``prompts/system/singleshot_format.md``); the brief only points at it
+SINGLE_SHOT_OUTPUT = "Reply with the file blocks exactly as the single-shot response format in your system prompt says."
+
AGENT_OUTPUT_RULES = """HOW TO FINISH (agent mode): edit files under src/ only (and public/ for compiled assets).
Before you finish you MUST run the `build` tool and fix every error it reports; then run `measure`
(objects) or `scene_probe` (scenes) once and compare the numbers with the plan. Do not write
diff --git a/harness/tests/orchestrator_tracks/test_generation_planner_repair.py b/harness/tests/orchestrator_tracks/test_generation_planner_repair.py
index e6473e28..8fdfde41 100644
--- a/harness/tests/orchestrator_tracks/test_generation_planner_repair.py
+++ b/harness/tests/orchestrator_tracks/test_generation_planner_repair.py
@@ -12,7 +12,6 @@ from codeverse3d.orchestrator import BudgetGuard, RoundPolicy, RunState
from codeverse3d.proc import EventLog
from codeverse3d.tracks.common import RunContext
from codeverse3d.tracks.generation import (
- SINGLE_SHOT_FORMAT,
GenerationError,
GenerationTask,
MultiFileParseError,
@@ -60,7 +59,6 @@ def test_write_files_filters_paths_and_os_errors(tmp_ws):
safe_relpath(bad)
changes = write_files(tmp_ws, {"src/a.js": "x", "public/b.txt": "y\n"})
assert [c.path for c in changes] == ["src/a.js", "public/b.txt"] and (tmp_ws.src / "a.js").read_text() == "x\n"
- assert "=== FILE:" in SINGLE_SHOT_FORMAT
skipped: list[str] = []
changes = write_files(