Sqlite2postgres - #1
Conversation
# Conflicts: # apps/web/src/app/layout.tsx # skills-lock.json
…tAuth` singletons, and refine fetch options for tRPC clients.
…abase search, and related API/UI updates.
|
@bernoussama I've opened a new pull request, #2, to work on those changes. Once the pull request is ready, I'll request review from you. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new Cloudflare platform skill to enhance the developer experience within the agent platform. It includes detailed documentation for the Cloudflare Agents SDK and sets up necessary symlinks for platform compatibility, aiming to consolidate and streamline Cloudflare development tasks. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
Adds a large set of Cloudflare “skill” reference documents (decision trees, configuration, API references, patterns, gotchas) under .agents/skills/cloudflare, plus symlinks under .agent/skills/ to expose the skills to the agent platform.
Changes:
- Introduces many new Cloudflare product reference docs (Workers/Pages, storage, observability, security, networking, etc.).
- Adds Agents SDK documentation + configuration guidance.
- Adds
.agent/skills/*symlinks pointing back to.agents/skills/*.
Reviewed changes
Copilot reviewed 141 out of 432 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| .agents/skills/cloudflare/references/pages-functions/README.md | Adds Pages Functions overview + routing decision trees |
| .agents/skills/cloudflare/references/observability/patterns.md | Adds observability implementation patterns |
| .agents/skills/cloudflare/references/observability/gotchas.md | Adds observability troubleshooting + limits/pricing notes |
| .agents/skills/cloudflare/references/observability/configuration.md | Adds observability configuration examples |
| .agents/skills/cloudflare/references/observability/api.md | Adds observability API + SQL examples |
| .agents/skills/cloudflare/references/observability/README.md | Adds observability index/decision tree |
| .agents/skills/cloudflare/references/network-interconnect/patterns.md | Adds CNI patterns + HA guidance |
| .agents/skills/cloudflare/references/network-interconnect/configuration.md | Adds CNI configuration workflow + monitoring |
| .agents/skills/cloudflare/references/network-interconnect/README.md | Adds CNI overview + automation boundaries |
| .agents/skills/cloudflare/references/miniflare/gotchas.md | Adds Miniflare limitations + troubleshooting |
| .agents/skills/cloudflare/references/miniflare/configuration.md | Adds Miniflare configuration reference |
| .agents/skills/cloudflare/references/miniflare/README.md | Adds Miniflare usage decision tree + quick start |
| .agents/skills/cloudflare/references/kv/gotchas.md | Adds KV troubleshooting + limits/cost notes |
| .agents/skills/cloudflare/references/kv/configuration.md | Adds KV setup + bindings + REST examples |
| .agents/skills/cloudflare/references/kv/README.md | Adds KV overview + API summary |
| .agents/skills/cloudflare/references/images/patterns.md | Adds Images transform/upload patterns |
| .agents/skills/cloudflare/references/images/gotchas.md | Adds Images limits + common errors |
| .agents/skills/cloudflare/references/images/api.md | Adds Images binding + REST + URL APIs |
| .agents/skills/cloudflare/references/images/README.md | Adds Images index + navigation |
| .agents/skills/cloudflare/references/hyperdrive/gotchas.md | Adds Hyperdrive troubleshooting + limits |
| .agents/skills/cloudflare/references/hyperdrive/api.md | Adds Hyperdrive driver/API examples + caching notes |
| .agents/skills/cloudflare/references/hyperdrive/README.md | Adds Hyperdrive overview + quick start |
| .agents/skills/cloudflare/references/graphql-api/gotchas.md | Adds GraphQL analytics troubleshooting + limits |
| .agents/skills/cloudflare/references/graphql-api/configuration.md | Adds GraphQL auth + client setup examples |
| .agents/skills/cloudflare/references/email-workers/patterns.md | Adds Email Workers patterns (parse/filter/reply/etc.) |
| .agents/skills/cloudflare/references/email-workers/gotchas.md | Adds Email Workers pitfalls + security notes |
| .agents/skills/cloudflare/references/email-workers/configuration.md | Adds Email Workers wrangler + deps setup |
| .agents/skills/cloudflare/references/email-routing/README.md | Adds Email Routing overview + quick start |
| .agents/skills/cloudflare/references/do-storage/configuration.md | Adds DO storage backend + migrations guidance |
| .agents/skills/cloudflare/references/do-storage/api.md | Adds DO storage SQL/KV API reference |
| .agents/skills/cloudflare/references/do-storage/README.md | Adds DO storage overview + reading order |
| .agents/skills/cloudflare/references/ddos/gotchas.md | Adds DDoS troubleshooting + limits |
| .agents/skills/cloudflare/references/ddos/configuration.md | Adds DDoS configuration + rule structure |
| .agents/skills/cloudflare/references/ddos/README.md | Adds DDoS overview + plan availability |
| .agents/skills/cloudflare/references/d1/gotchas.md | Adds D1 troubleshooting + tier limits |
| .agents/skills/cloudflare/references/d1/README.md | Adds D1 overview + usage patterns |
| .agents/skills/cloudflare/references/cron-triggers/README.md | Adds Cron Triggers overview + quick start |
| .agents/skills/cloudflare/references/containers/README.md | Adds Containers overview + routing patterns |
| .agents/skills/cloudflare/references/cache-reserve/configuration.md | Adds Cache Reserve enablement + IaC examples |
| .agents/skills/cloudflare/references/c3/patterns.md | Adds create-cloudflare workflows + CI patterns |
| .agents/skills/cloudflare/references/c3/gotchas.md | Adds create-cloudflare troubleshooting |
| .agents/skills/cloudflare/references/c3/configuration.md | Adds create-cloudflare generated config notes |
| .agents/skills/cloudflare/references/c3/api.md | Adds create-cloudflare flag reference |
| .agents/skills/cloudflare/references/c3/README.md | Adds create-cloudflare overview + decision tree |
| .agents/skills/cloudflare/references/browser-rendering/patterns.md | Adds Browser Rendering patterns |
| .agents/skills/cloudflare/references/browser-rendering/gotchas.md | Adds Browser Rendering troubleshooting + limits |
| .agents/skills/cloudflare/references/browser-rendering/configuration.md | Adds Browser Rendering setup examples |
| .agents/skills/cloudflare/references/browser-rendering/api.md | Adds Browser Rendering REST + binding API reference |
| .agents/skills/cloudflare/references/browser-rendering/README.md | Adds Browser Rendering overview + navigation |
| .agents/skills/cloudflare/references/bot-management/README.md | Adds Bot Management overview + patterns |
| .agents/skills/cloudflare/references/bindings/README.md | Adds Workers bindings catalog + selection guide |
| .agents/skills/cloudflare/references/argo-smart-routing/patterns.md | Adds Argo Smart Routing patterns + validation |
| .agents/skills/cloudflare/references/argo-smart-routing/gotchas.md | Adds Argo Smart Routing troubleshooting |
| .agents/skills/cloudflare/references/argo-smart-routing/README.md | Adds Argo Smart Routing overview |
| .agents/skills/cloudflare/references/api/configuration.md | Adds Cloudflare API + SDK configuration guidance |
| .agents/skills/cloudflare/references/api/README.md | Adds Cloudflare API integration overview |
| .agents/skills/cloudflare/references/api-shield/gotchas.md | Adds API Shield troubleshooting + limits |
| .agents/skills/cloudflare/references/api-shield/api.md | Adds API Shield endpoint reference + Workers fields |
| .agents/skills/cloudflare/references/api-shield/README.md | Adds API Shield overview |
| .agents/skills/cloudflare/references/analytics-engine/patterns.md | Adds Analytics Engine patterns + schema template |
| .agents/skills/cloudflare/references/analytics-engine/gotchas.md | Adds Analytics Engine gotchas + limits |
| .agents/skills/cloudflare/references/analytics-engine/configuration.md | Adds Analytics Engine binding configuration |
| .agents/skills/cloudflare/references/analytics-engine/api.md | Adds Analytics Engine API reference + SQL examples |
| .agents/skills/cloudflare/references/analytics-engine/README.md | Adds Analytics Engine overview + decision guidance |
| .agents/skills/cloudflare/references/ai-search/patterns.md | Adds AI Search patterns (filters/streaming/rerank) |
| .agents/skills/cloudflare/references/ai-search/gotchas.md | Adds AI Search gotchas + limits |
| .agents/skills/cloudflare/references/ai-search/configuration.md | Adds AI Search setup + token guidance |
| .agents/skills/cloudflare/references/ai-search/api.md | Adds AI Search API reference |
| .agents/skills/cloudflare/references/ai-search/README.md | Adds AI Search overview + comparisons |
| .agents/skills/cloudflare/references/ai-gateway/troubleshooting.md | Adds AI Gateway troubleshooting |
| .agents/skills/cloudflare/references/ai-gateway/sdk-integration.md | Adds AI Gateway SDK integration examples |
| .agents/skills/cloudflare/references/ai-gateway/features.md | Adds AI Gateway features/capabilities overview |
| .agents/skills/cloudflare/references/ai-gateway/dynamic-routing.md | Adds AI Gateway dynamic routing overview |
| .agents/skills/cloudflare/references/ai-gateway/configuration.md | Adds AI Gateway setup + auth modes |
| .agents/skills/cloudflare/references/agents-sdk/configuration.md | Adds Agents SDK wrangler/env/routing setup |
| .agents/skills/cloudflare/references/agents-sdk/README.md | Adds Agents SDK overview + quick start |
| .agent/skills/skill-creator | Adds symlink for agent platform compatibility |
| .agent/skills/cloudflare | Adds symlink for agent platform compatibility |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| @@ -0,0 +1 @@ | |||
| ../../.agents/skills/cloudflare No newline at end of file | |||
| -H "Authorization: Bearer $CF_API_TOKEN" \ | ||
| -H "Content-Type: application/json" \ | ||
| --data '{ | ||
| "query": "query($zoneTag: string!, $start: Time!, $end: Time!) { viewer { zones(filter: {zoneTag: $zoneTag}) { httpRequestsAdaptiveGroups(filter: {datetime_gt: $start, datetime_lt: $end}, limit: 10, orderBy: [datetimeFiveMinutes_DESC]) { count dimensions { datetimeFiveMinutes } } } } }", |
| query { | ||
| viewer { | ||
| accounts(filter: { accountTag: $accountId }) { | ||
| workersInvocationsAdaptive( | ||
| limit: 100 | ||
| filter: { | ||
| datetime_geq: "2025-01-01T00:00:00Z" | ||
| datetime_leq: "2025-01-31T23:59:59Z" | ||
| scriptName: "my-worker" | ||
| } | ||
| ) { |
| ## Quick Decision Tree | ||
|
|
||
| **Need to:** | ||
| - **Transform in Worker?** → [api.md](api.md#workers-binding-api-2026-primary-method) (Workers Binding API) |
|
|
||
| **For building image upload/transform feature:** | ||
| 1. [configuration.md](configuration.md) - Setup Workers binding | ||
| 2. [api.md](api.md#workers-binding-api-2026-primary-method) - Learn transform API |
| export default { | ||
| async email(message, env, ctx) { | ||
| const buffer = await new Response(message.raw).arrayBuffer(); | ||
| const email = await PostalMime.parse(buffer); |
| buffer.count++; buffer.total += value; | ||
|
|
||
| // Write once per second instead of per request | ||
| if (Date.now() % 1000 === 0) { | ||
| env.ANALYTICS.writeDataPoint({ doubles: [buffer.count, buffer.total] }); |
| | `get(keys, type?)` | Bulk read (≤100) | `Map<string, T \| null>` | | ||
| | `put(key, value, options?)` | Write | `Promise<void>` | | ||
| | `delete(key)` | Delete | `Promise<void>` | | ||
| | `list(options?)` | List keys | `{ keys, list_complete, cursor? }` | | ||
| | `getWithMetadata(key)` | Get + metadata | `{ value, metadata }` | | ||
|
|
|
|
||
| # Common commands that use API | ||
| wrangler deploy # Uploads worker via API | ||
| wrangler kv:key put # KV operations |
| { | ||
| "name": "email-worker", | ||
| "main": "src/index.ts", | ||
| "compatibility_date": "2025-01-27", |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive Cloudflare platform skill, adding a vast amount of documentation for various Cloudflare products. The structure is excellent, with detailed references for APIs, configuration, patterns, and common gotchas. My review focuses on improving consistency, fixing a few broken links, and clarifying some code examples to make them more complete and easier for developers to use. The PR title seems unrelated to the content, which might be worth correcting for clarity.
| ```ts | ||
| onStart() { | ||
| // Re-register MCP servers after hibernation | ||
| await this.mcp.registerServer("github", { url: env.MCP_URL, auth: {...} }); |
There was a problem hiding this comment.
The code example uses env.MCP_URL, but within a class method, environment variables are typically accessed via this.env. This should be corrected to this.env.MCP_URL to be accurate.
| await this.mcp.registerServer("github", { url: env.MCP_URL, auth: {...} }); | |
| await this.mcp.registerServer("github", { url: this.env.MCP_URL, auth: {...} }); |
| 1. **Never use `any` for env:** | ||
| ```typescript | ||
| // ❌ BAD | ||
| async fetch(request: Request, env: any) { } |
There was a problem hiding this comment.
| } | ||
| ``` | ||
|
|
||
| **⚠️ Don't override `alarm()` directly when using `schedule()` helper.** |
There was a problem hiding this comment.
The comment mentions the schedule() helper, but this helper is part of the Agent class from the agents-sdk, not the Container class, which extends DurableObject. Durable Objects use setAlarm() and alarm(). This comment is misleading and should be removed or corrected to refer to the appropriate alarm API for Durable Objects.
| - durable-objects - Agent infrastructure | ||
| - d1 - External database integration | ||
| - workers-ai - AI model integration | ||
| - vectorize - Vector search for RAG patterns No newline at end of file |
There was a problem hiding this comment.
For consistency with other reference files like SKILL.md, it would be clearer to add a trailing slash to these directory references (e.g., durable-objects/). This makes it explicit that they are directories.
| - durable-objects - Agent infrastructure | |
| - d1 - External database integration | |
| - workers-ai - AI model integration | |
| - vectorize - Vector search for RAG patterns | |
| - [durable-objects/](./durable-objects/) - Agent infrastructure | |
| - [d1/](./d1/) - External database integration | |
| - [workers-ai/](./workers-ai/) - AI model integration | |
| - [vectorize/](./vectorize/) - Vector search for RAG patterns |
| import { AIChatAgent } from "agents"; | ||
| import { openai } from "@ai-sdk/openai"; | ||
|
|
||
| export class ChatAgent extends AIChatAgent<Env> { | ||
| async onChatMessage(onFinish) { | ||
| return this.streamText({ | ||
| model: openai("gpt-4"), | ||
| messages: this.messages, // Auto-managed message history | ||
| tools: { | ||
| getWeather: { | ||
| description: "Get weather", | ||
| parameters: z.object({ city: z.string() }), | ||
| execute: async ({ city }) => `Sunny, 72°F in ${city}` | ||
| } | ||
| }, | ||
| onFinish, // Persist response to this.messages | ||
| }); | ||
| } | ||
| } |
There was a problem hiding this comment.
The code example uses z for schema validation, which implies the zod library. However, zod is not imported in the snippet. Adding the import would make the example self-contained and easier to understand.
| import { AIChatAgent } from "agents"; | |
| import { openai } from "@ai-sdk/openai"; | |
| export class ChatAgent extends AIChatAgent<Env> { | |
| async onChatMessage(onFinish) { | |
| return this.streamText({ | |
| model: openai("gpt-4"), | |
| messages: this.messages, // Auto-managed message history | |
| tools: { | |
| getWeather: { | |
| description: "Get weather", | |
| parameters: z.object({ city: z.string() }), | |
| execute: async ({ city }) => `Sunny, 72°F in ${city}` | |
| } | |
| }, | |
| onFinish, // Persist response to this.messages | |
| }); | |
| } | |
| } | |
| import { AIChatAgent } from "agents"; | |
| import { openai } from "@ai-sdk/openai"; | |
| import { z } from "zod"; | |
| export class ChatAgent extends AIChatAgent<Env> { | |
| async onChatMessage(onFinish) { | |
| return this.streamText({ | |
| model: openai("gpt-4"), | |
| messages: this.messages, // Auto-managed message history | |
| tools: { | |
| getWeather: { | |
| description: "Get weather", | |
| parameters: z.object({ city: z.string() }), | |
| execute: async ({ city }) => `Sunny, 72°F in ${city}` | |
| } | |
| }, | |
| onFinish, // Persist response to this.messages | |
| }); | |
| } | |
| } |
| const stream = await client.chat.completions.create({model: "gpt-4", messages, stream: true}); | ||
| for await (const chunk of stream) conn.send(JSON.stringify({chunk: chunk.choices[0].delta.content})); |
There was a problem hiding this comment.
The client variable is used here but is not defined within the code snippet. To make this example more complete and understandable, please consider adding an example of how client (presumably an OpenAI client instance) would be initialized.
| const stream = await client.chat.completions.create({model: "gpt-4", messages, stream: true}); | |
| for await (const chunk of stream) conn.send(JSON.stringify({chunk: chunk.choices[0].delta.content})); | |
| const stream = await client.chat.completions.create({model: "gpt-4", messages, stream: true}); | |
| for await (const chunk of stream) conn.send(JSON.stringify({chunk: chunk.choices[0]?.delta?.content})); |
| const client = new OpenAI({ | ||
| apiKey: process.env.OPENAI_API_KEY, | ||
| baseURL: `https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/compat`, | ||
| defaultHeaders: { | ||
| 'cf-aig-authorization': `Bearer ${cfToken}` // For authenticated gateways | ||
| } | ||
| }); |
There was a problem hiding this comment.
The variables accountId, gatewayId, and cfToken are used here without being defined. For the example to be clear and runnable, please define these variables, likely from environment variables (e.g., process.env.CF_ACCOUNT_ID).
| const client = new OpenAI({ | |
| apiKey: process.env.OPENAI_API_KEY, | |
| baseURL: `https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/compat`, | |
| defaultHeaders: { | |
| 'cf-aig-authorization': `Bearer ${cfToken}` // For authenticated gateways | |
| } | |
| }); | |
| const accountId = process.env.CF_ACCOUNT_ID; | |
| const gatewayId = process.env.CF_GATEWAY_ID; | |
| const cfToken = process.env.CF_API_TOKEN; | |
| const client = new OpenAI({ | |
| apiKey: process.env.OPENAI_API_KEY, | |
| baseURL: `https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/compat`, | |
| defaultHeaders: { | |
| 'cf-aig-authorization': `Bearer ${cfToken}` // For authenticated gateways | |
| } | |
| }); |
| # Headers required | ||
| X-Auth-Email: user@example.com | ||
| Authorization: Bearer YOUR_API_TOKEN |
There was a problem hiding this comment.
The authentication example includes both X-Auth-Email and Authorization: Bearer YOUR_API_TOKEN. This is confusing as typically only one method is used. The recommended approach is using an API Token. Please clarify that these are alternatives or remove the legacy X-Auth-Email header for clarity.
| # Headers required | |
| X-Auth-Email: user@example.com | |
| Authorization: Bearer YOUR_API_TOKEN | |
| # Headers required | |
| Authorization: Bearer YOUR_API_TOKEN |
| "$schema": "https://raw.githubusercontent.com/cloudflare/workers-sdk/main/packages/wrangler/config-schema.json", | ||
| "name": "my-app", | ||
| "main": "src/index.ts", | ||
| "compatibility_date": "2026-01-27" |
There was a problem hiding this comment.
| ## Quick Decision Tree | ||
|
|
||
| **Need to:** | ||
| - **Transform in Worker?** → [api.md](api.md#workers-binding-api-2026-primary-method) (Workers Binding API) |
There was a problem hiding this comment.
The link [api.md](api.md#workers-binding-api-2026-primary-method) is broken because the anchor #workers-binding-api-2026-primary-method does not exist in api.md. Please update it to point to the correct section, which appears to be ## Workers Binding API.
| - **Transform in Worker?** → [api.md](api.md#workers-binding-api-2026-primary-method) (Workers Binding API) | |
| - **Transform in Worker?** → [api.md](api.md#workers-binding-api) (Workers Binding API) |
This pull request introduces a comprehensive Cloudflare platform skill into the
.agents/skillsdirectory, focusing on a unified developer experience for Cloudflare products—including Workers, storage, AI, networking, security, and infrastructure-as-code. It adds a detailed skill manifest, extensive product decision trees, and in-depth documentation for the new Cloudflare Agents SDK, covering API usage, configuration, and integration patterns. The changes also set up symlinks to make these skills available to the agent platform.Cloudflare Platform Skill Integration
cloudflareskill to.agents/skillswith a detailedSKILL.mdmanifest. This includes product decision trees, retrieval best practices, and a comprehensive index of Cloudflare features and references for developer use..agent/skills/forcloudflareandskill-creatorto their respective directories in.agents/skills/for agent platform compatibility. [1] [2]Cloudflare Agents SDK Documentation
README.md): Explains agent types, use cases, and quick start examples for AI and base agents.api.md): Covers agent classes, lifecycle hooks, state management, SQL, scheduling, RPC, connections, AI integration, MCP, and client React hooks.configuration.md): Details wrangler setup, environment bindings, deployment, agent/email routing, AI Gateway, and MCP configuration.