re_similar, re_struct_audit; next_functions favours raw functions with a readable near-duplicate
This commit is contained in:
1 parent
2d2f5fe7c5
commit
07a031109b
4 files changed
+65
-4
No files matched your search
+26
-1
@@ -518,6 +518,30 @@ def re_match(targets: str, decomp: str | None = None) -> dict:
|
||||
raise ToolError(str(error)) from None
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def re_similar(target: str, k: int = 10, min_score: float = 0.7) -> dict:
|
||||
"""Functions whose instructions look like this one (normalized: addresses blanked, registers and small
|
||||
constants kept), best first, with each one's status. A readable near-duplicate is a head start: read it
|
||||
first. 0.85+ is usually the same code (template copies); 0.75-0.85 the same idiom; check before reusing."""
|
||||
try:
|
||||
from .reverse import run_toolkit
|
||||
return run_toolkit(harbor().project.reverse, "similar",
|
||||
[str(target), "--k", str(max(1, min(int(k), 50))), "--min", str(float(min_score))])
|
||||
except (HarborError, projects.ProjectError) as error:
|
||||
raise ToolError(str(error)) from None
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def re_struct_audit(struct: str) -> list:
|
||||
"""Check a struct's field types against how the game's code accesses it through its globals: width,
|
||||
signedness (movsx/movzx), float vs int, and unnamed bytes the code uses. Use it before changing types.h."""
|
||||
try:
|
||||
from .reverse import run_toolkit
|
||||
return run_toolkit(harbor().project.reverse, "struct_audit", ["--struct", str(struct)], json_to_file=True)
|
||||
except (HarborError, projects.ProjectError) as error:
|
||||
raise ToolError(str(error)) from None
|
||||
|
||||
|
||||
def _queue():
|
||||
from .queue import FunctionQueue
|
||||
return FunctionQueue(harbor())
|
||||
@@ -529,7 +553,8 @@ def next_functions(n: int = 10) -> list:
|
||||
by someone else, rejected fewer than the attempt cap. Each row says why it ranks where it does (size, how
|
||||
many callees already have names, the convention from the bytes, earlier rejections)."""
|
||||
try:
|
||||
return _queue().next_functions(me(), max(1, min(int(n), 50)))
|
||||
q = _queue()
|
||||
return q.next_functions(me(), max(1, min(int(n), 50)), similar_readable=q.similar_readable())
|
||||
except (HarborError, projects.ProjectError) as error:
|
||||
raise ToolError(str(error)) from None
|
||||
|
||||
|
||||
Reference in new issue
Block a user