Add json/csv support to the posting script (issue #012)

TEXT_KINDS and TEXT_SUFFIXES now include json/csv, with matching
sniff_text_kind branches so both explicit --kind and positional auto-mode
work. Added validate_payload's JSON shape check mirroring the server.
Updated SKILL.md/docs/llm_posting_helper.md with real usage examples,
replacing the stale --as-markdown workaround guidance (kept only for
genuinely unstructured code, which still has no dedicated kind). Also
fixed an unrelated stale doc line found in the same table: html_full's
validation was documented as requiring <!doctype AND <html, but only
<html is actually required.

Verified via dry-run (explicit --kind, auto-mode, invalid-JSON rejection)
and one real end-to-end post through the script against the live dev
instance.

Added tests/scripts/test_daybook_post.py - 17 tests, plain unittest, zero
new dependencies, loaded via importlib since the script isn't a package.
Closes the test-coverage question the issue raised.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
peter 2026-09-02 15:38:47 +01:00
parent 532b4bd4eb
commit e137725cab
6 changed files with 177 additions and 8 deletions

View file

@ -56,10 +56,19 @@ python skills/daybook-posting/scripts/daybook_post.py --file diagram.svg --title
python skills/daybook-posting/scripts/daybook_post.py --file report.pdf --title "Generated Report"
```
Render CSV/JSON/code as Markdown today:
Post CSV or JSON as an interactive table/tree (auto-mode detects the kind
from the extension; explicit `--kind` works too):
```bash
python skills/daybook-posting/scripts/daybook_post.py --file results.csv --as-markdown --title "Results CSV"
python skills/daybook-posting/scripts/daybook_post.py results.csv
python skills/daybook-posting/scripts/daybook_post.py --kind json --title "Run Summary" --content-file summary.json
```
Render other code as a Markdown fenced block instead (no dedicated `code`
kind yet):
```bash
python skills/daybook-posting/scripts/daybook_post.py --file script.py --as-markdown --title "Generated Script"
```
Dry run:
@ -78,8 +87,9 @@ The helper validates common LLM mistakes before sending:
|---|---|
| `deck` | Must contain `<section`. |
| `html_fragment` | Must not contain `<!doctype`, `<html`, or `<body`. |
| `html_full` | Must contain `<!doctype` and `<html`. |
| `html_full` | Must contain `<html` (a `<!doctype` is recommended, not required). |
| `markdown` | Must not be blank. |
| `json` | Must be valid JSON (`json.loads` must succeed). |
| `.svg` upload | Forces `image/svg+xml`. |
| `.pdf` upload | Forces `application/pdf`. |