Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions .github/ISSUE_TEMPLATE/page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Page Fetch Issue
description: Report a problem fetching or narrowing a specific page with curl.md.
labels: ['bug']
body:
- type: markdown
attributes:
value: |
Thanks for reporting this.

For page-specific issues, the most helpful details are the exact page URL and the exact request options you used.

- type: checkboxes
id: existing_issues
attributes:
label: Check existing issues
description: By submitting this issue, you checked there is not already an issue for this problem.
options:
- label: I checked existing issues and did not find a duplicate.
required: true

- type: input
id: page_url
attributes:
label: Page URL
description: The exact page you tried to fetch.
placeholder: https://developers.cloudflare.com/workers
validations:
required: true

- type: textarea
id: issue
attributes:
label: What is the issue?
description: What did you expect, and what happened instead?
placeholder: I expected curl.md to return the installation steps, but it omitted that section / returned unrelated content / failed to fetch the page.
validations:
required: true

- type: input
id: objective
attributes:
label: Objective
description: If you used an objective, paste it exactly.
placeholder: find the install steps
validations:
required: false

- type: input
id: keywords
attributes:
label: Keywords
description: If you used keywords, paste them exactly.
placeholder: install,worker,binding
validations:
required: false

- type: dropdown
id: mode
attributes:
label: Mode
description: If you used an objective, which mode did you use?
options:
- I did not use an objective
- smart
- rush
validations:
required: true

- type: checkboxes
id: request_options
attributes:
label: Request options
options:
- label: I used `fresh` / bypassed cache.

- type: textarea
id: exact_request
attributes:
label: Exact request
description: Paste the exact CLI command, browser URL, SDK call, or agent tool input if possible.
placeholder: |
curl.md developers.cloudflare.com/workers --objective "find the install steps" --keywords install,worker --fresh
render: shell
validations:
required: false

- type: textarea
id: response
attributes:
label: Response or error output
description: Paste the returned markdown, error message, or a representative excerpt.
validations:
required: false

- type: textarea
id: context
attributes:
label: Anything else?
description: Extra context. Public/private page, auth requirements, browser vs CLI, screenshots, etc.
validations:
required: false
3 changes: 2 additions & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ curl.md example.com
md example.com

# Add to your agent
claude plugin install curl-md@claude-plugins-official
claude plugin marketplace add wevm/curl.md
claude plugin install curl-md@curl-md
opencode plugin -g @curl.md/opencode
pi install npm:@curl.md/pi
npx @curl.md/amp install
Expand Down
67 changes: 40 additions & 27 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1049,15 +1049,19 @@ export const api = new Hono<{

let paymentIntent: Stripe.PaymentIntent
try {
paymentIntent = await stripe.paymentIntents.create({
amount,
confirm: true,
currency: 'usd',
customer: stripeCustomerId,
metadata: { entity_type: entityType, entity_id: entityId },
off_session: true,
payment_method: defaultPaymentMethod.id,
})
const idempotencyKey = c.req.header('idempotency-key')
paymentIntent = await stripe.paymentIntents.create(
{
amount,
confirm: true,
currency: 'usd',
customer: stripeCustomerId,
metadata: { entity_type: entityType, entity_id: entityId },
off_session: true,
payment_method: defaultPaymentMethod.id,
},
idempotencyKey ? { idempotencyKey } : undefined,
)
} catch (error) {
if (
error instanceof Stripe.errors.StripeCardError &&
Expand Down Expand Up @@ -1733,7 +1737,7 @@ export const api = new Hono<{

switch (event.type) {
case 'payment_intent.succeeded': {
const paymentIntent = event.data.object as import('stripe').Stripe.PaymentIntent
const paymentIntent = event.data.object
const customer = typeof paymentIntent.customer === 'string' ? paymentIntent.customer : null
if (customer && paymentIntent.amount)
await c.env.STRIPE_WEBHOOK_QUEUE.send({
Expand All @@ -1748,7 +1752,7 @@ export const api = new Hono<{
}
case 'charge.dispute.created': {
// TODO: send chargeback alert (email/Slack)
const dispute = event.data.object as import('stripe').Stripe.Dispute
const dispute = event.data.object
const charge =
typeof dispute.charge === 'string'
? await stripe.charges.retrieve(dispute.charge)
Expand All @@ -1766,7 +1770,7 @@ export const api = new Hono<{
break
}
case 'refund.created': {
const refund = event.data.object as import('stripe').Stripe.Refund
const refund = event.data.object
const charge =
typeof refund.charge === 'string'
? await stripe.charges.retrieve(refund.charge)
Expand Down Expand Up @@ -2045,7 +2049,6 @@ export const api = new Hono<{
vary: 'Accept',
})

// Rate limit: three tiers (anon, authed/free, paid)
const identity = c.var.session
? c.var.session.account_id
: (c.req.header('cf-connecting-ip') ?? 'unknown')
Expand All @@ -2059,23 +2062,22 @@ export const api = new Hono<{
if (balanceMills > 0) billable = true
}

const limit = (() => {
if (query.objective)
let rateLimitHeaders: Record<string, string> = {}
if (!billable) {
const limit = (() => {
if (query.objective)
return {
key: `query:${identity}` as const,
max: c.var.session ? 10 : 3,
window: 3600,
}
return {
key: `query:${identity}` as const,
max: c.var.session ? 10 : 3,
key: `fetch:${identity}` as const,
max: c.var.session ? 1000 : 100,
window: 3600,
}
return {
key: `fetch:${identity}` as const,
max: c.var.session ? 1000 : 100,
window: 3600,
}
})()
})()

// Paid users skip rate limiting
let rateLimitHeaders: Record<string, string> = {}
if (!billable) {
const kvKey = `ratelimit:${limit.key}` as const
const now = Math.floor(Date.now() / 1000)
const record = await c.env.KV.get(kvKey, 'json')
Expand Down Expand Up @@ -2251,7 +2253,18 @@ export const api = new Hono<{
}

const chunks = Md.chunk(filteredContent)
const results = await Promise.all(chunks.map(extractChunk))
const results: Awaited<ReturnType<typeof extractChunk>>[] = []
let chunkIndex = 0
// Bound Workers AI fan-out so one large objective request can't saturate inference capacity.
await Promise.all(
Array.from({ length: Math.min(2, chunks.length) }, async () => {
while (chunkIndex < chunks.length) {
const currentIndex = chunkIndex
chunkIndex += 1
results[currentIndex] = await extractChunk(chunks[currentIndex]!)
}
}),
)
const filtered = results
.filter((r) => r.response && r.response.trim() !== Constants.sentinelValue)
.map((r) => r.response)
Expand Down
Loading
Loading