agentleFS
vanduc2514vanduc2514/agent-tkst-hanoi-2026/.agents/skills/sync-festival/SKILL.md

sync-festival

Skill0 starsChanged 11 days agoMITView on GitHub

Refresh src/events.json from the Hanoi Design Festival's official site and from the organiser's Facebook, Instagram and Threads accounts, retrieved through Apify. Use when events may have been added, moved, renamed or cancelled, before a deploy, or when a poster or social post disagrees with the local data. The organiser's posts win every date and time conflict, because they are the freshest source; map pins and curated per-day schedules are never overwritten.

  • Installs packages

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every run ends by pasting tmp/sync/report.md into the answer, unchanged and in full, as Markdown.

    line 176

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Sync the festival programme

Keeps src/events.json aligned with what the organiser publishes.

Two sources, two jobs:

SourceRetrieved withProvides
lehoithietkesangtao.vnits public JSON APItitles, types, venues, detail prose, media library, albums, covers
Facebook, Instagram, ThreadsApify actorschanges, additions, the real schedule, promotion photos and cards

The map pins, clusters and per-day schedules in the repo are curated here. A post only overrides date, dateEnd, startTime and endTime.

Ground rules

  1. Apify is the retrieval layer. Social content comes from three actors over the Apify REST API; no browser driving, no HTML scraping, no manual paste.
  2. The site is JSON, not HTML. /su-kien/ is a client-side app; its data is /api/public/events. Read the API.
  3. The site's dates are coarse, but they are the reference. startAt/endAt are UTC values; a 00:00 time means "no hours published" and is ignored. Dates are written as given. Hours are written for single-day events; for a multi-day run one window cannot describe the programme, so those go to review
  4. The site leads, and the run fixes itself. apply writes what the site says instead of asking: a single-day event takes its startTime/endTime, every event takes its date/dateEnd, and a title is corrected when the change is cosmetic (punctuation, casing, spacing). Empty organiser fields are filled the same way. Posts only fill what the site leaves unsaid, and never overrule a page that exists.
  5. Raise only what cannot be settled. The review table is for real conflicts — the site and a post stating different values, a curated per-day schedule the site contradicts, a new event that needs a map pin, a listing that vanished. Everything else is corrected silently and appears under "Changes made".
  6. An image must show its own event. images reads the text printed on every candidate (OCR) before attaching it: a designed card belongs to the event whose name it prints first, near the top. A roundup, a venue card, or another programme's card is not evidence. When nothing is truthful, the event keeps its generated kind poster rather than a misleading photo.
  7. Two field classes. official* belongs to the organiser and may be refreshed. slots, lineup, days, placeId, clusterId, tags, spotlight and number are curated and only change by hand — a curated per-day schedule is richer than one post, so an event that has one is never overridden.

Workflow

When this runs from CI. .github/workflows/sync-festival.md executes steps 1–3 below in frontmatter steps, with APIFY_TOKEN in that step's environment only. The agent that follows starts at step 5: tmp/sync/report.md is already on disk, src/events.json is already resolved, and APIFY_TOKEN is deliberately absent from the agent's environment. Do not re-run fetch, do not look for the token, and do not use mise — it is not installed on the runner. images is not part of the CI run either: it needs a fresh fetch, Pillow and (for card verification) Apple's Vision OCR, none of which the runner has. The Apify spend for the run has already been made.

1. Fetch

export APIFY_TOKEN=...            # never written to a file
python3 .agents/skills/sync-festival/scripts/sync_festival.py fetch [--limit 25]

Runs the three actors, waits for them, and writes tmp/sync/social.json with the raw datasets and the spend. Costs about $0.04 for the default sweep; see references/apify.md.

2. Diff

python3 .agents/skills/sync-festival/scripts/sync_festival.py diff

Writes tmp/sync/report.md — a 2–3 KB triage sheet — and tmp/sync/social-drafts.json. Read the report; do not open the raw datasets.

The report has exactly two sections, both keyed by event name then id:

SectionRowsAction
Changes madewhat the last apply wrote on its own, with the linked page or post it came fromnone, it is a record
Needs your reviewcontradictions and items only a human can settleread the row, then edit by hand

"Changes made" uses | Event | id | Change | Source |, where the source is the post it came from, linked, or lehoithietkesangtao.vn. "Needs your review" uses | Event | id | Difference |: the cell names the field, our value, and the remote value with its origin spelled out and linked — facebook post, 2026-11-20 when a post exists, lehoithietkesangtao.vn otherwise — never the bare word "listing". A post row also says when its date is one session inside our longer run rather than a reschedule.

A difference a post already settles is not repeated under review. Everything the sync deliberately leaves alone — curated official values, per-day schedules, venue-label notes, posts outside the window — is a single "Nothing to do" line under the tables, along with the ids that have no official page.

