mycode-sdk 0.5.5__tar.gz → 0.5.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/PKG-INFO +1 -1
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/pyproject.toml +1 -1
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/messages.py +1 -1
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/tools.py +29 -47
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/.gitignore +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/LICENSE +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/README.md +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/__init__.py +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/agent.py +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/models.py +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/models_catalog.json +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/providers/__init__.py +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/providers/anthropic_like.py +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/providers/base.py +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/providers/gemini.py +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/providers/openai_chat.py +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/providers/openai_responses.py +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/py.typed +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/session.py +0 -0
- {mycode_sdk-0.5.5 → mycode_sdk-0.5.7}/src/mycode/utils.py +0 -0
|
@@ -103,7 +103,7 @@ def tool_result_block(
|
|
|
103
103
|
`output` is replayed back to providers on later turns.
|
|
104
104
|
`content` carries multimodal blocks (e.g. images) that providers should
|
|
105
105
|
replay alongside the text. `metadata` is an optional structured payload
|
|
106
|
-
for UI consumption (e.g. edit
|
|
106
|
+
for UI consumption (e.g. edit patch and line stats).
|
|
107
107
|
"""
|
|
108
108
|
|
|
109
109
|
block: ContentBlock = {
|
|
@@ -32,7 +32,7 @@ from base64 import b64encode
|
|
|
32
32
|
from collections import deque
|
|
33
33
|
from collections.abc import Callable, Sequence
|
|
34
34
|
from dataclasses import dataclass
|
|
35
|
-
from difflib import SequenceMatcher
|
|
35
|
+
from difflib import SequenceMatcher, unified_diff
|
|
36
36
|
from mimetypes import guess_type
|
|
37
37
|
from pathlib import Path
|
|
38
38
|
from typing import Any, Literal, TextIO, cast, get_args, get_origin, overload
|
|
@@ -67,9 +67,9 @@ class ToolExecutionResult:
|
|
|
67
67
|
- **provider** — gets ``output`` (a text summary) and, for multimodal
|
|
68
68
|
returns, ``content`` (structured blocks such as an image). ``output``
|
|
69
69
|
is replayed on later turns.
|
|
70
|
-
- **UI** — reads ``metadata`` for structured rendering (e.g. edit
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
- **UI** — reads ``metadata`` for structured rendering (e.g. edit patch
|
|
71
|
+
and stats). When ``metadata`` is absent, the UI falls back to ``output``
|
|
72
|
+
as a one-line summary.
|
|
73
73
|
"""
|
|
74
74
|
|
|
75
75
|
output: str
|
|
@@ -637,52 +637,34 @@ def _run_edit(ctx: ToolContext, args: dict[str, Any]) -> ToolExecutionResult:
|
|
|
637
637
|
except Exception as exc:
|
|
638
638
|
return ToolExecutionResult(output=f"error: failed to write file: {exc}", is_error=True)
|
|
639
639
|
|
|
640
|
-
#
|
|
641
|
-
#
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
for start, end, new_text, _ in matches:
|
|
651
|
-
old_snippet = text[start:end]
|
|
652
|
-
new_start = start + char_shift
|
|
653
|
-
start_line = updated[:new_start].count("\n") + 1
|
|
654
|
-
old_lines_list = old_snippet.splitlines()
|
|
655
|
-
new_lines_list = new_text.splitlines()
|
|
656
|
-
old_lc = len(old_lines_list) or 1
|
|
657
|
-
new_lc = len(new_lines_list) or 1
|
|
658
|
-
|
|
659
|
-
added = 0
|
|
660
|
-
removed = 0
|
|
661
|
-
for tag, i1, i2, j1, j2 in SequenceMatcher(None, old_lines_list, new_lines_list).get_opcodes():
|
|
662
|
-
if tag in ("replace", "delete"):
|
|
663
|
-
removed += i2 - i1
|
|
664
|
-
if tag in ("replace", "insert"):
|
|
665
|
-
added += j2 - j1
|
|
666
|
-
|
|
667
|
-
si = start_line - 1
|
|
668
|
-
before = updated_lines[max(0, si - context_lines) : si]
|
|
669
|
-
after = updated_lines[si + new_lc : si + new_lc + context_lines]
|
|
670
|
-
|
|
671
|
-
edit_metas.append(
|
|
672
|
-
{
|
|
673
|
-
"start_line": start_line,
|
|
674
|
-
"old_line_count": old_lc,
|
|
675
|
-
"new_line_count": new_lc,
|
|
676
|
-
"added_lines": added,
|
|
677
|
-
"removed_lines": removed,
|
|
678
|
-
"context_before": before,
|
|
679
|
-
"context_after": after,
|
|
680
|
-
}
|
|
640
|
+
# The UI renders this standard patch directly; stats are counted from the
|
|
641
|
+
# same patch so TUI and web show the same +N/-N numbers.
|
|
642
|
+
patch_lines = list(
|
|
643
|
+
unified_diff(
|
|
644
|
+
text.splitlines(),
|
|
645
|
+
updated.splitlines(),
|
|
646
|
+
fromfile=f"a/{path}",
|
|
647
|
+
tofile=f"b/{path}",
|
|
648
|
+
n=3,
|
|
649
|
+
lineterm="",
|
|
681
650
|
)
|
|
682
|
-
|
|
651
|
+
)
|
|
652
|
+
patch = "\n".join(patch_lines)
|
|
653
|
+
if patch:
|
|
654
|
+
patch += "\n"
|
|
655
|
+
patch_body = patch_lines[2:]
|
|
656
|
+
added_lines = sum(1 for line in patch_body if line.startswith("+"))
|
|
657
|
+
removed_lines = sum(1 for line in patch_body if line.startswith("-"))
|
|
683
658
|
|
|
684
659
|
summary = f"Updated {path}" if len(edits) == 1 else f"Updated {path} ({len(edits)} edits)"
|
|
685
|
-
return ToolExecutionResult(
|
|
660
|
+
return ToolExecutionResult(
|
|
661
|
+
output=summary,
|
|
662
|
+
metadata={
|
|
663
|
+
"patch": patch,
|
|
664
|
+
"added_lines": added_lines,
|
|
665
|
+
"removed_lines": removed_lines,
|
|
666
|
+
},
|
|
667
|
+
)
|
|
686
668
|
|
|
687
669
|
|
|
688
670
|
def _closest_line_hint(text: str, needle: str) -> str | None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|