@kentcdodds: 你可以用Kody来设置这个。刚刚制作了一个PlanetScale包,这样你就不用从零开始了:https://kody.co…

X AI KOLs Timeline 工具

摘要

Kent C. Dodds 发布了一个用于 Kody 的 PlanetScale 包,该包能自动将数据库洞察异常转化为 GitHub issues、实施 PR 并通知相关人员进行审查。

你可以用Kody来设置这个。刚刚制作了一个PlanetScale包,这样你就不用从零开始了:https://kody.codes/@kody/planetscale… 然后你使用那个触发器通过GitHub包打开issue,这会使用Cursor/Devin等包触发一个云代理。 并且它通过Discord/Twilio等包通知你。
查看原文
查看缓存全文

缓存时间: 2026/08/24 21:57

你可以通过 Kody 完成设置。我刚创建了一个 PlanetScale 包,这样你就无需从头开始:https://kody.codes/@kody/planetscale…

接着你可以使用该触发器,通过 GitHub 包来创建 issue,这将触发使用 Cursor/Devin 等包的云端代理。

然后它会通过 Discord/Twilio 等包向你发送通知。


@kody/planetscale — Kody 社区包

来源:https://kody.codes/@kody/planetscale ← 社区包 (https://kody.codes/community)

将 PlanetScale Insights 异常转化为 GitHub issue、实现者 PR 和人工审核通知.

