Open Keyrxng opened 2 months ago
We need to minimize the use of KV and rely more on the GitHub API because we have tighter limits on the Cloudflare side.
@UbiquityOS Explain how to install and run the kernel, and install text-conversation-rewards plugin
Sure! Here's a step-by-step guide to installing and running the UbiquityOS kernel, as well as installing the text-conversation-rewards
plugin.
Begin by cloning the UbiquityOS kernel repository to your local machine:
git clone https://github.com/ubiquity-os/ubiquity-os-kernel.git
cd ubiquity-os-kernel
Ensure you have Bun installed, as it's required for managing dependencies and running the project.
bun install
Generate a GitHub App:
Obtain Credentials:
App ID: Retrieve this from your GitHub App settings.
Private Key: Generate a private key in PKCS8 format. Use the following command to convert your PEM file:
openssl pkcs8 -topk8 -inform pem -outform pem -nocrypt -in yourappprivatekey.pem -out appprivatekey.pem
Webhook Secret: Set this value in both your GitHub App settings and your kernel configuration.
Create a Cloudflare Account: If you don't have one, sign up at Cloudflare.
Install Wrangler CLI: Wrangler is Cloudflare's command-line tool for managing Workers.
npm install -g wrangler
Login to Cloudflare:
wrangler login
Create a KV Namespace:
wrangler kvnamespace create pluginchainstate
Note the generated Namespace ID and add it to your wrangler.toml
under the [env.dev]
section:
[env.dev]
kv_namespaces = [{ binding = "PLUGINCHAINSTATE", id = "your-generated-id" }]
Add the necessary environment variables and secrets required by the kernel:
App Private Key:
wrangler secret put appprivatekey --env dev < path/to/appprivatekey.pem
Other Secrets:
Add these using:
wrangler secret put appwebhooksecret --env dev
wrangler secret put appid --env dev
wrangler secret put webhookproxyurl --env dev
You'll be prompted to enter the values for each secret.
Deploy your kernel using the following command:
bun run deploy-dev
This command will build and deploy your kernel to the Cloudflare Workers environment.
text-conversation-rewards
PluginClone or Fork the Plugin:
text-conversation-rewards
plugin is available within the ubiquity-os-marketplace organization. If it's an official plugin, transfer it there; otherwise, fork it.Fetch Plugin Manifests:
manifest.json
from each plugin repository to understand its configuration and dependencies.Update Kernel Configuration:
Edit the ubiquity-osconfig.yml
file in your kernel repository to include the text-conversation-rewards
plugin:
plugins:
- text-conversation-rewards
Deploy Updated Configuration:
bun run deploy-dev
Start the Kernel in Development Mode:
bun dev
Trigger Plugin Functionality:
text-conversation-rewards
plugin responds to issue comments, post a relevant comment in your GitHub repository to trigger the plugin.Verify Plugin Response:
Caching Mechanism:
Testing with Jest:
bun test
Handling Permits:
Here’s a brief example to get you started with a "hello-world" plugin, which follows similar steps to the text-conversation-rewards
plugin:
Run the Kernel:
bun dev
Run the Hello-World Plugin:
bun plugin hello-world
Update Configuration:
Add the hello-world plugin to ubiquity-osconfig.yml
:
plugins:
- hello-world-plugin
Trigger the Plugin:
/hello
comment in any issue. The bot should respond with a "world" message.By following the steps outlined above, you will set up the UbiquityOS kernel, configure necessary secrets and environment variables, deploy the kernel to Cloudflare Workers, and install the text-conversation-rewards
plugin. Ensure you replace placeholder URLs and file paths with your actual configuration details. For any issues or further customization, refer to the linked resources and repository documentation.
It's kinda annoying that the kernel must fetch from both config locations on every request and more often than not only one is needed.
Cons:
Solution:
Do you think this would be a good thing to implement @whilefoo?