Repository navigation
Scripts and Media Tools
Flows name commands; these are the commands. Two folders:
-
scripts/: helpers that use the Python standard library only. Each one is silent unless it has something to say, opens no console windows on Windows, and fails loudly. -
media/: image and video tools. A tool that needs Pillow, numpy or ffmpeg says so and how to install it.
Each folder has an INDEX.json generated from the scripts' own argument parsers: purpose, usage line, what it
needs and what it touches. Agents read it instead of guessing arguments. Every tool has --help.
python scripts/bank.py --help
python scripts/make_index.py --check # is scripts/INDEX.json current?
python scripts/make_index.py --dir media --check # is media/INDEX.json current?After changing a script's arguments, regenerate the index: python scripts/make_index.py (and
--dir media for the media tools).
| Code | Means |
|---|---|
| 0 | Worked |
| 1 | Failed; the message is on stderr (every request failed, an input file is missing, an external program like ffmpeg, codex or Chrome is missing) |
| 2 | Usage error: a missing or malformed argument |
| 3 | An optional Python module is missing ("needs PIL: pip install Pillow") |
The "Demo" column marks the scripts the demo flows call. The others are general helpers you can call from your own flows.
| Script | Purpose | Usage | Needs | Effects | Demo |
|---|---|---|---|---|---|
bank.py |
Post bank: check lengths and print compose links for the posts in bank.tsv
|
bank.py [--bank FILE] [check | x KEY | b KEY | text KEY [+]] |
none | x-post | |
bridge_wait.py |
Wait for a fresh chrome-control native host after a bridge drop (Windows) | bridge_wait.py [MAX_MINUTES] | --list |
none | ||
bsky_authors.py |
Recent original posts from chosen Bluesky accounts, ranked by likes + 3 x replies | bsky_authors.py HANDLE [HANDLE ...] [--hours 14] [--limit 40] |
network | ||
bsky_feed.py |
Fresh top-level posts from Bluesky custom feeds, ranked by likes + 3 x replies | bsky_feed.py FEED_URI [FEED_URI ...] [--hours 30] |
network | ||
bsky_filter.py |
Drop Bluesky candidates the owner already replied to, and reply-gated threads | bsky_filter.py OWNER_HANDLE < candidates |
network | ||
bsky_open.py |
List replies on the owner's recent Bluesky threads that the owner hasn't answered | bsky_open.py OWNER_HANDLE [THREADS_TO_SCAN] |
network | bluesky | |
captions.py |
Write an ASS subtitle file for captions burned into a video with ffmpeg | captions.py CUES_JSON OUT_ASS WIDTH HEIGHT |
files | ||
clip.py |
Copy text to the system clipboard silently and verify it arrived | clip.py FILE [LINE] | --text "STRING" |
clipboard | ||
clipimage.py |
Put an image on the system clipboard silently (paste it with Ctrl+V into a site or a program) | clipimage.py IMAGE |
clipboard | ||
codex_img.py |
Generate one image with the Codex CLI's built-in image generation | codex_img.py "PROMPT" OUT.png [--timeout 600] [--ref IMAGE ...] [--codex PATH] |
Codex CLI (signed in) | network, files | |
doctor.py |
Setup check: Python, Chrome, the clipboard and the public APIs | doctor.py [--no-clipboard] [--no-network] |
clipboard, network | onboard | |
fb_snap.py |
Map Facebook comment authors to their Reply and "View N replies" refs from a saved page snapshot | fb_snap.py SNAPSHOT_FILE [all|reply|view] |
none | ||
li_detail.py |
Fetch LinkedIn job details through the public guest API (no login) | li_detail.py JOB_ID [JOB_ID ...] [--out details.json] |
network, files | ||
li_search.py |
Search LinkedIn jobs through the public guest API (no login) | li_search.py "KEYWORDS" ["EXTRA=QUERY&PARAMS"] |
network | ||
loop_qc.py |
Measure whether an animation loops cleanly and plays at a sane speed | loop_qc.py ANIMATION [--fps 30] [--out QC_DIR] [--bg 1e2128] [--allow-boil] |
numpy, Pillow | files | |
make_index.py |
Write INDEX.json for a scripts folder |
make_index.py [--dir DIR] [--check | --print] |
files | ||
mklibanner.py |
Make the LinkedIn-size (1584x396) banner page from the 1500x500 banner page | mklibanner.py BANNER_HTML [OUT_HTML] |
files | ||
pace.py |
Facebook group pacing: which groups may take a post now, and record a post just made | pace.py [GROUPS_TSV] [--groups FILE] [--mark SLUG] |
files | ||
pr_review.py |
Prepare, run and clean up an independent read-only PR review (the Grok CLI by default) | pr_review.py {prep REPO PR | cmd CHECKOUT BRIEF | run CHECKOUT BRIEF OUT | done REPO PR} [options] |
git, gh, grok | files, network | |
render_carousel.py |
Render an HTML page to PNG slides with headless Chrome | render_carousel.py --html FILE --name NAME --count N --out DIR [--only N [N ...]] [--width 1080] [--height 1350] [--timeout 45] [--tries 3] [--chrome PATH] |
Chrome or Chromium | files | art |
render_short.py |
Run an explainer video pipeline's own shorts.py (not included) with each clip's audio edges moved to the narration's real word onsets |
render_short.py [--shorts-dir DIR] VIDEO_DIR [SHORTS_ARGS ...] |
numpy, ffmpeg, a shorts.py with window() and main() and what it needs (OpenCV, Pillow) |
files | |
run.py |
Run checklists (see Recipes and run checklists) | run.py {recipes,start,status,done,skip,finish,abandon,check,list} ... |
files | every recipe | |
wait_cpu.py |
Block until CPU load stays under a threshold for 3 checks in a row | wait_cpu.py [THRESHOLD_PERCENT] [MAX_MINUTES] [INTERVAL_SECONDS] |
none | ||
xintent.py |
Build an X intent URL for a new post or a reply, and report the post's weighted length | xintent.py STATUS_ID|0 "TEXT" |
none | ||
xsynd.py |
Recent original posts from X accounts, from the public syndication timeline (no login) | xsynd.py MAX_AGE_HOURS HANDLE [HANDLE ...] |
network | ||
xthread.py |
Show an X post's author, text and what it replies to, from the public syndication endpoint (no login) | xthread.py STATUS_ID [STATUS_ID ...] |
network | x-reply |
common.py holds the shared helpers (requests, TSV, time, X's weighted length, finding Chrome, the clipboard);
it isn't a command.
How the helpers behave:
-
Network. Every request goes through
common.fetch. A rate limit (HTTP 429), a server error (500, 502, 503, 504), a timeout or a dropped connection is retried up to twice, after a short wait or the server'sRetry-Afterwhen that is 15 seconds or less. A script exits 1 only when every request failed.li_search.pyalso exits 1 when LinkedIn answers with a login page instead of results. -
Clipboard.
clip.pyandclipimage.pygive up after a timeout instead of hanging when the clipboard tool doesn't answer. -
Chrome.
render_carousel.pyruns headless Chrome with a throwaway profile that it deletes afterwards, so it never touches your own Chrome profile and two renders can run at once.
A few of these read state files in playbook/state/:
-
bank.tsv, the post bank: one post per line,key<TAB>text<TAB>optional link,#lines are comments.bank.py checkflags posts too long for X (280, weighted) or Bluesky (300);bank.py x KEYprints an X intent link (link left out);bank.py b KEYa Bluesky compose link;bank.py text KEYthe raw text. -
groups.tsv, the Facebook groups clock:slug<TAB>name<TAB>mode<TAB>min_hours<TAB>last_post_utc. Modes:approval(default 6 hours between posts),open(4),own(1),strict(4, non-promo only),skip(never).pace.pylists which groups are ready;pace.py --mark SLUGrecords a post.audit.py gapand thepacingQC filter read the same file. The demo's file has only its header.
| Tool | Purpose | Usage | Needs | Effects |
|---|---|---|---|---|
image_gen.py |
Generate one image with Codex behind a quota check, and accept it only when it is the image asked for | image_gen.py "PROMPT" OUT.png [--ref IMAGE ...] [--aspect 16:9|3:2|1:1|9:16|any] [--min-side 800] [--alpha] [--tries 3] [--timeout 900] [--wait 10] [--max-used 95] [--no-quota] [--dry-run] [--codex PATH] |
Codex CLI (signed in), Pillow | network, files |
quota.py |
Say how much of the weekly Codex limit is used, and refuse a bulk image run when it is too high | quota.py [--max-used 80] [--max-age-hours 24] [--codex-home DIR] [--json] |
none | |
scenes.py |
Check a video's scene list, and generate its scene images with Codex |
scenes.py lint VIDEO_DIR [...] / scenes.py gen VIDEO_DIR --channel NAME [...]
|
Codex CLI and Pillow (gen only) | network, files |
mcommon.py holds the shared media helpers (ffmpeg, fonts, image measures); it isn't a command.
-
image_gen.py(used by the demo'sartflow) checks the result before it becomesOUT.png: it opens as an image, its shorter side is at least--min-side, its shape is within 5 percent of--aspect, it isn't one flat colour, and with--alphait has real transparency. A rejected try is kept asOUT.rejected-N.png. It writesOUT.txt(the prompt) andOUT.gen.json(hashes, tries, the quota reading). Prompts are ASCII only. -
quota.pyreads the newest rate-limit reading from Codex's session files and reports the weekly window (the one whose length is at least a week; that is the primary window today). It exits 1 at or above--max-usedpercent, or when there is no recent reading. The demo'sartflow runs it before any batch. -
scenes.pyworks on an explainer-video folder with a scene list;media/channels/holds four style presets (blueprint,chalkboard,notebook,parchment).
templates/carousel.html, templates/banner_li.html and templates/banner_fb.html are pages that
render_carousel.py renders to PNG. The demo's art flow renders a LinkedIn banner like this:
python scripts/render_carousel.py --html templates/banner_li.html --name banner --count 1 --width 1584 --height 396 --out <dir>| Variable | Used by | Default |
|---|---|---|
AGENT_PLAYBOOK_PORT |
launch.pyw, server.py
|
47321 |
AGENT_PLAYBOOK_ACTOR |
pb.py: the name its writes are recorded under in the change history |
agent |
AGENT_PLAYBOOK_CHROME |
render_carousel.py, doctor.py (anything that finds Chrome) |
Then CHROME_PATH, CHROME_BIN, the usual install folders, the Windows registry, PATH
|
CHROME_PATH, CHROME_BIN
|
Same, as fallbacks | |
AGENT_PLAYBOOK_BANK |
bank.py |
playbook/state/bank.tsv (a --bank flag wins) |
AGENT_PLAYBOOK_GROUPS |
pace.py |
playbook/state/groups.tsv (a file argument or --groups wins) |
AGENT_PLAYBOOK_OFFLINE |
Every script that makes requests through common.py
|
Unset. Set to 1 to make every request fail at once (the tests do this). |
AGENT_PLAYBOOK_FFMPEG, AGENT_PLAYBOOK_FFPROBE
|
Media tools |
ffmpeg, ffprobe on PATH
|
AGENT_PLAYBOOK_FONT_DIR |
Media tools, for bare font file names | Then the Windows Fonts folder, /Library/Fonts, /usr/share/fonts
|
AGENT_PLAYBOOK_EXPLAINER_DIR |
scenes.py |
The nearest folder above the video folder that holds <channel>/branding (a --explainer-dir flag wins) |
AGENT_PLAYBOOK_SHORTS_DIR |
render_short.py |
None: give --shorts-dir or set this |
CODEX_BIN |
codex_img.py, image_gen.py
|
codex on PATH (a --codex flag wins) |
CODEX_HOME |
codex_img.py, quota.py
|
~/.codex (a --codex-home flag wins for quota.py) |
GROK_BIN |
pr_review.py |
grok on PATH, then ~/.grok/bin/grok
|
LI_LOCATION, LI_GEOID
|
li_search.py |
United States, 103644278
|
Variables used only by the test suite: AGENT_PLAYBOOK_REQUIRE_MEDIA (turns a media test that would skip into a
failure; CI's media job sets it), AGENT_PLAYBOOK_TEST_NET_MARKER, AGENT_PLAYBOOK_TEST_HIDE_MODULES and
AGENT_PLAYBOOK_TEST_CLIPBOARD.
- Put it in
scripts/(standard library only) ormedia/(may import Pillow, numpy or call ffmpeg; check for them and exit 3 or 1 with the install line). - Give it a
build_parser()function that returnscommon.make_parser(__doc__, __file__, "PROG ..."): the docstring's first line becomes the purpose inINDEX.json, and the usage line is written by hand. DeclareNEEDS = [...](programs or modules it needs) andEFFECTS = [...](one or more ofnone,clipboard,network,files,browser) at the top.make_index.pyimports the script to read these, so importing it must not do anything. - Fail loudly with
common.die("message")(exit 1); a missing module withcommon.require("module")(exit 3). -
python scripts/make_index.py(or--dir media). - Name it in the flow step that uses it, with real arguments.
pb.py catalogthen lists it under the recipes that use that flow.
Agent Playbook is released under the MIT licence. Source: github.com/RandyNorthrup/agent-playbook