浏览文件 (https://kody.codes/@kody/planetscale/files)

  • 集成 (https://kody.codes/community?category=integrations)
  • planetscale
  • insights
  • 异常
  • 慢查询
  • postgres
  • vitess
  • github
  • cursor
  • webhook
  • 试运行

许可协议:MIT 发布日期:2026年8月24日 置顶提交:55a531f 评分:暂无评分 复刻:0 收藏:0 适配工作量:—

README

@kody/planetscale

意图

提供可复用的 PlanetScale Insights 辅助工具,使分叉后的 Kody 包能够将慢查询转化为实际期望的工作流:创建 GitHub issue、启动实现者(其会创建 PR)、让审核代理审查该 PR,然后通知人工审核。成功标志是:先生成可检查的试运行草稿,再进行确认运行,且每次无需从头开始。

此列表意在被分叉。分叉后,请保存你自己的 planetscaleApiToken,将 configure-loop 指向你的组织/数据库/仓库,并在希望 webhook 或轮询任务创建 issue 之前,保持 loopEnabled 为关闭状态。未硬编码任何个人组织 ID、数据库名称或令牌。

请将此包分享为 https://kody.codes/@kody/planetscale(切勿使用 /community/{listing_id} URL)。

工作流程

  1. PlanetScale Insights 报告一个异常(branch.anomaly webhook 或轮询)。
  2. draft-loop 编写 GitHub issue 内容、实现者提示词、审核者提示词和人工通知。
  3. run-loop(在 confirm: true 后)创建 issue,启动带有 autoCreatePR 的 Cursor Cloud 实现者,并请求 Cursor 请求审核者。
  4. 人工审核者收到邮件通知(如果该分叉配置了 @kody/notify,也会通过其通知)。
  5. 当 Insights 标记下一个慢查询时重复以上步骤。

run-loop 会将最后处理的异常 ID 记录在 packageStorage() 中,因此相同的信号不会在每次轮询时都创建新的 issue。

认证

PlanetScale 服务令牌以 Authorization: SERVICE_TOKEN_ID:SERVICE_TOKEN 的形式发送,不包含 scheme。请在 Kody 中保存该精确的 id:token 值。

  1. 在 PlanetScale 仪表板 创建一个至少具有 read_organization、read_database 和 Insights 读取权限的令牌。仅当您将从此包创建 branch.anomaly webhook 时,才添加 write_database 权限。
  2. 在 Kody 中保存它(请勿在聊天中粘贴该值):
https://kody.codes/account/secrets/new?name=planetscaleApiToken&description=PlanetScale%20service%20token%20as%20SERVICE_TOKEN_ID%3ASERVICE_TOKEN%20for%20api.planetscale.com&allowedHosts=api.planetscale.com&scope=user
  1. 批准主机 api.planetscale.com。
  2. (可选)Webhook HMAC 密钥(头部 X-PlanetScale-Signature,SHA-256 十六进制):
https://kody.codes/account/secrets/new?name=planetscaleWebhookSecret&description=PlanetScale%20webhook%20HMAC%20secret%20(X-PlanetScale-Signature)&allowedHosts=api.planetscale.com&scope=user

传递 account: "work" 可使用密钥 planetscaleApiToken-work,或传递 secretName: "planetscaleApiToken-work"。未硬编码任何账户别名。

主机

  • api.planetscale.com — 所有 REST 调用(必需)

GitHub、Cursor 和通知

实时工作流步骤调用官方助手:

  • kody:@kody/github/request — POST /repos/{owner}/{repo}/issues
  • kody:@kody/cursor/agents — createAgent,设置 autoCreatePR: true 并请求审核者
  • kody.email_send — 通知已登录的 Kody 用户
  • kody:@kody/notify — 在分叉 notify 并保存你的频道后进行额外通知

createAgent 没有试运行模式。此包仅在 confirm: true 时才会调用它。请在实时运行前连接 GitHub OAuth(https://kody.codes/connect/oauth?provider=github)并保存 Cursor API 密钥。@kody/notify 平台存储不是你的收件箱——如需 Slack/Discord/Telegram 通知,请先分叉 notify。

实现者提示词会指示 Cursor 代理使用 ManagePullRequest 自行创建 PR。Kody 不会代替其创建该 PR。

变更操作安全

configure-loop 默认为 { dryRun: true, wouldSave },仅在 confirm: true 时写入 packageStorage()。

run-loop 默认为预览模式 { dryRun: true, draft, wouldCall }。创建实时 GitHub issue、Cursor 代理和通知需要 confirm: true。

create-webhook 和 request 变更调用除非 confirm: true,否则会抛出错误。传递 dryRun: true 可进行预览。

已声明的 poll-anomalies 任务初始为禁用状态。insights webhook 在 configure-loop 保存 loopEnabled: true 之前仅保持草稿状态。

import runLoop from 'kody:@kody/planetscale/run-loop'

const preview = await runLoop({
	organization: 'acme',
	database: 'app',
	branch: 'main',
	githubOwner: 'acme',
	githubRepo: 'app',
	dryRun: true,
})

const live = await runLoop({
	organization: 'acme',
	database: 'app',
	branch: 'main',
	githubOwner: 'acme',
	githubRepo: 'app',
	confirm: true,
})

冒烟测试

import smokeTest from 'kody:@kody/planetscale/smoke-test'

export default async function main() {
	return await smokeTest()
}

即使没有 planetscaleApiToken,此测试仍会返回 { ok: true, live: false } 以及设置 URL 和一个固定的循环草稿。如有凭据,它会列出组织且不返回账单邮件。它永远不会创建 issue 或代理。

分叉后快速开始

import configureLoop from 'kody:@kody/planetscale/configure-loop'
import runLoop from 'kody:@kody/planetscale/run-loop'

export default async function main() {
	await configureLoop({
		organization: 'acme',
		database: 'app',
		branch: 'main',
		githubOwner: 'acme',
		githubRepo: 'app',
		repositoryUrl: 'https://github.com/acme/app',
		confirm: true,
	})
	return await runLoop({ dryRun: true })
}

要让 insights webhook 或已启用的轮询创建 issue:

import configureLoop from 'kody:@kody/planetscale/configure-loop'

export default async function main() {
	return await configureLoop({ loopEnabled: true, confirm: true })
}

然后为 branch.anomaly 创建一个 PlanetScale webhook,其 POST 目标为本包的 insights webhook URL。请先在 PlanetScale 端预览:

import createWebhook from 'kody:@kody/planetscale/create-webhook'

export default async function main() {
	return await createWebhook({
		organization: 'acme',
		database: 'app',
		url: 'https://YOUR-KODY-INSIGHTS-WEBHOOK',
		dryRun: true,
	})
}

导出模块

  • kody:@kody/planetscale — 操作分发器(默认为概览)
  • kody:@kody/planetscale/accounts — 解析密钥名称和设置 URL
  • kody:@kody/planetscale/smoke-test — 可选凭据的冒烟测试
  • kody:@kody/planetscale/list-organizations — 列出组织(只读)
  • kody:@kody/planetscale/list-databases — 列出数据库(只读)
  • kody:@kody/planetscale/list-branches — 列出分支(只读)
  • kody:@kody/planetscale/list-anomalies — 列出 Insights 异常(只读)
  • kody:@kody/planetscale/list-queries — 列出 Insights 查询,默认按 p99_latency 排序(只读)
  • kody:@kody/planetscale/draft-loop — 格式化 issue + 提示词(不写入)
  • kody:@kody/planetscale/configure-loop — 保存组织/数据库/仓库目标(dryRun/confirm)
  • kody:@kody/planetscale/run-loop — 预览或运行 issue → PR → 通知循环
  • kody:@kody/planetscale/handle-webhook — branch.anomaly webhook 处理器
  • kody:@kody/planetscale/poll-anomalies — 计划 Insights 轮询(任务初始为禁用状态)
  • kody:@kody/planetscale/create-webhook — 创建 PlanetScale webhook(dryRun/confirm)
  • kody:@kody/planetscale/request — 底层 PlanetScale API 访问入口
  • kody:@kody/planetscale/types — 共享 TypeScript 类型

备注

  • REST 基础 URL:https://api.planetscale.com/v1
  • 列表辅助函数返回 { items, pageInfo }。
  • Insights 仪表板 URL 格式为 https://app.planetscale.com/{org}/{db}/{branch}/insights。
  • branch.anomaly webhook 负载包含 organization、database 和 resource.name(即分支名)。处理器随后会列出 Insights 异常。
  • 此包与 PlanetScale 无关联或未获其背书。

品牌

community-icon.svg 是 PlanetScale 的官方白色标志,来源于 planetscale.com/brand(planetscale-logo-mark-white.svg,黑色背景 #000000)。路径未作修改,仅添加了方形瓦片以确保标志在 56 像素下清晰可辨。PlanetScale® 是 PlanetScale, Inc. 的商标。此包与 PlanetScale 无关联或未获其背书。

文档

收藏

0 颗星

登录 为此包添加星标.

举报此列表 登录 举报此列表.

Matt Pocock (@mattpocockuk): 一个非常棒的循环思路是:

  • 数据库警告你存在慢查询(@PlanetScale 提供此功能)
  • 在你的代码库中创建一个 issue
  • 立即安排一个实现者提交 PR
  • 审核代理审查该 PR
  • 通知人工进行审核

不断重复直到应用速度提升

相似文章