Skip to content

Recipes

m4bwav edited this page Nov 3, 2026 · 8 revisions

Real tasks, each run as shown on 2026-11-02 against 0.6.1 (commit 078613e). With the skills installed, an agent runs these steps itself when you ask in plain words; the commands are here for checking its work, or for using hw.py without an agent.

Check a date in an old English letter

A letter dated "11 February 1731" in England was written before 1752, when the legal year still began on 25 March, so by today's count it is 1732, in the Julian calendar. Pass the January-start year with O.S.:

python hw.py cal date "1732-02-11 O.S." --country GB

The Gregorian day, the dual year as written then, and the reason:

  "gregorian": {
   "iso": "1732-02-22",
   "label": "22 February 1732"
  },
  "islamic_tabular": {
   "ah": "1144-08-25",
   "note": "tabular; observed dates can differ by a day or two"
  },
  "civil_calendar": {
   "country": "GB",
   "calendar": "julian",
   "dual_year": "1731/32"
  },
  "os_ns": {
   "old_style": "11 February 1732",
   "new_style": "22 February 1732",
   "difference_days": 11
  },
  "notes": [
   "legal year began 25 March before 1752"
  ]

Full output: How dates are computed.

Work out how long a reign lasted

python hw.py cal span "1661-02-05" "1722-12-20"
{
 "ok": true,
 "start": "5 February 1661",
 "end": "20 December 1722",
 "days": 22597,
 "years": 61,
 "months": 10,
 "rest_days": 15,
 "calendar_for_y_m_d": "gregorian",
 "crosses_bc_ad": false,
 "note": null
}

Use accession and death dates, not the era name's span (why).

Check that a quote is in its source

The page must hold the words, exactly or after evening out case, quote marks, dashes and spaces:

python hw.py verify quote --url "https://penelope.uchicago.edu/Thayer/E/Roman/Texts/Suetonius/12Caesars/Julius*.html" --quote "He died in the fifty-sixth year of his age"
{
 "found": true,
 "match": "exact",
 "ok": true,
 "url": "https://penelope.uchicago.edu/Thayer/E/Roman/Texts/Suetonius/12Caesars/Julius*.html",
 "source_text": "fetched now"
}

"found": false means the page does not say it, whoever the quote is credited to.

In a book printed before about 1800, OCR reads the long s as f. Quote it in modern spelling; from 0.5.0 hw.py tries the f reading:

python hw.py verify quote --url "https://archive.org/download/youngmillwrightm00evan/youngmillwrightm00evan_djvu.txt" --quote "a sufficient guide to save thousands"
{
 "found": true,
 "match": "normalised, long s read as f (pre-1800 print)",
 "ok": true,
 "url": "https://archive.org/download/youngmillwrightm00evan/youngmillwrightm00evan_djvu.txt",
 "source_text": "fetched now"
}

Check a bibliography an AI wrote

Two checks catch most invented references. First, does each link exist?

python hw.py verify url "https://en.wikipedia.org/wiki/Julius_Caesar" "https://en.wikipedia.org/wiki/The_Fourth_Gallic_Diary_of_Caesar"

Read the label of each result; unknown means look again later, not "fine" (the labels). Second, does each DOI belong to the work it is cited for?

python hw.py doi 10.20381/ruor-23791 --title "The Gallic War and the Roman Army" --author Ficocelli --year 2019

The verdict is at the end:

 "match": {
  "title": false,
  "author": true,
  "year": true
 },
 "all_match": false,
 "warning": "the DOI exists but does not match every detail given: a blended or wrong reference"

Find what a Wikipedia sentence rests on

python hw.py wp refs "Microsoft" --near "April 4, 1975"

The sentence that holds the phrase, then its three footnotes (full output):

 "role": "finder: read each reference and cite it, not the article",
 "sentence": "Gates and Allen established Microsoft on April 4, 1975, with Gates as CEO, and Allen suggested the name \"Micro-Soft\", short for micro-computer software.",

Open each footnote's link and read it; cite the BBC timeline, the Fortune interview or Paul Allen's memoir, never the article.

Convert a Chinese era date

python hw.py cal cjk 崇禎三年四月初三

The third day of the fourth month of the third year of Chongzhen (崇禎) is:

   "era": "崇禎",
   "emperor": "思宗",
   "dynasty": "明",
   "country": "chinese",
   "era_year": 3,
   "year_ganzhi": "庚午",
   "month_name": "四月",
   "jdn": [
    2316539,
    2316539
   ],
   "western": [
    "14 May 1630",
    "14 May 1630"
   ]

The first run downloads DILA's tables (about 1.3 MB); after that, conversions are offline.

Use hw.py from your own script

Every command prints one JSON object, so a script can call hw.py and read the fields. reign.py, with HW_PY set to the path of hw.py:

import json
import os
import subprocess
import sys

HW = os.environ.get("HW_PY", "hw.py")


def hw(*args):
    p = subprocess.run([sys.executable, HW, *args], capture_output=True, text=True, encoding="utf-8")
    return json.loads(p.stdout)


spans = {"formal reign": ("1661-02-05", "1722-12-20"), "era name 康熙": ("1662-02-18", "1722-12-20")}
for name, (start, end) in spans.items():
    s = hw("cal", "span", start, end)
    print(f"{name}: {s['years']} years, {s['months']} months, {s['rest_days']} days ({s['days']} days)")
python reign.py
formal reign: 61 years, 10 months, 15 days (22597 days)
era name 康熙: 60 years, 10 months, 2 days (22219 days)

Check ok in real code: a refused input prints {"ok": false, "error": ...} and exits 1.

Clone this wiki locally