3. Apply

python3 .agents/skills/sync-festival/scripts/sync_festival.py apply
python3 .agents/skills/sync-festival/scripts/sync_festival.py apply --no-social
python3 .agents/skills/sync-festival/scripts/sync_festival.py apply --insert-social

apply resolves the site first, in this order:

  1. Site corrections. date, dateEnd, and startTime/endTime on single-day events; a 00:00 site time is treated as "no hours" and skipped. A title is rewritten only when the site's version folds to the same words or is 90% similar — a cosmetic fix, not a different event.
  2. Post fills. A post writes date, dateEnd, startTime and endTime only for events that have no official page. It must name exactly one event and carry its own Thời gian/Time line; the newest post per event wins.
  3. Empty organiser fields, filled from the API.

Anything the site and a post disagree about is not written: the event is reported for review. --no-social skips the post fills when the fetch is stale. --insert-social adds drafts that carry a date, a time, a resolvable place and an event-like title, and that are not duplicates or outside 13–28/11.

4. Images

python3 .agents/skills/sync-festival/scripts/sync_festival.py images --dry-run
python3 .agents/skills/sync-festival/scripts/sync_festival.py images

Runs on the machine that made the fetch, because it needs Pillow (python3 -m pip install pillow) and, to verify cards, Apple's Vision framework through scripts/ocr.swift (compiled once into tmp/sync/ocr). It:

  1. gathers candidates from the site's media library, its 14 media albums, project and article covers, the fetched posts and the known card decks;
  2. downloads each image once into tmp/sync/scan, skipping anything under 320px;
  3. reads the text printed on it, and keeps the image only where that text (or the post's opening line) names this event;
  4. ranks printed information first, so a designed card is the cover and photos follow; de-duplicates by perceptual hash; caps each gallery at --max-per-event (default 10);
  5. writes the winners into src/images/events and src/images/cards, content-addressed, then sets image and images on every event.

--no-ocr skips step 3's verification, which means cards cannot be trusted and only post photos are kept. --dry-run prints what would change and writes tmp/sync/images.json (per-event source URLs and information scores) without touching events.json.

Two things expire, so re-run fetch first when the run reports far fewer images than the last time: the posts are only as fresh as the last fetch, and Facebook and Instagram CDN URLs stop working within days. The site's own images do not expire.

5. Check

python3 .agents/skills/sync-festival/scripts/sync_festival.py check
python3 .agents/skills/sync-festival/scripts/selftest.py
node tools/build-agent-files.mjs --base https://tkst.nvduc.dev
python3 -m http.server 8080 --directory src

check catches duplicate ids, unknown places/clusters, malformed times, dateEnd < date, broken numbering, and an image or images entry whose file is not on disk. selftest.py is 61 offline tests over the parsers, matcher, diff, schedule override, inserter and the image attribution rules; it must pass before any edit is committed.

6. Report

Every run ends by pasting tmp/sync/report.md into the answer, unchanged and in full, as Markdown. Not a summary of it, not a link to it — the tables themselves, then one line on what you did with them. Skip this and the run is incomplete.

The file is generated by render(); do not hand-write it. Its shape is fixed:

# Festival sync — 2026-11-13 → 2026-11-28

92 unchanged · 12 differ from the official site · 1 new on the official site · 48 without an official page

## Changes made

`apply`, 2026-11-21T13:02

| Event | id | Change | Source |
|---|---|---|---|
| … | `e122` | end 17:00 → 17:30 | [facebook post, 2026-11-20](…post url…) |

## Needs your review

Only what two sources contradict, or what `apply` cannot settle alone.

| Event | id | Difference |
|---|---|---|
| … | `e130` | end differs: ours 11:00, [lehoithietkesangtao.vn](…page…) says 12:00, [threads post, 2026-11-21](…post…) says 11:00 — the post and the site disagree |

Nothing to do: …
No official page, so unverifiable: …

Rules the format enforces:

  1. Two sections only, ## Changes made then ## Needs your review, in that order.
  2. Event name first, then the id in backticks, then the difference or change.
  3. Name the source, never the mechanism. A post is facebook post, 2026-11-20, instagram post, 2026-11-20 or threads post, 2026-11-21; the organiser's site is lehoithietkesangtao.vn. Both are links to the exact page or post. The word "listing" never appears.
  4. A difference reads <field> differs: ours <value>, <source> says <value>. Titles are quoted. A missing event reads not in events.json: <source> has it starting …; a delisted one reads we still list it: <source> dropped the slug and the sitemap.
  5. A review row exists only for a contradiction or an unresolvable item: the site and a post disagreeing, a curated per-day schedule the site contradicts, a slug that needs a map pin, a page that disappeared. Cite every source that speaks, the site first, then the post.
  6. Anything the sync deliberately leaves alone, and anything apply is about to write, stays in the single "Nothing to do" line. Do not add sections, notes or commentary between the tables.

Commands

CommandEffect
fetch [--limit N]run the three Apify actors → tmp/sync/social.json
diffsite API + social → tmp/sync/report.md, social-drafts.json
enrich [--write]registration links from the fetched posts → registrationUrl
socialrebuild drafts from social.json without touching the site
apply [--no-social] [--insert-social]write social schedule overrides + safe fills
images [--dry-run] [--no-ocr] [--max-per-event N]verify and store promotion images → image, images
checkvalidate events.json, no network

apply also writes tmp/sync/applied.json, the ledger the "Changes made" section is built from.

Exit codes: 0 clean, 1 something to review or a validation problem, 2 retrieval failed.

Field ownership

FieldOwnerWritten by
titleorganiser, curated by handmanual
officialUrl, officialType, officialVenue, officialVenueAddressorganiserapply, only when empty
officialDetail, officialSummaryorganisermanual
registrationUrlorganiser (posted on social)enrich
date, dateEnd, startTime, endTimeorganiser (posted on social), else curatedapply from the newest post
slots, lineup, dayscuratedmanual
placeId, clusterIdcurated map pinsmanual
tags, description, spotlight, numbercuratedapply --insert-social adds, then renumbers
image, imagesorganiser (the pictures)images, which may only pick from what the organiser published

Schema details and how to extend it: references/schema.md. Wiring a new field into the page: references/ui-checklist.md.

Cost

Measured 2026-11-20 on the free plan ($5/month, no card):

RunItemsCost
Instagram, 5 posts5$0.0135
Facebook, 5 posts5$0.0250
Threads profile1 item with 13 posts nested$0.0050
Default sweep, three accounts~11 items~$0.04

That is ~120 sweeps a month, or one a day with room for a full refresh after each announcement. Prices and plan limits: references/apify.md.

Files

PathPurpose
scripts/sync_festival.pyCLI: fetch, diff, apply, images, check
scripts/apify.pyApify REST client: run actor, poll, read dataset
scripts/social.pydataset shapes → drafts (pure)
scripts/enrich.pyregistration links from posts (pure)
scripts/schedule.pyschedule overrides from posts (pure)
scripts/extract.pytext normalising, HTML, dates, times (pure)
scripts/match.pyvenue lookup, duplicate detection, slugs (pure)
scripts/events_model.pyload, validate, save, build events (pure)
scripts/config.pyaccounts, actors, prices, festival window
scripts/images.pycandidate gathering, OCR ranking, image selection (pure select)
scripts/ocr.swiftApple Vision OCR helper, compiled to tmp/sync/ocr on first use
scripts/selftest.py61 offline tests
tmp/sync/applied.jsonthe ledger the "Changes made" table is built from
tmp/sync/images.jsonper-event image provenance and information scores, from the last run
tmp/sync/scan/download and OCR cache, safe to delete (a rerun refetches)
references/apify.mdactors, inputs, pricing, dataset shapes
references/schema.mdfield ownership and extension procedure
references/ui-checklist.mdwiring new metadata into the page
references/images.mdwhere images come from, the attribution rules, adding a card deck

Failure modes

SymptomCauseFix
APIFY_TOKEN is not settoken not exportedexport APIFY_TOKEN=... in the same shell
ApifyError: 401token revokedissue a new token in Apify Console
ApifyError: ... finished FAILEDactor input rejectedcheck the input against references/apify.md
fetch reports 0 itemsactors see no new postswiden --limit; check the accounts still exist
many announcement draftsthe organiser posts updates, not eventsnormal; only ready drafts are insertable
needs a human rows repeatthe site is coarser than the curated valueleave them; the report is a triage sheet, not a work list
a schedule override looks wrongthe post describes one session of a run, or a stale fetchcheck the post URL in the report; rerun with --no-social to skip
apply rewrote a title into something oddthe site's title drifted past a cosmetic changerestore from git; the 90% guard is in site_fixes
the answer has prose but no tablesstep 6 skippedpaste tmp/sync/report.md in full
images keeps far fewer images than last timestale posts or expired CDN URLsre-run fetch first; the site's own images never expire
ApifyError: ... platform-feature-disabledthe monthly $5 free quota is spentwait for the reset, or run site-only sources; images still works offline from the site
images exits with "Pillow is required"Pillow missingpython3 -m pip install pillow
images reports ocr offno Swift/swiftc (Linux) or compile failedexpected off macOS; cards cannot be verified, so only post photos are kept
a card lands on the wrong eventthe card prints the name late, or OCR misreads itadd the event and a regex to MANUAL_REJECT in scripts/images.py; the run is repeatable
check reports image is a remote URLa hand edit pointed at a CDNrun images, which stores files under src/images

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.