Fix output truncation bug, add language support for agent responses
Bug 1 — Output truncation:
_run_claude() was replacing raw stdout with parsed sub-field which
could be a dict (not string). run_agent() then saved dict.__repr__
to DB instead of full JSON. Fixed: _run_claude() always returns
string output; run_agent() ensures string before DB write.
Added tests: full_output_saved_to_db, dict_output_saved_as_json_string.
Bug 2 — Language support:
Added projects.language column (TEXT DEFAULT 'ru').
Auto-migration for existing DBs (ALTER TABLE ADD COLUMN).
context_builder passes language in project context.
format_prompt() appends "## Language\nALWAYS respond in {language}"
at the end of every prompt.
CLI: kin project add --language ru (default: ru).
Tests: language in prompt for ru/en, project creation, context.
112 tests, all passing. ~/.kin/kin.db migrated (vdol: language=ru).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
38c252fc1b
commit
c129cf9d95
7 changed files with 117 additions and 18 deletions
|
|
@ -131,3 +131,33 @@ class TestFormatPrompt:
|
|||
ctx = build_context(conn, "VDOL-001", "analyst", "vdol")
|
||||
prompt = format_prompt(ctx, "analyst") # No analyst.md exists
|
||||
assert "analyst" in prompt.lower()
|
||||
|
||||
def test_format_includes_language_ru(self, conn):
|
||||
ctx = build_context(conn, "VDOL-001", "debugger", "vdol")
|
||||
prompt = format_prompt(ctx, "debugger", "Debug.")
|
||||
assert "## Language" in prompt
|
||||
assert "Russian" in prompt
|
||||
assert "ALWAYS respond in Russian" in prompt
|
||||
|
||||
def test_format_includes_language_en(self, conn):
|
||||
# Update project language to en
|
||||
conn.execute("UPDATE projects SET language='en' WHERE id='vdol'")
|
||||
conn.commit()
|
||||
ctx = build_context(conn, "VDOL-001", "debugger", "vdol")
|
||||
prompt = format_prompt(ctx, "debugger", "Debug.")
|
||||
assert "ALWAYS respond in English" in prompt
|
||||
|
||||
|
||||
class TestLanguageInProject:
|
||||
def test_project_has_language_default(self, conn):
|
||||
p = models.get_project(conn, "vdol")
|
||||
assert p["language"] == "ru"
|
||||
|
||||
def test_create_project_with_language(self, conn):
|
||||
p = models.create_project(conn, "en-proj", "English Project", "/en",
|
||||
language="en")
|
||||
assert p["language"] == "en"
|
||||
|
||||
def test_context_carries_language(self, conn):
|
||||
ctx = build_context(conn, "VDOL-001", "pm", "vdol")
|
||||
assert ctx["project"]["language"] == "ru"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue