lookbkdev/lookbk-skills / skills/itinerary-kit
itinerary-kit
UnverifiedBuild the itinerary page for a guided trip, tour or retreat that a travel company sells, from one trip.json, a route file and a map file. The page is drawn like a surveyor's sheet - one route shown three ways that move together: a map drawn in the page's own type and colours from coordinates (no map tiles, no map service), a whole-trip height strip, and a day-by-day ledger with measured distance, climb, where you sleep, meals, an effort grade by a stated rule and a note. Scrolling through the days moves the map and strip; tapping the strip jumps to a day. Then what is included, departures with places left, and the price. On a phone the map becomes a sticky strip. Every figure is measured or counted by the build, never typed; a stated distance that disagrees with the track stops it. One self-contained page plus a paste-in embed, a check at four widths, and a frame-exact video. Use for walking holidays, cycling or driving tours, photography trips, retreats and expeditions.
| File | Kind | Size |
|---|---|---|
| NOTICE.md | markdown | 2.0 KB |
| SKILL.md | skill md | 18.1 KB |
| TESTED.json | config | 489 B |
| examples/drywash-expeditions/geo.geojson | other | 382.4 KB |
| examples/drywash-expeditions/route.geojson | other | 72.5 KB |
| examples/drywash-expeditions/trip.json | config | 5.4 KB |
| examples/hollin-walking/geo.geojson | other | 185.6 KB |
| examples/hollin-walking/route.geojson | other | 25.3 KB |
| examples/hollin-walking/trip.json | config | 5.7 KB |
| kit/geo/natural-earth-50m.json | config | 738.7 KB |
| kit/geo/world-atlas-LICENSE.txt | markdown | 734 B |
| kit/itinerary.css | other | 18.0 KB |
| kit/runtime.js | script | 13.4 KB |
| scripts/build.mjs | script | 141 B |
| scripts/check.mjs | script | 141 B |
| scripts/chrome.mjs | script | 3.6 KB |
| scripts/kit/build.mjs | script | 23.9 KB |
| scripts/kit/cdp.mjs | script | 4.9 KB |
| scripts/kit/check.mjs | script | 20.9 KB |
| scripts/kit/geo.mjs | script | 6.3 KB |
| scripts/kit/record.mjs | script | 6.6 KB |
| scripts/kit/schema.mjs | script | 12.8 KB |
| scripts/kit/serve.mjs | script | 2.5 KB |
| scripts/measure.mjs | script | 2.3 KB |
| scripts/record.mjs | script | 143 B |
| scripts/serve.mjs | script | 141 B |
scripts/kit/record.mjs
View on GitHub// Itinerary Kit: records the built page's tour frame by frame into a video
// and a poster, or takes one still, or lists the settled moments.
//
// node scripts/record.mjs out/index.html [--seconds 19] [--size 1920x1080] [--poster 2]
// node scripts/record.mjs out/index.html --still 2 [--size 390x844 --scale 2] [--png file.png]
// node scripts/record.mjs out/index.html --moments [--size 390x844]
//
// The page runs with ?it-record=1: nothing moves on its own, and for every
// frame the recorder asks it to step its tour (rest on the top with the whole
// route, glide to each of the first four days and rest while the map settles
// on it, then the dates and the price). Every frame is taken at its exact
// time, so the video is the same on any machine. --moments prints
// { length, settled, moments }: the stretches where the scroll rests and the
// map has finished moving, so stills and posters are only taken at rest.
import { spawnSync } from 'node:child_process'
import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { dirname, join, relative, resolve } from 'node:path'
import { launch } from './cdp.mjs'
import { serve } from './serve.mjs'
function args(argv) {
const out = { _: [] }
for (let i = 0; i < argv.length; i++) {
const a = argv[i]
if (!a.startsWith('--')) out._.push(a)
else {
const [k, v] = a.slice(2).split('=')
out[k] = v ?? (argv[i + 1] && !argv[i + 1].startsWith('--') ? argv[++i] : true)
}
}
return out
}
const shown = (p) => { const r = relative(process.cwd(), p); return r.startsWith('..') ? p : r }
function ffmpeg(argv) {
const bin = process.env.FFMPEG_PATH || 'ffmpeg'
const r = spawnSync(bin, ['-hide_banner', '-loglevel', 'error', '-y', ...argv], { stdio: ['ignore', 'inherit', 'pipe'] })
if (r.error) throw new Error('ffmpeg not found: install it (brew install ffmpeg, winget install ffmpeg, apt install ffmpeg) or set FFMPEG_PATH')
if (r.status !== 0) throw new Error(`ffmpeg failed: ${String(r.stderr).slice(-600)}`)
}
export async function record(input, opts = {}) {
const file = resolve(input)
if (!existsSync(file)) throw new Error(`${input} not found; build the page first`)
const out = dirname(file)
const [w, h] = String(opts.size ?? '1920x1080').split('x').map(Number)
const scale = Number(opts.scale ?? 1)
const fps = Number(opts.fps ?? 30)
const server = await serve(out)
const chrome = await launch({ width: Math.max(w, 800), height: h })
const tmp = mkdtempSync(join(tmpdir(), 'itinerary-kit-'))
const errors = []
try {
const tab = await chrome.page()
chrome.on('Runtime.exceptionThrown', (p) => errors.push(p.exceptionDetails?.exception?.description ?? p.exceptionDetails?.text))
await tab.send('Page.enable')
await tab.send('Runtime.enable')
await tab.send('Emulation.setDeviceMetricsOverride', { width: w, height: h, deviceScaleFactor: scale, mobile: w < 760 })
if (opts.reduce) await tab.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-reduced-motion', value: 'reduce' }] })
const loaded = tab.once('Page.loadEventFired', 60000)
await tab.send('Page.navigate', { url: `${server.url}${relative(out, file)}?it-record=1` })
await loaded
const ev = async (expression) => {
const r = await tab.send('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true })
if (r.exceptionDetails) throw new Error(r.exceptionDetails.exception?.description ?? r.exceptionDetails.text)
return r.result.value
}
for (let i = 0; i < 100 && !(await ev('!!(window.Itinerary && window.Itinerary.ready)')); i++) await new Promise((r) => setTimeout(r, 100))
if (!(await ev('!!window.Itinerary'))) throw new Error(`the page did not start: ${errors.join(' | ') || 'unknown'}`)
await ev('window.Itinerary.ready')
await new Promise((r) => setTimeout(r, 300))
const length = Number(opts.seconds ?? (await ev('window.Itinerary.length')))
if (opts.moments) return { moments: { length, ...(await ev('({ settled: Itinerary.settled, moments: Itinerary.moments })')) } }
const shot = async (t, path) => {
await ev(`window.Itinerary.seek(${t})`)
const { data } = await tab.send('Page.captureScreenshot', { format: 'png' })
writeFileSync(path, Buffer.from(data, 'base64'))
}
if (opts.still !== undefined) {
const png = resolve(opts.png ?? join(out, 'still.png'))
const t = Math.min(Math.max(Number(opts.still) || 0, 0), length)
await ev(`window.Itinerary.seek(${t})`)
await new Promise((r) => setTimeout(r, 150))
await ev(`window.Itinerary.seek(${t})`)
const settled = await ev(`window.Itinerary.settled.some(([a, b]) => ${t} >= a && ${t} <= b)`)
if (!settled) console.warn(`note: ${t}s is not inside a settled stretch (${await ev('JSON.stringify(window.Itinerary.settled)')})`)
const { data } = await tab.send('Page.captureScreenshot', { format: 'png' })
writeFileSync(png, Buffer.from(data, 'base64'))
return { png }
}
const frames = Math.round(length * fps)
for (let i = 0; i < frames; i++) await shot(i / fps, join(tmp, `${String(i + 1).padStart(5, '0')}.png`))
const mp4 = join(out, 'preview.mp4')
ffmpeg(['-framerate', String(fps), '-i', join(tmp, '%05d.png'), '-vf', `scale=${w}:${h}:flags=lanczos,format=yuv420p`, '-c:v', 'libx264', '-preset', 'slow', '-crf', String(opts.crf ?? 18), '-movflags', '+faststart', mp4])
const posterAt = Math.min(Math.max(Number(opts.poster ?? (await ev('window.Itinerary.moments[0][1]'))), 0), length - 1 / fps)
const poster = join(out, 'poster.png')
ffmpeg(['-ss', String(posterAt), '-i', mp4, '-frames:v', '1', '-update', '1', poster])
if (errors.length) console.warn(`page errors: ${errors.join(' | ')}`)
return { mp4, poster }
} finally {
await chrome.close()
server.close()
rmSync(tmp, { recursive: true, force: true })
}
}
export async function main(argv = process.argv.slice(2)) {
const a = args(argv)
const [input] = a._
if (!input) {
console.log('usage: node scripts/record.mjs out/index.html [--seconds S] [--size 1920x1080] [--poster S]\n node scripts/record.mjs out/index.html --still S [--size 390x844 --scale 2] [--png file.png]\n node scripts/record.mjs out/index.html --moments [--size 390x844]')
process.exit(1)
}
try {
const r = await record(input, a)
if (r.moments) console.log(JSON.stringify(r.moments))
else if (r.png) console.log(`wrote ${shown(r.png)}`)
else console.log(`wrote ${shown(r.mp4)} and ${shown(r.poster)}`)
} catch (e) {
console.error(e.message)
process.exit(1)
}
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |