copilot-extensions / preview-sdk.js

An SDK that streamlines extension development by automating request verification, response formatting, and API interactions
MIT License
2 stars 7 forks source link

Create an example setup that works with the basic prompts #83

Open rajbos opened 4 days ago

rajbos commented 4 days ago

It was quite a hassle to get things started with the SDK, I think it would make it a lot easier if an example folder is included that can be executed, basically with the example of 'Talk like a pirate'.

I'd be happy to help out with that, either in this repo or in a new one? We can also include an example of running this inside of a Codespace, which works rather nicely. A walk trough would really help there as well.

Let me know your thoughts and I can help out with setting things up.

gr2m commented 4 days ago

That would be most wonderful, I really like repositories with an examples/ folder, I think that the Next.js team really paved the way to show how great it can be:

https://github.com/vercel/next.js/tree/canary/examples

@rajbos thank you for making that suggestion. If you like, you can start by creating the first examples/* folder and if you get stuck in any way, please reach out for help

rajbos commented 4 days ago

I will!

gr2m commented 4 days ago

I recently shared a minimal hello world example privately within @github. I figured I'll share it here as well, maybe we can use it as a starting point for examples/hello-world/index.js

import { createServer } from "http";

import {
  createTextEvent,
  createDoneEvent,
} from "@copilot-extensions/preview-sdk";

const server = createServer((req, res) => {
  if (req.method === "GET") {
    return res.end("ok");
  }

  res.write(createTextEvent("Hello, world!"));
  res.end(createDoneEvent());
});

const PORT = process.env.PORT || 3000;
server.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});
gr2m commented 4 days ago

Also here is my own app that I've been using to try out all the SDK capabilities: https://github.com/gr2m/app

It's a bit messy but maybe it helps

rajbos commented 4 days ago

That link returns a 404 for me.

rajbos commented 4 days ago

Draft PR started, please comment if you have remarks on the direction it is going.

gr2m commented 4 days ago

That link returns a 404 for me.

sorry it was private, fixed it now