Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions refact-agent/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ lto = true

[package]
name = "refact-lsp"
version = "0.10.21"
version = "0.10.30"
edition = "2021"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -18,10 +18,8 @@ shadow-rs = "1.1.0"
winreg = "0.55.0"

[dependencies]
ahash = "0.8.12"
astral-tokio-tar = "0.5.2"
axum = { version = "0.6.20", features = ["default", "http2"] }
async-process = "2.0.1"
async-stream = "0.3.5"
async-trait = "0.1.73"
backtrace = "0.3.71"
Expand All @@ -38,6 +36,7 @@ hashbrown = "0.15.2"
headless_chrome = "1.0.16"
heed = "0.22.0"
home = "0.5"
hostname = "0.4"
html2text = "0.12.5"
hyper = { version = "0.14", features = ["server", "stream"] }
image = "0.25.2"
Expand Down Expand Up @@ -82,7 +81,6 @@ tokio = { version = "1.43.0", features = ["fs", "io-std", "io-util", "macros", "
tokio-rusqlite = "0.5.0"
tokio-util = { version = "0.7.12", features = ["compat"] }
tokio-tungstenite = "0.21.0"
tower = { version = "0.4", features = ["full"] }
tower-http = { version = "0.4.0", features = ["cors"] }
tower-lsp = "0.20"
tracing = "0.1"
Expand All @@ -105,4 +103,5 @@ zerocopy = "0.8.14"

# There you can use a local copy
# rmcp = { path = "../../../rust-sdk/crates/rmcp/", "features" = ["client", "transport-child-process", "transport-sse"] }
rmcp = { git = "https://github.com/smallcloudai/rust-sdk", branch = "main", features = ["client", "transport-child-process", "transport-sse-client", "reqwest"] }
rmcp = { git = "https://github.com/smallcloudai/rust-sdk", branch = "main", features = ["client", "transport-child-process", "transport-sse-client", "reqwest"] }
thiserror = "2.0.12"
Original file line number Diff line number Diff line change
Expand Up @@ -13,104 +13,103 @@


# v W int
# U{ go_up root::W }
W = 640
# v H int
# U{ go_up root::H }
# U{ go_up root::W }
H = 480
# U{ go_up root::H }


# f draw_hello_frog() void
def draw_hello_frog(
# p screen ?::Surface
# U{ alias ?::pygame } U{ attr guess ?::Surface }
screen: pygame.Surface,
# p message str
# U{ alias ?::pygame } U{ attr guess ?::Surface }
message: str,
# p color (int,int,int)
color: Tuple[int, int, int] = (0, 255, 255),
# p font_name str
font_name: str = "Arial",
) -> None:
# v font ERR/FUNC_NOT_FOUND/?::SysFont
# U{ alias ?::pygame } U{ attr guess ?::font } U{ attr guess ?::SysFont } U{ go_up root::draw_hello_frog::font_name } U{ go_up root::draw_hello_frog::font }
font = pygame.font.SysFont(font_name, 32)
# v text ERR/FUNC_NOT_FOUND/?::render
# U{ go_up root::draw_hello_frog::font } U{ attr guess ?::render } U{ go_up root::draw_hello_frog::message } U{ go_up root::draw_hello_frog::color } U{ go_up root::draw_hello_frog::text }
# U{ alias ?::pygame } U{ attr guess ?::font } U{ attr guess ?::SysFont } U{ go_up root::draw_hello_frog::font_name } U{ go_up root::draw_hello_frog::font }
text = font.render(message, True, color)
# v text_rect ERR/FUNC_NOT_FOUND/?::get_rect
# U{ go_up root::draw_hello_frog::text } U{ attr guess ?::get_rect } U{ go_up root::draw_hello_frog::text_rect }
# U{ go_up root::draw_hello_frog::font } U{ attr guess ?::render } U{ go_up root::draw_hello_frog::message } U{ go_up root::draw_hello_frog::color } U{ go_up root::draw_hello_frog::text }
text_rect = text.get_rect()
# ERROR py_var_add cannot create: "attribute" in text_rect.center
# U{ go_up root::W } U{ go_up root::H } U{ go_up root::draw_hello_frog::text_rect } U{ attr guess ?::center }
# U{ go_up root::draw_hello_frog::text } U{ attr guess ?::get_rect } U{ go_up root::draw_hello_frog::text_rect }
text_rect.center = (W / 2, H / 2)
# U{ go_up root::draw_hello_frog::screen } U{ attr guess ?::blit } U{ go_up root::draw_hello_frog::text } U{ go_up root::draw_hello_frog::text_rect }
# U{ go_up root::W } U{ go_up root::H } U{ go_up root::draw_hello_frog::text_rect } U{ attr guess ?::center }
screen.blit(text, text_rect)
# U{ go_up root::draw_hello_frog::screen } U{ attr guess ?::blit } U{ go_up root::draw_hello_frog::text } U{ go_up root::draw_hello_frog::text_rect }


# v creatures [ERR/FUNC_NOT_FOUND/?::Frog]
# U{ go_up root::creatures }
creatures = [
# U{ alias ?::frog } U{ attr guess ?::Frog }
# U{ go_up root::creatures }
frog.Frog(
# U{ alias ?::numpy } U{ attr guess ?::random } U{ attr guess ?::uniform } U{ go_up root::W }
# U{ alias ?::frog } U{ attr guess ?::Frog }
np.random.uniform(0, W),
# U{ alias ?::numpy } U{ attr guess ?::random } U{ attr guess ?::uniform } U{ go_up root::H }
# U{ alias ?::numpy } U{ attr guess ?::random } U{ attr guess ?::uniform } U{ go_up root::W }
np.random.uniform(0, H),
# U{ alias ?::numpy } U{ attr guess ?::random } U{ attr guess ?::uniform } U{ go_up root::W } U{ go_up root::H }
# U{ alias ?::numpy } U{ attr guess ?::random } U{ attr guess ?::uniform } U{ go_up root::H }
np.random.uniform(-W/10, H/10),
# U{ alias ?::numpy } U{ attr guess ?::random } U{ attr guess ?::uniform } U{ go_up root::W } U{ go_up root::H }
np.random.uniform(-W/10, H/10),
# v i int
# U{ go_up root::<listcomp>::i }
# U{ alias ?::numpy } U{ attr guess ?::random } U{ attr guess ?::uniform } U{ go_up root::W } U{ go_up root::H }
) for i in range(10)]
# U{ go_up root::<listcomp>::i }


# f main_loop() !void
def main_loop():
# ERROR py_body syntax error: "comment" in # without space because it's a test it needs to pi...
# v screen ERR/FUNC_NOT_FOUND/?::set_mode
# U{ alias ?::pygame } U{ attr guess ?::display } U{ attr guess ?::set_mode } U{ go_up root::W } U{ go_up root::H } U{ go_up root::main_loop::screen }
screen = pygame.display.set_mode((W,H)) # without space because it's a test it needs to pick up the correct line below
# v quit_flag bool
# U{ go_up root::main_loop::quit_flag }
# U{ alias ?::pygame } U{ attr guess ?::display } U{ attr guess ?::set_mode } U{ go_up root::W } U{ go_up root::H } U{ go_up root::main_loop::screen }
quit_flag = False
# U{ go_up root::main_loop::quit_flag }
while not quit_flag:
# v event ERR/FUNC_NOT_FOUND/?::get
# U{ alias ?::pygame } U{ attr guess ?::event } U{ attr guess ?::get } U{ go_up root::main_loop::event }
# U{ go_up root::main_loop::quit_flag }
for event in pygame.event.get():
# U{ go_up root::main_loop::event } U{ attr guess ?::type } U{ alias ?::pygame } U{ attr guess ?::QUIT }
# U{ alias ?::pygame } U{ attr guess ?::event } U{ attr guess ?::get } U{ go_up root::main_loop::event }
if event.type == pygame.QUIT:
# U{ go_up root::main_loop::quit_flag }
# U{ go_up root::main_loop::event } U{ attr guess ?::type } U{ alias ?::pygame } U{ attr guess ?::QUIT }
quit_flag = True
# U{ go_up root::main_loop::screen } U{ attr guess ?::fill }
# U{ go_up root::main_loop::quit_flag }
screen.fill((0, 0, 0))
# U{ go_up root::creatures } U{ go_up root::main_loop::p }
# U{ go_up root::main_loop::screen } U{ attr guess ?::fill }
for p in creatures:
# U{ alias ?::pygame } U{ attr guess ?::draw } U{ attr guess ?::circle } U{ go_up root::main_loop::screen } U{ go_up root::main_loop::p } U{ attr guess ?::x } U{ go_up root::main_loop::p } U{ attr guess ?::y }
# U{ go_up root::creatures } U{ go_up root::main_loop::p }
pygame.draw.circle(screen, (0, 255, 0), (p.x, p.y), 10)
# U{ go_up root::draw_hello_frog } U{ go_up root::main_loop::screen }
# U{ alias ?::pygame } U{ attr guess ?::draw } U{ attr guess ?::circle } U{ go_up root::main_loop::screen } U{ go_up root::main_loop::p } U{ attr guess ?::x } U{ go_up root::main_loop::p } U{ attr guess ?::y }
draw_hello_frog(screen, "Jump To Conclusions!", (0, 200, 0))
# v p ?::Frog
# U{ alias ?::frog } U{ attr guess ?::Frog } U{ go_up root::main_loop::p }
# U{ go_up root::draw_hello_frog } U{ go_up root::main_loop::screen }
p: frog.Frog
# U{ go_up root::creatures } U{ go_up root::main_loop::p }
# U{ alias ?::frog } U{ attr guess ?::Frog } U{ go_up root::main_loop::p }
for p in creatures:
# U{ go_up root::main_loop::p } U{ attr guess ?::jump } U{ go_up root::W } U{ go_up root::H }
# U{ go_up root::creatures } U{ go_up root::main_loop::p }
p.jump(W, H)
# U{ alias ?::pygame } U{ attr guess ?::display } U{ attr guess ?::flip }
# U{ go_up root::main_loop::p } U{ attr guess ?::jump } U{ go_up root::W } U{ go_up root::H }
pygame.display.flip()
# U{ alias ?::pygame } U{ attr guess ?::time } U{ attr guess ?::Clock } U{ attr guess ?::tick }
# U{ alias ?::pygame } U{ attr guess ?::display } U{ attr guess ?::flip }
pygame.time.Clock().tick(60)
# U{ alias ?::pygame } U{ attr guess ?::time } U{ attr guess ?::Clock } U{ attr guess ?::tick }


if __name__ == '__main__':
# U{ alias ?::pygame } U{ attr guess ?::init }
pygame.init()
# U{ alias ?::pygame } U{ attr guess ?::display } U{ attr guess ?::set_caption }
# U{ alias ?::pygame } U{ attr guess ?::init }
pygame.display.set_caption("Pond")
# U{ go_up root::main_loop }
# U{ alias ?::pygame } U{ attr guess ?::display } U{ attr guess ?::set_caption }
main_loop()
# U{ alias ?::pygame } U{ attr guess ?::quit }
# U{ go_up root::main_loop }
pygame.quit()
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,47 @@ class Animal:
# p age int
def __init__(self, age: int):
# v age int
# U{ go_up root::Animal::__init__::age } U{ attr root::Animal::age }
self.age = age
# v also1_age float
# U{ go_up root::Animal::__init__::age } U{ attr root::Animal::also1_age }
# U{ go_up root::Animal::__init__::age } U{ attr root::Animal::age }
self.also1_age: float = age
# v also2_age ?
# U{ go_up root::Animal::__init__::age } U{ attr root::Animal::also2_age }
# U{ go_up root::Animal::__init__::age } U{ attr root::Animal::also1_age }
self.also2_age = float(age)
# v also3_age int
# U{ go_up root::Animal::__init__::age } U{ attr root::Animal::also3_age }
# U{ go_up root::Animal::__init__::age } U{ attr root::Animal::also2_age }
self.also3_age = age + 5.0
# U{ go_up root::Animal::__init__::age } U{ attr root::Animal::also3_age }

# f self_review() !void
# p self root::Animal
def self_review(self):
# U{ go_up_fail guess ?::print } U{ attr root::Animal::age }
print(f"self_review age={self.age}")
# U{ go_up_fail guess ?::print } U{ attr root::Animal::age }


# s Goat !root::Goat
# U{ go_up root::Animal }
class Goat(Animal):
# ERROR py_function parameter syntax: "list_splat_pattern" in *args
# ERROR py_function parameter syntax: "dictionary_splat_pattern" in **kwargs
# f __init__() !void
# p self root::Goat
# p age int
# p weight float
# U{ go_up root::Animal }
def __init__(self, age: int, weight: float, *args, **kwargs):
# U{ go_up_fail guess ?::super } U{ attr guess ?::__init__ } U{ go_up root::Goat::__init__::age }
super().__init__(age)
# v weight float
# U{ go_up root::Goat::__init__::weight } U{ attr root::Goat::weight }
# U{ go_up_fail guess ?::super } U{ attr guess ?::__init__ } U{ go_up root::Goat::__init__::age }
self.weight = weight
# U{ go_up root::Goat::__init__::weight } U{ attr root::Goat::weight }

# f jump_around() root::Animal
# p self root::Goat
# U{ go_up root::Animal }
def jump_around(self) -> Animal:
# U{ go_up_fail guess ?::print } U{ attr guess ?::age } U{ attr root::Goat::weight }
# U{ go_up root::Animal }
print(f"jump_around age={self.age} weight={self.weight}")
# U{ attr guess ?::self_review }
# U{ go_up_fail guess ?::print } U{ attr guess ?::age } U{ attr root::Goat::weight }
self.self_review()
# U{ attr guess ?::self_review }
return self
41 changes: 20 additions & 21 deletions refact-agent/engine/src/ast/alt_testsuite/py_goat_main_annotated.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,105 +10,104 @@ class CosmicJustice:
# p self root::CosmicJustice
def __init__(self):
# v balance float
# U{ attr root::CosmicJustice::balance }
self.balance = 0.0
# U{ attr root::CosmicJustice::balance }


# s CosmicGoat !root::CosmicGoat
# U{ alias ?::py_goat_library } U{ attr guess ?::Goat } U{ go_up root::CosmicJustice }
class CosmicGoat(py_goat_library.Goat, CosmicJustice):
# f __init__() !void
# p self root::CosmicGoat
# p age ?
# p weight ?
# p balance_ ?
# U{ alias ?::py_goat_library } U{ attr guess ?::Goat } U{ go_up root::CosmicJustice }
def __init__(self, age, weight, balance_):
# U{ alias ?::py_goat_library } U{ attr guess ?::Goat } U{ attr guess ?::__init__ } U{ go_up root::CosmicGoat::__init__::age } U{ go_up root::CosmicGoat::__init__::weight }
py_goat_library.Goat.__init__(self, age, weight)
# U{ go_up root::CosmicJustice } U{ attr guess ?::__init__ }
# U{ alias ?::py_goat_library } U{ attr guess ?::Goat } U{ attr guess ?::__init__ } U{ go_up root::CosmicGoat::__init__::age } U{ go_up root::CosmicGoat::__init__::weight }
CosmicJustice.__init__(self)
# v balance ?
# U{ go_up root::CosmicGoat::__init__::balance_ } U{ attr root::CosmicGoat::balance }
# U{ go_up root::CosmicJustice } U{ attr guess ?::__init__ }
self.balance = balance_
# U{ go_up root::CosmicGoat::__init__::balance_ } U{ attr root::CosmicGoat::balance }

# f say_hi() !void
# p self root::CosmicGoat
def say_hi(self):
# U{ go_up_fail guess ?::print } U{ attr guess ?::age } U{ attr guess ?::weight } U{ attr root::CosmicGoat::balance }
print(f"I am a CosmicGoat, age={self.age} weight={self.weight} balance={self.balance:.2f}")
# U{ go_up_fail guess ?::print } U{ attr guess ?::age } U{ attr guess ?::weight } U{ attr root::CosmicGoat::balance }


# f goat_generator1() !root::CosmicGoat
def goat_generator1():
# U{ go_up root::CosmicGoat }
return CosmicGoat(10, 20, 30.5)
# U{ go_up root::CosmicGoat }

# f goat_generator2() !root::CosmicGoat
def goat_generator2():
# U{ go_up root::CosmicGoat }
return CosmicGoat(11, 21, 31.5)
# U{ go_up root::CosmicGoat }


# f animal_direct_access() !void
# p v1 root::CosmicGoat
# p v2 ?::py_goat_library::Animal
# p v3 [?::py_goat_library::Animal]
# p v4 [?::py_goat_library::Animal]
# U{ go_up root::CosmicGoat } U{ alias ?::py_goat_library::Animal } U{ alias ?::py_goat_library::Animal } U{ alias ?::py_goat_library::Animal }
def animal_direct_access(v1: CosmicGoat, v2: Optional[Animal], v3: List[Animal], v4: List[Optional[Animal]]):
# ERROR py_type_of_expr syntax: "conditional_expression" in v2.age if v2 else 'None'
# ERROR py_type_of_expr syntax: "parenthesized_expression" in (y.age if y else 'not_a_goat')
# v x ?::py_goat_library::Animal
# v y ?::py_goat_library::Animal
# U{ go_up_fail guess ?::print } U{ go_up root::animal_direct_access::v1 } U{ attr guess ?::age } U{ go_up root::animal_direct_access::v3 } U{ go_up root::animal_direct_access::<listcomp>::x } U{ go_up root::animal_direct_access::<listcomp>::x } U{ attr guess ?::age } U{ go_up root::animal_direct_access::v4 } U{ go_up root::animal_direct_access::<listcomp>::y }
# U{ go_up root::CosmicGoat } U{ alias ?::py_goat_library::Animal } U{ alias ?::py_goat_library::Animal } U{ alias ?::py_goat_library::Animal }
print(f"animal_direct_access: age1={v1.age} age2={v2.age if v2 else 'None'} age3={[x.age for x in v3]} age4={[(y.age if y else 'not_a_goat') for y in v4]}")
# U{ go_up_fail guess ?::print } U{ go_up root::animal_direct_access::v1 } U{ attr guess ?::age } U{ go_up root::animal_direct_access::v3 } U{ go_up root::animal_direct_access::<listcomp>::x } U{ go_up root::animal_direct_access::<listcomp>::x } U{ attr guess ?::age } U{ go_up root::animal_direct_access::v4 } U{ go_up root::animal_direct_access::<listcomp>::y }


# f animal_function_calling() !void
# p v1 root::CosmicGoat
# p v2 ?::py_goat_library::Animal
# p v3 [?::py_goat_library::Animal]
# p v4 [?::py_goat_library::Animal]
# U{ go_up root::CosmicGoat } U{ alias ?::py_goat_library::Animal } U{ alias ?::py_goat_library::Animal } U{ alias ?::py_goat_library::Animal }
def animal_function_calling(v1: CosmicGoat, v2: Optional[Animal], v3: List[Animal], v4: List[Optional[Animal]]):
# U{ go_up root::animal_function_calling::v1 } U{ attr guess ?::self_review }
# U{ go_up root::CosmicGoat } U{ alias ?::py_goat_library::Animal } U{ alias ?::py_goat_library::Animal } U{ alias ?::py_goat_library::Animal }
v1.self_review()
# ERROR py_body syntax error: "identifier" in v2
# U{ go_up root::animal_function_calling::v1 } U{ attr guess ?::self_review }
if v2:
# U{ go_up root::animal_function_calling::v2 } U{ attr guess ?::self_review }
v2.self_review()
# v x ?::py_goat_library::Animal
# U{ go_up root::animal_function_calling::v3 } U{ go_up root::animal_function_calling::x }
# U{ go_up root::animal_function_calling::v2 } U{ attr guess ?::self_review }
for x in v3:
# U{ go_up root::animal_function_calling::x } U{ attr guess ?::self_review }
# U{ go_up root::animal_function_calling::v3 } U{ go_up root::animal_function_calling::x }
x.self_review()
# v y ?::py_goat_library::Animal
# U{ go_up root::animal_function_calling::v4 } U{ go_up root::animal_function_calling::y }
# U{ go_up root::animal_function_calling::x } U{ attr guess ?::self_review }
for y in v4:
# ERROR py_body syntax error: "identifier" in y
# U{ go_up root::animal_function_calling::v4 } U{ go_up root::animal_function_calling::y }
if y:
# U{ go_up root::animal_function_calling::y } U{ attr guess ?::self_review }
y.self_review()
# U{ go_up root::animal_function_calling::y } U{ attr guess ?::self_review }


# f goat_generator() (root::CosmicGoat,root::CosmicGoat)
# U{ go_up root::CosmicGoat } U{ go_up root::CosmicGoat }
def goat_generator() -> Tuple[CosmicGoat, CosmicGoat]:
# U{ go_up root::CosmicGoat } U{ go_up root::CosmicGoat }
return CosmicGoat(2, 2.0, 13.37), CosmicGoat(3, 4.0, 13.37)
# U{ go_up root::CosmicGoat } U{ go_up root::CosmicGoat }


if __name__ == '__main__':
# ERROR py_type_of_expr syntax: "list_splat" in *goat_generator()
# ERROR py_type_of_expr syntax: "list" in [CosmicGoat(4, 4.0, 13.37)]
# ERROR py_type_of_expr syntax: "list" in [CosmicGoat(5, 5.0, 13.37), None]
# U{ go_up root::animal_function_calling }
animal_function_calling(*goat_generator(), [CosmicGoat(4, 4.0, 13.37)], [CosmicGoat(5, 5.0, 13.37), None])
# v goat_generator_copy (root::CosmicGoat,root::CosmicGoat)
# U{ go_up root::goat_generator } U{ go_up root::goat_generator_copy }
# U{ go_up root::animal_function_calling }
goat_generator_copy = goat_generator
# ERROR py_type_of_expr syntax: "list_splat" in *goat_generator_copy()
# ERROR py_type_of_expr syntax: "list" in [CosmicGoat(4, 4.0, 13.37)]
# ERROR py_type_of_expr syntax: "list" in [CosmicGoat(5, 5.0, 13.37), None]
# U{ go_up root::animal_direct_access }
# U{ go_up root::goat_generator } U{ go_up root::goat_generator_copy }
animal_direct_access(*goat_generator_copy(), [CosmicGoat(4, 4.0, 13.37)], [CosmicGoat(5, 5.0, 13.37), None])
Loading
Loading