Show HN: Superblocks AI – AI coding assistant for internal apps(superblocks.com)
superblocks.com
Show HN: Superblocks AI – AI coding assistant for internal apps
https://www.superblocks.com/blog/introducing-superblocks-ai
65 comments
I honestly really like this, both conceptually and from an implementations point of view.
Assisting in the creation of single purpose functions is, in my experience, by far the most reliable use case for LLMs in regard to code creation at this point in time, yet is something I haven't seen many companies really lean into. In fact, the only other example I know of is Cloudflares Workers Workshop [0], which I have been waiting for since May.
What I especially like about the implementation showcased in your demo videos though was the visual component. Some subtle animations, effective use of diff, methods being editable before pasting, it all felt very cohesive and thought through, which is something I can't say about every company utilizing OpenAIs APIs. Seems more like something that can serve a real value add for users, rather than just jumping on LLMs because it's the hot thing this summer.
Really hope more people are experimenting with the "visual implementation" of LLMs, using animations and graphs to communicate LLM outputs has a lot of unused potential currently.
[0] https://blog.cloudflare.com/introducing-cursor-the-ai-assist...
Assisting in the creation of single purpose functions is, in my experience, by far the most reliable use case for LLMs in regard to code creation at this point in time, yet is something I haven't seen many companies really lean into. In fact, the only other example I know of is Cloudflares Workers Workshop [0], which I have been waiting for since May.
What I especially like about the implementation showcased in your demo videos though was the visual component. Some subtle animations, effective use of diff, methods being editable before pasting, it all felt very cohesive and thought through, which is something I can't say about every company utilizing OpenAIs APIs. Seems more like something that can serve a real value add for users, rather than just jumping on LLMs because it's the hot thing this summer.
Really hope more people are experimenting with the "visual implementation" of LLMs, using animations and graphs to communicate LLM outputs has a lot of unused potential currently.
[0] https://blog.cloudflare.com/introducing-cursor-the-ai-assist...
Thanks for the kind words! A lot of thought went into the user experience. You can expect the same level of thought with all of our future AI features.
This is neat, but, as with all projects in this vein, I fail to see the real value add. We've had ML-powered code generation for several years now (Copilot released publicly in late 2021), and apart from a cute novelty, there's no real use case I've found. (Maybe except for generating tests, but when dealing with a novel code base, the models really can't figure out dependency injection, mocks, weird edge cases I'd care about, etc.)
This might be a bit contrarian, but I don't really think there's product market fit here, at least for engineers. And if given in the hands of non-engineers, you'll need to have an engineer at least look over the code anyway. I haven't seen or heard of anyone that seriously uses ChatGPT to generate code and uses it in prod (apart from engagement-farming Twitter posts).
> Understanding someone else’s code for large internal engineering teams is often a challenge
Without proper context, this will fail miserably. Have you ever seen a corporate codebase before? It can be the definition of "wtf?" even for a seasoned developer that's been working there for years.
This AI-generated code trend reminds me of the "no-code" fad of the past decade.
This might be a bit contrarian, but I don't really think there's product market fit here, at least for engineers. And if given in the hands of non-engineers, you'll need to have an engineer at least look over the code anyway. I haven't seen or heard of anyone that seriously uses ChatGPT to generate code and uses it in prod (apart from engagement-farming Twitter posts).
> Understanding someone else’s code for large internal engineering teams is often a challenge
Without proper context, this will fail miserably. Have you ever seen a corporate codebase before? It can be the definition of "wtf?" even for a seasoned developer that's been working there for years.
This AI-generated code trend reminds me of the "no-code" fad of the past decade.
I feel like I live in an alternate universe to this comment. Every engineer I know (devops, software, hell even datascience) is using GPT-4 or Copilot (especially Copilot with the new chat interface) and people, myself included, use it every day. Refactor this code for me, add a function that does X, why is Y failing, align this code with a different coding pattern, I cobbled together this React app, clean it up and refactor it and factor Z functionality into a node backend, help me understand this bit of obtuse Python code, and the list goes on and on and on. I've seen tremendous value, and its not without fault mind you, LLM hallucination is a real problem, but I would be very sad and annoyed if tomorrow they'd take LLMs out of my daily engineering flow.
Copilot shines with a number of things and isn't very good at a number of other things. Whether you get value out of Copilot says more, I think, about the kind of work you do on a day-to-day basis than it does about the utility of Copilot.
Copilot/GPT is excellent at writing lots of new lines of code. It's also really good at getting you started in code/frameworks that you don't really understand.
However, Copilot/GPT is not nearly as good at troubleshooting problems in existing code. If your job involves lots of bug fixing or tweaks to existing features, Copilot and GPT are next to useless.
I've noticed that if my work falls into the first category, Copilot often speeds me up something like 30% to 40%. If my work falls into the second category, it's 0%.
Copilot/GPT is excellent at writing lots of new lines of code. It's also really good at getting you started in code/frameworks that you don't really understand.
However, Copilot/GPT is not nearly as good at troubleshooting problems in existing code. If your job involves lots of bug fixing or tweaks to existing features, Copilot and GPT are next to useless.
I've noticed that if my work falls into the first category, Copilot often speeds me up something like 30% to 40%. If my work falls into the second category, it's 0%.
It's not better then me.
But I use it when I'm lazy, tired or at times drinking.
And then it's really nice. At times it costs me too much time solving it's mistakes. But then it nails something perfectly and I'm impressed again.
But I use it when I'm lazy, tired or at times drinking.
And then it's really nice. At times it costs me too much time solving it's mistakes. But then it nails something perfectly and I'm impressed again.
I often work with new (to me) tech or build prototypes/PoCs, it's pretty great for that.
It's useful to recognize when a dialog is a dead-end, otherwise it's easy to enter a rabbit hole that the llm can't get out of. Best to poke at it from another angle and/or within a new dialog, then.
It's useful to recognize when a dialog is a dead-end, otherwise it's easy to enter a rabbit hole that the llm can't get out of. Best to poke at it from another angle and/or within a new dialog, then.
> It's not better then me.
Where did anyone say it was?
Where did anyone say it was?
It’s normal. Early adopters always feel this way. It happened with home PCs, internet connections, the iPod, smartphones.
They will talk down to you about it until the wave rolls over them. It’s a tradition as old as mainframe engineers mocking PDP-11 hackers.
This one will be particularly rough for the late adopters, since one of the effects of ML code generation is compression of experience level.
They will talk down to you about it until the wave rolls over them. It’s a tradition as old as mainframe engineers mocking PDP-11 hackers.
This one will be particularly rough for the late adopters, since one of the effects of ML code generation is compression of experience level.
Forgive the long reply, but I'm going to go ahead and "press X to doubt," because I have been trying to use both ChatGPT and Copilot, and the results are abysmal apart from anything but "write me a linked list" or "give me some React boilerplate." If you have examples of it working for you, please share them. Here's a very salient example of it not working for me: I spent about 1-2 days figuring this out, so it's definitely non-trivial, but it's not something insane either. I'm working on a new project/startup idea and this is part of it (verbatim prompt I just used on chatGPT):
So what is ML code generation useful for? Apart from helping on the Nth CRUD app someone's building, I just don't see it.
hi, can you write me a function in rust that, if running on windows:
1. figures out if the topmost window is a windows explorer window
2. if it's a windows explorer window, it returns the path (as a string) that the windows explorer window is actively viewing
3. if it's not a windows explorer window, it returns a blank string
This is a deceptively difficult task, as it requires all kinds of COM finagling, and ChatGPT gets it royally wrong: #[cfg(windows)]
fn get_active_explorer_path() -> String {
use std::ptr;
use winapi::um::winuser::{EnumWindows, GetWindowTextW, IsWindowVisible};
use winapi::shared::windef::HWND;
use std::os::raw::c_int;
use std::ffi::OsString;
use std::os::windows::ffi::OsStringExt;
let mut path = String::new();
let mut active_explorer = None;
unsafe extern "system" fn enum_windows_callback(hwnd: HWND, lparam: LPARAM) -> c_int {
let active_explorer = &mut *(lparam as *mut Option<HWND>);
let mut buffer: [u16; 512] = [0; 512];
if IsWindowVisible(hwnd) != 0 && GetWindowTextW(hwnd, buffer.as_mut_ptr(), 512) != 0 {
let window_title = OsString::from_wide(&buffer[..]).to_string_lossy();
if window_title == "File Explorer" {
*active_explorer = Some(hwnd);
return 0; // Stop enumeration
}
}
1 // Continue enumeration
}
unsafe {
EnumWindows(Some(enum_windows_callback), &mut active_explorer as *mut _ as LPARAM);
}
if let Some(hwnd) = active_explorer {
let mut buffer: [u16; 512] = [0; 512];
if GetWindowTextW(hwnd, buffer.as_mut_ptr(), 512) != 0 {
let window_title = OsString::from_wide(&buffer[..]).to_string_lossy();
if window_title == "File Explorer" {
let shell32 = winapi::um::shellapi::GetShellWindow();
if shell32 != hwnd {
let mut path_buffer: [u16; 512] = [0; 512];
if winapi::um::shellapi::SHGetPathFromIDListW(ptr::null_mut(), path_buffer.as_mut_ptr()) != 0 {
let path_str = OsString::from_wide(&path_buffer[..]).to_string_lossy();
path = path_str.into_owned();
}
}
}
}
}
path
}
I'm actually on my Mac right now, and I don't even need to test it, because the first red flag is `"window_title == "File Explorer"`. File Explorer will change its window titlebar to the currently viewed folder (so the conditional will always fail). There's also other comical mistakes, including passing a null pointer to `SHGetPathFromIDListW`, using `GetShellWindow` which returns the desktop, and not taking into account that Explorer windows can have multiple tabs. Okay, let's see if we fare better on MacOS. #[cfg(target_os = "macos")]
fn get_active_finder_path() -> String {
use std::ptr;
use objc::runtime::{Class, Object};
use objc::{class, msg_send, sel, sel_impl};
use objc_id::Id;
let mut path = String::new();
unsafe {
let workspace: Id<Object> = msg_send![class!(NSWorkspace), sharedWorkspace];
let front_window: Id<Object> = msg_send![workspace, frontmostApplication];
let front_window_pid: u32 = msg_send![front_window, processIdentifier];
let running_apps: Id<Object> = msg_send![workspace, runningApplications];
let app_count: usize = msg_send![running_apps, count];
for i in 0..app_count {
let app: Id<Object> = msg_send![running_apps, objectAtIndex: i];
let app_pid: u32 = msg_send![app, processIdentifier];
if app_pid == front_window_pid {
let bundle_url: Id<Object> = msg_send![app, bundleURL];
let bundle_path: *const Object = msg_send![bundle_url, path];
let path_str: *const i8 = msg_send![bundle_path, UTF8String];
if !path_str.is_null() {
let c_str = std::ffi::CStr::from_ptr(path_str);
path = c_str.to_string_lossy().to_string();
}
break;
}
}
}
path
}
#[cfg(not(target_os = "macos"))]
fn get_active_finder_path() -> String {
String::new()
}
fn main() {
let active_finder_path = get_active_finder_path();
println!("Active Finder Path: {}", active_finder_path);
}
Doesn't look like it: this is what I got, which doesn't even compile. I'm not as familiar with MacOS systems programming, so I'm not even sure what's wrong with it, frankly. My solution involved using osascript on MacOS (which is the first Google hit, though I'll have to port it, as some folks may not have it on their systems).So what is ML code generation useful for? Apart from helping on the Nth CRUD app someone's building, I just don't see it.
I get a lot of mileage out of GPT, so let me see if I can explain. I wouldn't ask GPT/Copilot to do what you asked. After using them for a while you start to get an intuitive sense of what's easy and what's hard for them to do, and your specific example is indeed too difficult to get GPT to do properly. They have the biggest utility for me for stuff that I would ask a junior programmer to do - like a new grad.
The real value proposition of GPT isn't that it can solve really hard problems. The value proposition is that it's about as capable as a junior engineer, except it can write code much faster than any junior engineer, so it can speed you along on the boilerplate-y parts of coding that otherwise would be a lot of manual effort. It's especially useful for things that feel "easy" but which I don't have the relevant domain expertise. For instance, the other day I needed to write a fairly trivial shell script to parse some JSON files. I never write shell scripts and I always forget the syntax, but GPT wrote it correctly on the first try. That probably saved me 20-30 minutes of googling for how to do things like read files, etc in shell scripts.
The real value proposition of GPT isn't that it can solve really hard problems. The value proposition is that it's about as capable as a junior engineer, except it can write code much faster than any junior engineer, so it can speed you along on the boilerplate-y parts of coding that otherwise would be a lot of manual effort. It's especially useful for things that feel "easy" but which I don't have the relevant domain expertise. For instance, the other day I needed to write a fairly trivial shell script to parse some JSON files. I never write shell scripts and I always forget the syntax, but GPT wrote it correctly on the first try. That probably saved me 20-30 minutes of googling for how to do things like read files, etc in shell scripts.
It’s great at simple tedious stuff.
It’s useful for average things and concepts we might be unfamiliar with.
It’s of limited use, if not utterly useless, for most things a senior would have a hard time wrapping their head around.
And where it really shines, is when adapting an answer you’d otherwise look for on Google to your code, context, and constraints.
It’s useful for average things and concepts we might be unfamiliar with.
It’s of limited use, if not utterly useless, for most things a senior would have a hard time wrapping their head around.
And where it really shines, is when adapting an answer you’d otherwise look for on Google to your code, context, and constraints.
The problem is that you are using it for a "deceptively difficult task" and not "a task I know how to do, or could easily look up, but would prefer not to". Looking at my ChatGPT history, some things I've used it for in the last week (all GPT-4):
* Formatting a huge confusing blob of python code, markdown, and json into something readable.
* Writing "boring" python functions needed to interface with AWS DynamoDB & S3.
* Going from 0 -> 1 on a side project creating printable QR codes that redirect to custom links with logging. (Literally gave me picture perfect step by step instructions here, as if it was reading off the AWS UI. The sole issue I had it helped me troubleshoot).
* JS tutoring.
* Integrating an unfamiliar authentication provider with a web app. It gave me boilerplate code that needed like 1-2 tweaks to work perfectly.
* Long winded architectural discussion giving me ideas on where to take internal libraries.
Other than that, I've actually found that the github copilot CLI is a fantastic tool I've been turning to more and more. There are so many CLI tools that I kinda sorta remember the flags for, and now I no longer have to munge about looking things up. Just earlier I needed some test api key and I just said "!! generate a random api key", and it immediately came back with "openssl rand -base64 32". That works, and saved me time googling it.
Also, your prompt here is pretty weak. For something complex you need to be very specific and give it explicit instructions on how to reason through the problem, explain it's thinking, etc. I find the more context I provide in the prompt, the better it performs. In particular leveraging the system prompt makes a big difference.
* Formatting a huge confusing blob of python code, markdown, and json into something readable.
* Writing "boring" python functions needed to interface with AWS DynamoDB & S3.
* Going from 0 -> 1 on a side project creating printable QR codes that redirect to custom links with logging. (Literally gave me picture perfect step by step instructions here, as if it was reading off the AWS UI. The sole issue I had it helped me troubleshoot).
* JS tutoring.
* Integrating an unfamiliar authentication provider with a web app. It gave me boilerplate code that needed like 1-2 tweaks to work perfectly.
* Long winded architectural discussion giving me ideas on where to take internal libraries.
Other than that, I've actually found that the github copilot CLI is a fantastic tool I've been turning to more and more. There are so many CLI tools that I kinda sorta remember the flags for, and now I no longer have to munge about looking things up. Just earlier I needed some test api key and I just said "!! generate a random api key", and it immediately came back with "openssl rand -base64 32". That works, and saved me time googling it.
Also, your prompt here is pretty weak. For something complex you need to be very specific and give it explicit instructions on how to reason through the problem, explain it's thinking, etc. I find the more context I provide in the prompt, the better it performs. In particular leveraging the system prompt makes a big difference.
When I have use cases similar to this one (similar in complexity), I'll pair program with it. If the code fails, I'll tell it what error I got and ask it to refactor. If the explanation it gives with the code shows it didn't understand the question, I'll guide it along the correct track.
It's not perfect at "zero-shot" answers but from my experience is very good when you work with it conversationally.
It's not perfect at "zero-shot" answers but from my experience is very good when you work with it conversationally.
Thanks for including this example. It helps me understand what you mean.
ChatGPT is not really equipped to do this level of code design because there are too many steps for it to handle at once. It can handle your instructions if it could first write a detailed design spec, then write code and unit tests, then run them, read the compiler output, and iteratively make changes.
IOW, this would require a purpose-built solution which uses ChatGPT's underlying engine to take your list of requirements and turn them into built and tested code.
ChatGPT is not really equipped to do this level of code design because there are too many steps for it to handle at once. It can handle your instructions if it could first write a detailed design spec, then write code and unit tests, then run them, read the compiler output, and iteratively make changes.
IOW, this would require a purpose-built solution which uses ChatGPT's underlying engine to take your list of requirements and turn them into built and tested code.
> ChatGPT is not really equipped to do this level of code design because there are too many steps for it to handle at once
There's no code design going on here. My solution was literally just going through like 100 StackOverflow answers & Microsoft's god-awful documentation to get the 50 lines of code that does what I need it to do.
In fact, this is precisely what I'd hope ChatGPT would be good for. Most of my final code is simply copy-pasted from SO/example repos/official docs. He's the correct function (comments added by me so I'll know wtf this is meant to do when I look at it again in 3 months).
There's no code design going on here. My solution was literally just going through like 100 StackOverflow answers & Microsoft's god-awful documentation to get the 50 lines of code that does what I need it to do.
In fact, this is precisely what I'd hope ChatGPT would be good for. Most of my final code is simply copy-pasted from SO/example repos/official docs. He's the correct function (comments added by me so I'll know wtf this is meant to do when I look at it again in 3 months).
fn get_context_path() -> Result<String, Error> {
unsafe {
// Init COM libraries in this thread
CoInitializeEx(Some(ptr::null()), COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)?;
// CabinetWClass is the Explorer window class
let class = s!("CabinetWClass");
let topmost_explorer = FindWindowA(class, None);
let foreground_window = GetForegroundWindow();
// Breadcrumbs IFF topmost window is an explorer window
if topmost_explorer == foreground_window {
let windows: IShellWindows = CoCreateInstance(&ShellWindows, None, CLSCTX_LOCAL_SERVER)?;
let unk_enum = windows._NewEnum()?;
let enum_variant: IEnumVARIANT = unk_enum.cast::<IEnumVARIANT>()?;
// Iterate through all IShellWindows
loop {
let mut fetched = 0;
let mut var: [VARIANT; 1] = [VARIANT::default(); 1];
let hr = enum_variant.Next(&mut var, &mut fetched);
// No more windows?
if hr == S_FALSE || fetched == 0 {
break;
}
// Not an IDispatch interface?
if var[0].Anonymous.Anonymous.vt != VT_DISPATCH {
continue;
}
// We should be able to turn an IShellWindow into an IShellBrowser
let shell_browser: IShellBrowser = IUnknown_QueryService(
var[0]
.Anonymous
.Anonymous
.Anonymous
.pdispVal
.as_ref()
.unwrap(),
&SID_STopLevelBrowser,
)?;
let shell_window = shell_browser.GetWindow()?;
// NOTE: The window we're matching with is actually the shell's parent
// Given that windows can be tabbed, we want to make sure the parent is the top
if GetParent(shell_window) == topmost_explorer {
let shell_view = shell_browser.QueryActiveShellView()?;
// Do some COM finagling, including a QueryInterface cast,
// until we get the folder path we're looking at
let folder_view: IFolderView = shell_view.cast::<IFolderView>()?;
let folder: IPersistFolder2 = folder_view.GetFolder::<IPersistFolder2>()?;
let curr_folder = folder.GetCurFolder()?;
// NOTE: This fails on non SYSPATH paths (e.g. "Home" or "Recent")
let path = SHGetNameFromIDList(curr_folder, SIGDN_FILESYSPATH)?;
let result = path.to_string()?;
// To figure out what path we're on (e.g. what tab is active), we try to match the
// parent title with the folder
// FIXME: Unless using full paths as titles, we can have ambiguities here
let mut title: [u16; 512] = [0; 512];
let len = GetWindowTextW(topmost_explorer, &mut title);
let title = String::from_utf16_lossy(&title[..len as usize]);
// We found the proper tab (child)
if result.contains(&title) {
// Cleanup COM & return path result
CoUninitialize();
return Ok(result);
// Must be another one (or something went wrong)
} else {
continue;
}
}
}
}
// Cleanup COM & fallback to blank string
CoUninitialize();
return Ok(String::from(""));
}
}I've added the statement "let's think through the problem step by step" after your instructions. Here's GPT-4's answer. I don't know Rust so let me know if this is a better answer:
---
Sure, let's break down the problem:
1. Identify the topmost window: We can use the `winapi` crate in Rust to interact with the Windows API. The function `GetForegroundWindow` can be used to get a handle to the topmost window.
2. Check if the window is a Windows Explorer window: We can use the `GetClassNameW` function to get the class name of the window. If the window is a Windows Explorer window, the class name should be `CabinetWClass`.
3. Get the path of the active folder in the Windows Explorer window: This is a bit more complex. We can use the `SHGetPathFromIDListW` function from the Shell API to get the path from an item ID list. However, getting the item ID list for the active folder in a Windows Explorer window is not straightforward. We might need to use COM interfaces like `IShellWindows` to get the `IWebBrowserApp` for the window, and then use `IWebBrowserApp::LocationURL` to get the URL of the active folder.
4. Return the path as a string or a blank string: This is straightforward. We just need to convert the path to a string and return it, or return a blank string if the window is not a Windows Explorer window.
Here is a skeleton of the function in Rust:
---
---
Sure, let's break down the problem:
1. Identify the topmost window: We can use the `winapi` crate in Rust to interact with the Windows API. The function `GetForegroundWindow` can be used to get a handle to the topmost window.
2. Check if the window is a Windows Explorer window: We can use the `GetClassNameW` function to get the class name of the window. If the window is a Windows Explorer window, the class name should be `CabinetWClass`.
3. Get the path of the active folder in the Windows Explorer window: This is a bit more complex. We can use the `SHGetPathFromIDListW` function from the Shell API to get the path from an item ID list. However, getting the item ID list for the active folder in a Windows Explorer window is not straightforward. We might need to use COM interfaces like `IShellWindows` to get the `IWebBrowserApp` for the window, and then use `IWebBrowserApp::LocationURL` to get the URL of the active folder.
4. Return the path as a string or a blank string: This is straightforward. We just need to convert the path to a string and return it, or return a blank string if the window is not a Windows Explorer window.
Here is a skeleton of the function in Rust:
```rust
extern crate winapi;
use std::ptr;
use std::ffi::OsString;
use std::os::windows::ffi::OsStringExt;
use winapi::um::winuser::{GetForegroundWindow,
GetClassNameW};
use winapi::um::shellapi::SHGetPathFromIDListW;
use winapi::shared::minwindef::MAX_PATH;
fn get_active_folder_path() -> String {
// Get the topmost window
let hwnd = unsafe { GetForegroundWindow() };
// Get the class name of the window
let mut class_name = vec![0u16; MAX_PATH + 1];
unsafe {
GetClassNameW(hwnd, class_name.as_mut_ptr(), class_name.len() as i32);
}
// Convert the class name to a string
let class_name = OsString::from_wide(&class_name)
.to_string_lossy()
.into_owned();
// Check if the window is a Windows Explorer window
if class_name.starts_with("CabinetWClass") {
// TODO: Get the item ID list for the active folder in the Windows Explorer window
// TODO: Use SHGetPathFromIDListW to get the path from the item ID list
// TODO: Convert the path to a string and return it
}
// If the window is not a Windows Explorer window, return a blank string
"".to_string()
}
```
Please note that this is a skeleton of the function and it's not complete. The part to get the item ID list for the active folder in a Windows Explorer window and get the path from the item ID list is complex and requires using COM interfaces, which is not straightforward in Rust. You might need to use a crate like `winrt` to interact with COM interfaces in Rust.---
Skill issue—use it for smaller functions or learn how to write better prompts, lots of resources.
I don't write Rust but does this look (more) correct?
// Helper function to convert a wide string to a Rust string fn wide_to_string(wide: &[u16]) -> String { OsString::from_wide(&wide) .to_string_lossy() .into_owned() }
// Helper function to convert BSTR to Rust String fn bstr_to_string(bstr: BSTR) -> String { unsafe { let length = winapi::um::oleauto::SysStringLen(bstr) as usize; let slice = std::slice::from_raw_parts(bstr, length); wide_to_string(slice) } }
fn main() { unsafe { // Initialize COM let hr = CoInitialize(null_mut());
extern crate winapi;
use std::ptr::null_mut;
use winapi::shared::guiddef::{CLSID, IID};
use winapi::um::combaseapi::{CoInitialize, CoCreateInstance};
use winapi::um::shobjidl_core::CLSID_ShellWindows;
use winapi::um::winuser::GetForegroundWindow;
use winapi::Interface;
use winapi::shared::winerror::{HRESULT, SUCCEEDED};
use winapi::um::exdisp::IWebBrowser2;
use winapi::um::unknwnbase::IUnknown;
use winapi::um::oleidl::IDispatch;
use winapi::shared::wtypes::BSTR;
use winapi::um::winnt::LPCWSTR;
use winapi::shared::ntdef::VOID;
use std::ffi::OsString;
use std::os::windows::ffi::OsStringExt; // Helper function to convert a wide string to a Rust string
wide_to_string(wide: &[u16]) -> String {
OsString::from_wide(&wide)
.to_string_lossy()
.into_owned()
} // Helper function to convert BSTR to Rust String
fn bstr_to_string(bstr: BSTR) -> String {
unsafe {
let length = winapi::um::oleauto::SysStringLen(bstr) as usize;
let slice = std::slice::from_raw_parts(bstr, length);
wide_to_string(slice)
}
} fn main() {
unsafe {
// Initialize COM
let hr = CoInitialize(null_mut());
if SUCCEEDED(hr) {
let mut shell_windows_ptr: *mut IUnknown = null_mut();
let shell_windows_iid: IID = IShellWindows::uuidof();
let shell_windows_clsid: CLSID = CLSID_ShellWindows;
// Create IShellWindows instance
let hr = CoCreateInstance(
&shell_windows_clsid,
null_mut(),
winapi::um::combaseapi::CLSCTX_ALL,
&shell_windows_iid,
&mut shell_windows_ptr as *mut _ as _,
);
if SUCCEEDED(hr) {
let shell_windows_dispatch: &IDispatch = &*(shell_windows_ptr as *mut IDispatch);
let hwnd = GetForegroundWindow() as LPCWSTR;
// Get Item of IShellWindows
let mut result = null_mut();
let mut params = winapi::um::oaidl::DISPPARAMS {
cArgs: 1,
cNamedArgs: 0,
rgvarg: &mut winapi::um::oaidl::VARIANTARG {
n1: winapi::um::oaidl::VARIANTARG_0 {
n2: winapi::um::oaidl::VARIANTARG_0_0 {
vt: winapi::um::oaidl::VT_I4 as u16,
wReserved1: 0,
wReserved2: 0,
wReserved3: 0,
n3: winapi::um::oaidl::VARIANTARG_0_0_0 {
lVal: hwnd as _,
}
}
}
},
rgdispidNamedArgs: null_mut(),
};
shell_windows_dispatch.Invoke(
winapi::um::exdisp::DISPID_ISHELLWINDOWS_ITEM,
&winapi::shared::guiddef::IID_NULL,
winapi::um::winnls::LOCALE_USER_DEFAULT,
winapi::um::oaidl::DISPATCH_METHOD,
&mut params,
&mut result,
null_mut(),
null_mut(),
);
// Convert result to IWebBrowser2
let web_browser2: &IWebBrowser2 = &*(result.pdispVal as *mut IWebBrowser2);
// Get LocationURL property of IWebBrowser2
let mut location_url: BSTR = null_mut();
web_browser2.get_LocationURL(&mut location_url);
let path = bstr_to_string(location_url);
println!("Path: {}", path);
} else {
println!("Failed to create IShellWindows instance.");
}
} else {
println!("Failed to initialize COM.");
}
}
extern crate winapi;
use std::ptr::null_mut;
use winapi::shared::guiddef::{CLSID, IID};
use winapi::um::combaseapi::{CoInitialize, CoCreateInstance};
use winapi::um::shobjidl_core::CLSID_ShellWindows;
use winapi::um::winuser::GetForegroundWindow;
use winapi::Interface;
use winapi::shared::winerror::{HRESULT, SUCCEEDED};
use winapi::um::exdisp::IWebBrowser2;
use winapi::um::unknwnbase::IUnknown;
use winapi::um::oleidl::IDispatch;
use winapi::shared::wtypes::BSTR;
use winapi::um::winnt::LPCWSTR;
use winapi::shared::ntdef::VOID;
use std::ffi::OsString;
use std::os::windows::ffi::OsStringExt;// Helper function to convert a wide string to a Rust string fn wide_to_string(wide: &[u16]) -> String { OsString::from_wide(&wide) .to_string_lossy() .into_owned() }
// Helper function to convert BSTR to Rust String fn bstr_to_string(bstr: BSTR) -> String { unsafe { let length = winapi::um::oleauto::SysStringLen(bstr) as usize; let slice = std::slice::from_raw_parts(bstr, length); wide_to_string(slice) } }
fn main() { unsafe { // Initialize COM let hr = CoInitialize(null_mut());
if SUCCEEDED(hr) {
let mut shell_windows_ptr: *mut IUnknown = null_mut();
let shell_windows_iid: IID = IShellWindows::uuidof();
let shell_windows_clsid: CLSID = CLSID_ShellWindows;
// Create IShellWindows instance
let hr = CoCreateInstance(
&shell_windows_clsid,
null_mut(),
winapi::um::combaseapi::CLSCTX_ALL,
&shell_windows_iid,
&mut shell_windows_ptr as *mut _ as _,
);
if SUCCEEDED(hr) {
let shell_windows_dispatch: &IDispatch = &*(shell_windows_ptr as *mut IDispatch);
let hwnd = GetForegroundWindow() as LPCWSTR;
// Get Item of IShellWindows
let mut result = null_mut();
let mut params = winapi::um::oaidl::DISPPARAMS {
cArgs: 1,
cNamedArgs: 0,
rgvarg: &mut winapi::um::oaidl::VARIANTARG {
n1: winapi::um::oaidl::VARIANTARG_0 {
n2: winapi::um::oaidl::VARIANTARG_0_0 {
vt: winapi::um::oaidl::VT_I4 as u16,
wReserved1: 0,
wReserved2: 0,
wReserved3: 0,
n3: winapi::um::oaidl::VARIANTARG_0_0_0 {
lVal: hwnd as _,
}
}
}
},
rgdispidNamedArgs: null_mut(),
};
shell_windows_dispatch.Invoke(
winapi::um::exdisp::DISPID_ISHELLWINDOWS_ITEM,
&winapi::shared::guiddef::IID_NULL,
winapi::um::winnls::LOCALE_USER_DEFAULT,
winapi::um::oaidl::DISPATCH_METHOD,
&mut params,
&mut result,
null_mut(),
null_mut(),
);
// Convert result to IWebBrowser2
let web_browser2: &IWebBrowser2 = &*(result.pdispVal as *mut IWebBrowser2);
// Get LocationURL property of IWebBrowser2
let mut location_url: BSTR = null_mut();
web_browser2.get_LocationURL(&mut location_url);
let path = bstr_to_string(location_url);
println!("Path: {}", path);
} else {
println!("Failed to create IShellWindows instance.");
}
} else {
println!("Failed to initialize COM.");
}
}
}
}> I haven't seen or heard of anyone that seriously uses ChatGPT to generate code and uses it in prod
I have. And I'm sure others have too. I dare say there are many who probably _shouldn't_ be using it because of privacy/IP concerns and so you won't hear about them.
> cute novelty [...]
I thought the same not so long ago. But gpt4 for me was a game changer. It's helped me debug and fix some legitimately complex code, and has been awesome at wholesale refactoring modules to fulfil a new purpose. E.g. today I wanted help reconciling between runtime and persistent LRU cache stuff. And it understood what I wanted and assisted. After a few nudges it gave me a refactored module with comments and a few tests. It's like having a very capable junior dev in one's pocket :P
Ps. Trust me: it's not long before we have ai coding bots that grab open tickets and hammer together PRs with full testing suites. I imagine it's already happening.
I have. And I'm sure others have too. I dare say there are many who probably _shouldn't_ be using it because of privacy/IP concerns and so you won't hear about them.
> cute novelty [...]
I thought the same not so long ago. But gpt4 for me was a game changer. It's helped me debug and fix some legitimately complex code, and has been awesome at wholesale refactoring modules to fulfil a new purpose. E.g. today I wanted help reconciling between runtime and persistent LRU cache stuff. And it understood what I wanted and assisted. After a few nudges it gave me a refactored module with comments and a few tests. It's like having a very capable junior dev in one's pocket :P
Ps. Trust me: it's not long before we have ai coding bots that grab open tickets and hammer together PRs with full testing suites. I imagine it's already happening.
> I imagine it's already happening.
Not quite, that I know of, but some of us are working on it :)
I have a feeling that while the glorious future you describe can probably be realized using LLMs as a foundational technology, the software engineering effort needed to get there is on par with other AI moonshot projects e.g. autonomous vehicles.
If you or others reading this are interested in this topic, see this post for some interesting discussion and links to projects in development (and in the comments there's a link to a Discord server that was set up for further discussion): https://news.ycombinator.com/item?id=36422730
Not quite, that I know of, but some of us are working on it :)
I have a feeling that while the glorious future you describe can probably be realized using LLMs as a foundational technology, the software engineering effort needed to get there is on par with other AI moonshot projects e.g. autonomous vehicles.
If you or others reading this are interested in this topic, see this post for some interesting discussion and links to projects in development (and in the comments there's a link to a Discord server that was set up for further discussion): https://news.ycombinator.com/item?id=36422730
Can you not please? I enjoy coding and I don’t want to have to change careers again. Can you just automate something else like Congress or the people running the Taco Bell drive through?
[deleted]
> I haven't seen or heard of anyone that seriously uses ChatGPT to generate code and uses it in prod
I would agree with this in general. The main goal here is to optimize the "editor experience". When I personally code, I'll have ChatGPT pulled up on the side in case I need to reference it for speed. Some examples of how I might use it are:
- add some tests for me to review - take an existing piece of code and modify it in some way - help me think of ways in which I can write some code if I'm lazy that day.
This would generate code that after I iterate on it would need to be reviewed which speaks to your point, "you'll need to have an engineer at least look over the code anyway" which I agree with.
The main goal is to have it there as a resource to pair program with rather than trusting it without review/input.
I would agree with this in general. The main goal here is to optimize the "editor experience". When I personally code, I'll have ChatGPT pulled up on the side in case I need to reference it for speed. Some examples of how I might use it are:
- add some tests for me to review - take an existing piece of code and modify it in some way - help me think of ways in which I can write some code if I'm lazy that day.
This would generate code that after I iterate on it would need to be reviewed which speaks to your point, "you'll need to have an engineer at least look over the code anyway" which I agree with.
The main goal is to have it there as a resource to pair program with rather than trusting it without review/input.
I think this is just a marketing ploy jumping on the Generative AI bandwagon.
In real world, this will not work as the actual output might really confuse the end user.
AI code generation is not yet ready for a full-blown apps, but it works well on smaller well-defined functions. For example, Nekton.ai asks the user to split the workflow into smaller steps, and automates it one by one.
[deleted]
You're telling me you've never once pressed "TAB" to auto-fill the line or even several lines with Copilot? Because about half of the letters in my source code is now Copilot generated.
The value added is that you don't send your source code to OpenAI and/or their parent org Microsoft.
The value added is that you don't send your source code to OpenAI and/or their parent org Microsoft.
I do it all of the time (with GitHub copilot). It's getting much better. If I retro my interactions with it, I think I'll usually give it a "once over" to see if what it's doing makes sense. Sometimes I'll add a comment to my PR saying what AI did/didn't write to give the reviewer a heads up.
I mostly use it for the generation of doc strings in python and js doc in typescript.
Recently I've been using git diff and asking 3.5 to write the PR description for me and so far it is doing quite well. The 16k tokens means I can feed even more into it.
Recently I've been using git diff and asking 3.5 to write the PR description for me and so far it is doing quite well. The 16k tokens means I can feed even more into it.
This would be a great pre-commit hook! Generate commit message and fill .commit_msg for review/further editing.
Microsoft has owned GitHub since 2018.
I think the GP meant the value added by Superblocks?
This looks cool. I like that you're showing diffs and integrating the AI code and suggestions back into the original source code.
I've been focused on similar concepts with my open source AI coding tool. My tool is a command line GPT chat tool. You can ask it to write or edit code in any git repo. It displays live diffs as the AI edits stream in and automatically integrates them into your source files. I think this is similar to what your article is describing?
Folks might want to check out `aider` if they want to do the style of AI coding you're showing, but on their own git repos.
https://github.com/paul-gauthier/aider
I've been focused on similar concepts with my open source AI coding tool. My tool is a command line GPT chat tool. You can ask it to write or edit code in any git repo. It displays live diffs as the AI edits stream in and automatically integrates them into your source files. I think this is similar to what your article is describing?
Folks might want to check out `aider` if they want to do the style of AI coding you're showing, but on their own git repos.
https://github.com/paul-gauthier/aider
Thanks! I took a look at your repo and love the concise gif!
At first was excited when I clicked the link. I think for some people, this is a fantastic solution.
However, for me, what I was hoping it was/ one thing I'm still looking for: Feed in my whole repo to the GPT-4 API, train on it, and ask questions about the code base/ particular functions. Has anyone seen that?
However, for me, what I was hoping it was/ one thing I'm still looking for: Feed in my whole repo to the GPT-4 API, train on it, and ask questions about the code base/ particular functions. Has anyone seen that?
My tool aider lets you ask GPT questions about a git repo, as well as letting you ask gpt to edit the code. Here's an example of exploring and then modifying an open source js repo:
https://aider.chat/examples/2048-game.html
Here's an article about how it does that:
https://aider.chat/docs/ctags.html
I think bloop is also good for searching and Q&A against code. I'm not sure if it will let you edit/modify the code though.
https://bloop.ai
https://aider.chat/examples/2048-game.html
Here's an article about how it does that:
https://aider.chat/docs/ctags.html
I think bloop is also good for searching and Q&A against code. I'm not sure if it will let you edit/modify the code though.
https://bloop.ai
Your tool looks very impressive. Have you ever tried how well it works with Android app repos?
Aider seems pretty comfortable working with android apps. Here's a conversation I just had with it:
> what's a simple, popular open source android app?
One simple and popular open source Android app is "Minimal ToDo". It's a simple task management app with a clean, minimalistic user interface. The source code is available on GitHub and it's a great project for beginners who want to understand the structure and functioning of an Android app.
> clone command to clone minimal todo?
To clone the Minimal ToDo app from GitHub, you can use the following command:
> tell me about the overall structure of this codebase
This codebase appears to be for an Android application, specifically a to-do list app. The structure is typical of an Android project, with Java source files, XML layout files, and resource files.
1. Java Source Files: These are located in the `app/src/main/java/com/example/avjindersinghsekhon/minimaltodo` directory. The package structure suggests that the app is divided into several modules such as `About`, `AddToDo`, `Analytics`, `AppDefault`, `Main`, `Reminder`, `Settings`, and `Utility`. Each module contains classes related to its functionality.
2. XML Layout Files: These are located in the `app/src/main/res/layout` directory. They define the user interface for different activities and fragments in the app.
3. Resource Files: These include drawable resources (images, icons), values (strings, dimensions, colors), and menu definitions. They are located in the `app/src/main/res` directory.
4. Gradle Files: The `build.gradle` files specify the build configuration for the app. There are typically two such files in an Android project: one for the project and one for the app module.
5. Test Files: These are located in the `app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo` directory. They contain tests for the application's functionality.
6. Manifest File: The `AndroidManifest.xml` file in the `app/src/main` directory declares the app's components to the Android system and specifies permissions and other app requirements.
7. Properties and Configuration Files: Files like `gradle.properties` and `.travis.yml` are used for configuration of the build system and continuous integration services.
8. Other Files: The `google-services.json` file is typically used for configuring services from Google Firebase. The `.idea` directory contains configuration files for the IntelliJ IDEA IDE.
> what's a simple, popular open source android app?
One simple and popular open source Android app is "Minimal ToDo". It's a simple task management app with a clean, minimalistic user interface. The source code is available on GitHub and it's a great project for beginners who want to understand the structure and functioning of an Android app.
> clone command to clone minimal todo?
To clone the Minimal ToDo app from GitHub, you can use the following command:
```bash
git clone https://github.com/avjinder/Minimal-Todo.git
```
This will create a local copy of the Minimal ToDo repository on your machine.> tell me about the overall structure of this codebase
This codebase appears to be for an Android application, specifically a to-do list app. The structure is typical of an Android project, with Java source files, XML layout files, and resource files.
1. Java Source Files: These are located in the `app/src/main/java/com/example/avjindersinghsekhon/minimaltodo` directory. The package structure suggests that the app is divided into several modules such as `About`, `AddToDo`, `Analytics`, `AppDefault`, `Main`, `Reminder`, `Settings`, and `Utility`. Each module contains classes related to its functionality.
2. XML Layout Files: These are located in the `app/src/main/res/layout` directory. They define the user interface for different activities and fragments in the app.
3. Resource Files: These include drawable resources (images, icons), values (strings, dimensions, colors), and menu definitions. They are located in the `app/src/main/res` directory.
4. Gradle Files: The `build.gradle` files specify the build configuration for the app. There are typically two such files in an Android project: one for the project and one for the app module.
5. Test Files: These are located in the `app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo` directory. They contain tests for the application's functionality.
6. Manifest File: The `AndroidManifest.xml` file in the `app/src/main` directory declares the app's components to the Android system and specifies permissions and other app requirements.
7. Properties and Configuration Files: Files like `gradle.properties` and `.travis.yml` are used for configuration of the build system and continuous integration services.
8. Other Files: The `google-services.json` file is typically used for configuring services from Google Firebase. The `.idea` directory contains configuration files for the IntelliJ IDEA IDE.
haven't used it yet but Tzap looks like it'd fit the bill
- https://github.com/tzapio/tzap
- https://news.ycombinator.com/item?id=36377918
- https://github.com/tzapio/tzap
- https://news.ycombinator.com/item?id=36377918
This will be awesome when it's possible! I often wish GitHub Copilot knew more about my repo than it does.
Ever heard of Cody by Sourcegraph?
about.sourcegraph.com
about.sourcegraph.com
Does it do well? How does it get around the context window limits?
It uses Claude from anthropic which has a 100k context window. It typically stuffs the 15 most relevant files into the prompt to spit out the output. It’s shockingly fast.
I really like it for figuring out how something in my code base is done, like figuring out where exactly rate limits happen and what service we use to track them.
I really like it for figuring out how something in my code base is done, like figuring out where exactly rate limits happen and what service we use to track them.
Will check it out - thank you!
Superblocks is cool, but... when I tried building a simple web hook receiver, it totally failed because the sender of the web hook had their own particular notion of how authentication should work. And Superblocks was rigid in its concept of "web hook". There is no way to write arbitrary request handling code to get around this limitation.
As with all low-code / no-code solutions, you can't please all the people all the time. But I felt the design choice in this particular case was overly rigid and with little justification.
As with all low-code / no-code solutions, you can't please all the people all the time. But I felt the design choice in this particular case was overly rigid and with little justification.
Thanks for your comment! We're always open to product improvement around our Workflows product. I agree there's more features we need to add to service a robust set of web hook use cases.
With that being said, there may be ways to accomplish what you're looking for with the current state of our Workflows feature so feel free to send me a DM on Twitter or Linkedin.
With that being said, there may be ways to accomplish what you're looking for with the current state of our Workflows feature so feel free to send me a DM on Twitter or Linkedin.
Airplane too, does have a coding assistant similar to this [1].
[1] https://www.airplane.dev/autopilot
[1] https://www.airplane.dev/autopilot
This looks neat but the examples are terrible.
The fact that it's even willing to write a function which removes PII from a string is nonsense. No such function is possible.
And the comment for filterUsersTable is incredibly long, tedious, and unhelpful.
How does the SQL thing work? How does it know what my schema is? That's nowhere on screen.
The only believable example is the Salesforce one which anyone could do.
The fact that it's even willing to write a function which removes PII from a string is nonsense. No such function is possible.
And the comment for filterUsersTable is incredibly long, tedious, and unhelpful.
How does the SQL thing work? How does it know what my schema is? That's nowhere on screen.
The only believable example is the Salesforce one which anyone could do.
> And the comment for filterUsersTable is incredibly long, tedious, and unhelpful.
This is good feedback. I think having an ability to adjust verbosity is valuable. A comment version should maybe be more concise than the actual explanation.
> How does the SQL thing work? How does it know what my schema is? That's nowhere on screen.
When you configure integrations with Superblocks, we query your integrations metadata which we use to give the best answers here.
This is good feedback. I think having an ability to adjust verbosity is valuable. A comment version should maybe be more concise than the actual explanation.
> How does the SQL thing work? How does it know what my schema is? That's nowhere on screen.
When you configure integrations with Superblocks, we query your integrations metadata which we use to give the best answers here.
This is cool, but otherwise you can just use windmill as an open-source internal app builder and use Github Copilot in vscode to get the best AI assistant out there: https://www.windmill.dev/docs/cli_local_dev/vscode-extension
I thought Superblocks was blockchain company. Is this a pivot?
We have never been a blockchain company. However, I do believe there is one with a similar name.
Not just similar name but the same URL as well: https://twitter.com/getsuperblocks
I presume you bought the domain name from them in that case.
I presume you bought the domain name from them in that case.
Yea I believe we did.
Wow, a new low code app generator! And it even managed to shoehorn ChatGPT in! How exciting!
A lowcode app generator that "used" appsmith's open source project to build on, gamed hacker news to be on the top page once, has a new low code app generator with shoehorned chatgpt.
ZIRP Hustle is real.
ZIRP Hustle is real.
The architecture has diverged significantly from the Appsmith project (Apache 2.0 licensed) since forking the frontend canvas and evaluation code more than 2 years ago. Most of Superblocks is built from the ground up to optimize for performance, scalability and extensibility.
In terms of ChatGPT, Superblocks's goal is to develop a simple visual interface for creators to integrate AI into their workflow to build applications quickly. The platform makes it easy to verify, deploy, and monitor your changes, which would be difficult to do with just a chat interface.
In terms of ChatGPT, Superblocks's goal is to develop a simple visual interface for creators to integrate AI into their workflow to build applications quickly. The platform makes it easy to verify, deploy, and monitor your changes, which would be difficult to do with just a chat interface.
If you're interested, there's a number of open source alternatives to Superblocks
Budibase. https://github.com/Budibase/budibase
Appsmith. https://github.com/appsmithorg
Tooljet https://github.com/ToolJet/ToolJet
And more (I'm sure others will comment)
Budibase. https://github.com/Budibase/budibase
Appsmith. https://github.com/appsmithorg
Tooljet https://github.com/ToolJet/ToolJet
And more (I'm sure others will comment)
[deleted]
I've been using Windmill and it works like a charm.
Today we launched Superblocks AI and are excited to hear feedback from the HN community!
Superblocks AI combines the power of the Superblocks drag-and-drop App Builder with robust AI code generation, code optimization, code explanation, mock data generation, and API call generation across SQL, Python, JavaScript, JSON and HTML.
We built Superblocks AI with the intention to streamline some of the repetitive and often confusing aspects of building internal tools, here’s a brief overview:
Generate Code: LLMs like ChatGPT have quickly become a critical part of developers' lives and we wanted to bring that experience natively into our product. The response is streamed for the best UX, similar to Chat-GPT, and can be modified before use.
Explain Code: Understanding someone else’s code for large internal engineering teams is often a challenge. Highlight code and Superblocks AI offers an explanation that you then have the ability to add as a comment.
Edit Code: You can make alterations to code by highlighting it and choosing prompts like optimize performance, enhance readability, or something custom. We've added an inline code diff view for easy verification of changes.
Generate API Calls: You often want to make an API call but need to spend 30 minutes looking up the documentation and crafting the correct call in Postman. We provided a way for you to give a prompt, and Superblocks AI will generate REST and GraphQL queries for APIs like Stripe, Salesforce, your favorite SaaS provider, and more.
Generate Mock Data: This enables faster UI development by generating mock data for components like tables, charts, grids etc., which can be especially handy during prototyping.
I'd love to hear feedback from the HN community on how you think this feature should evolve over the next few months!