Skip to content

Commit 332422b

Browse files
committed
feat: move generate-teasers and improve prompt with more examples
1 parent a56f6e3 commit 332422b

5 files changed

Lines changed: 17 additions & 15 deletions

File tree

bin/evaluate-teasers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { globby } from 'globby'
33
import matter from 'gray-matter'
44
import { readFile } from 'node:fs/promises'
55

6-
import { generateTeaser } from '../11ty/generate-teasers.ts'
6+
import { generateTeaser } from './generate-teasers.ts'
77

88
interface Article {
99
title: string
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
insertTeaserIntoFrontmatter,
77
wrapText,
88
} from './generate-teasers.ts'
9-
import { computeHash, hashFields } from './revisions.ts'
9+
import { computeHash, hashFields } from '../11ty/revisions.ts'
1010

1111
describe('computeHash', () => {
1212
it('produces a 12-character hex string', () => {
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
computeTeaserHash,
1010
loadRevisions,
1111
saveRevisions,
12-
} from './revisions.ts'
12+
} from '../11ty/revisions.ts'
1313

1414
const TEASER_PROMPT = `
1515
You are generating a preview teaser for a blog post. The teaser appears as
@@ -22,10 +22,8 @@ read like the first few lines of the article, adapted to make sense without
2222
the surrounding context.
2323
2424
Guidelines:
25-
- Plain text only. No markdown, HTML, or formatting.
26-
- Always use curly quotes (“” ‘’), em-dashes (—), and
27-
ellipses (…). Never straight quotes or hyphens as dashes. Em-dashes must
28-
have spaces on both sides (\` — \`).
25+
- Plain text only. No markdown, HTML, or formatting. Unicode punctuation is fine.
26+
- Em-dashes must have spaces on both sides (\` — \`).
2927
- Target ~200 characters. Never exceed 250.
3028
- Skip blockquotes. Bridge the text before and after naturally, including
3129
only essential context from the quote if needed for surrounding text to
@@ -40,8 +38,10 @@ won’t be present.
4038
- Output only the teaser text. No explanation, no quotes around it.
4139
4240
Examples of correct output:
43-
- Maybe you’ve heard of the \u201Csocial contract.” It’s a concept in philosophy popularized during the Enlightenment…
44-
- I’ve reimplemented everything to target WebAssembly using SIMD instructions\u2014a language I’ve wanted to learn…
41+
- John Gruber is scathing about macOS Tahoe's window corners. In general I think the larger corner radiuses look fine. But if Apple really wanted to make this new look functional it needed to rethink how windows work…
42+
- Maybe you've heard of the "social contract." It's a concept in philosophy popularized during the Enlightenment…
43+
- I've reimplemented everything to target WebAssembly using SIMD instructions — a language I've wanted to learn…
44+
- Simon P. Couch used energy-per-token estimates to calculate his AI coding energy use — about 1,300 Wh through Claude Code on a median day. This matches my mental model…
4545
`.trim()
4646

4747
export interface TeaserDecision {
@@ -220,7 +220,9 @@ async function main() {
220220
console.log(`Done. ${generatedCount} teaser(s) generated.`)
221221
}
222222

223-
main().catch((error: unknown) => {
224-
console.error(error)
225-
process.exit(1)
226-
})
223+
if (import.meta.url === `file://${process.argv[1]}`) {
224+
main().catch((error: unknown) => {
225+
console.error(error)
226+
process.exit(1)
227+
})
228+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"clean": "del-cli *.tsbuildinfo coverage dist",
1212
"predev": "npm run prebuild",
1313
"dev": "eleventy --serve --incremental",
14-
"generate-teasers": "node 11ty/generate-teasers.ts",
14+
"generate-teasers": "node bin/generate-teasers.ts",
1515
"update-revisions": "node 11ty/update-revisions.ts",
1616
"lint": "eslint *.js *.ts 11ty www infra types",
1717
"postinstall": "patch-package",

vitest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default defineConfig({
77
{
88
test: {
99
name: 'unit',
10-
include: ['infra/test/**/*.spec.ts', '11ty/**/*.spec.ts'],
10+
include: ['infra/test/**/*.spec.ts', '11ty/**/*.spec.ts', 'bin/**/*.spec.ts'],
1111
exclude: ['node_modules/**', 'dist/**'],
1212
environment: 'node',
1313
},

0 commit comments

Comments
 (0)