questcast 4.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dusten Harrison
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,629 @@
1
+ Metadata-Version: 2.4
2
+ Name: questcast
3
+ Version: 4.1.2
4
+ Summary: Drafts X and LinkedIn posts from an author profile and a topic chosen at run time.
5
+ Keywords: social-media,x,linkedin,drafts,cli
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: Environment :: Console
9
+ Classifier: Operating System :: MacOS
10
+ Classifier: Operating System :: iOS
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Topic :: Communications
15
+ Classifier: Topic :: Utilities
16
+ Requires-Dist: anthropic==2.9.0 ; extra == 'anthropic'
17
+ Requires-Python: >=3.13
18
+ Project-URL: Homepage, https://github.com/BearingQuest/questcast
19
+ Project-URL: Source, https://github.com/BearingQuest/questcast
20
+ Project-URL: Changelog, https://github.com/BearingQuest/questcast/blob/master/CHANGELOG.md
21
+ Project-URL: Issues, https://github.com/BearingQuest/questcast/issues
22
+ Provides-Extra: anthropic
23
+ Description-Content-Type: text/markdown
24
+
25
+ <p align="center">
26
+ <a href="https://bearingquest.com">
27
+ <picture>
28
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/BearingQuest/questcast/master/docs/readme/bearing-quest-lockup-on-dark.svg">
29
+ <img alt="Bearing Quest" src="https://raw.githubusercontent.com/BearingQuest/questcast/master/docs/readme/bearing-quest-lockup-on-light.svg" width="220">
30
+ </picture>
31
+ </a>
32
+ </p>
33
+
34
+ <h1 align="center">QuestCast</h1>
35
+
36
+ <p align="center">
37
+ Daily X and LinkedIn post drafts from one recent source, in your voice.<br>
38
+ Part of the <a href="https://bearingquest.com">Bearing Quest</a> project family.
39
+ </p>
40
+
41
+ <p align="center">
42
+ <a href="https://github.com/BearingQuest/questcast/actions/workflows/ci.yml"><img alt="CI status" src="https://github.com/BearingQuest/questcast/actions/workflows/ci.yml/badge.svg?branch=master"></a>
43
+ <a href="https://scorecard.dev/viewer/?uri=github.com/BearingQuest/questcast"><img alt="OpenSSF Scorecard" src="https://api.scorecard.dev/projects/github.com/BearingQuest/questcast/badge"></a>
44
+ <a href="https://github.com/BearingQuest/questcast/blob/master/LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-1B365D"></a>
45
+ <img alt="Python 3.13 or newer" src="https://img.shields.io/badge/python-3.13+-1B365D">
46
+ </p>
47
+
48
+ Pick a technology topic, and this finds one noteworthy recent item on it and
49
+ drafts two social posts from that same source: a short one for X and a longer,
50
+ opinionated one for LinkedIn. By default it runs on Groq's free tier, where one
51
+ call both searches the web and writes the posts. Anthropic's Claude, or any
52
+ OpenAI-compatible endpoint, can be swapped in with a flag, and RSS feeds you
53
+ choose can replace the web search.
54
+
55
+ > [!IMPORTANT]
56
+ > Human-in-the-loop by default. Nothing is published unless you click Post yourself in X's compose box or LinkedIn's post box (`--post`, `--post-linkedin` and `--post-all` only open them); read each draft first.
57
+
58
+ The posts sound like *you* because of a profile file you write once and keep
59
+ outside this repo. That file is the whole idea: the code is a small harness,
60
+ and the profile is where the topics, the voice, the point of view, and the
61
+ guardrails live.
62
+
63
+ ## How it works
64
+
65
+ <img alt="Terminal demo: qc --help, then qc --list-topics showing a three-topic menu from a made-up profile." src="https://raw.githubusercontent.com/BearingQuest/questcast/master/docs/readme/demo.gif" width="720">
66
+
67
+ ```mermaid
68
+ flowchart LR
69
+ subgraph Mac["Your computer"]
70
+ PR["Author profile<br/>(outside the repo)"] --> T["Topic menu"]
71
+ T --> RUN["qc"]
72
+ RUN --> DR["drafts.md and run.log"]
73
+ DR --> YOU{"You review"}
74
+ end
75
+ RUN <-->|"one search-and-write call<br/>(or RSS feeds you choose)"| API["Groq, Anthropic or<br/>OpenAI-compatible API"]
76
+ YOU -. "Post on X / Post on LinkedIn links" .-> PUB["X / LinkedIn"]
77
+ ```
78
+
79
+ Each run:
80
+
81
+ 1. Asks which topic to cover — a numbered menu from your profile's `## Topics`
82
+ section, or a built-in catalog of common IT areas. `--topic` skips the
83
+ prompt, `--random-topic` rolls the dice.
84
+ 2. Searches the web for a substantive recent item in that area, filtered by
85
+ your **beat**: what counts as a good find, what to exclude, who it is for.
86
+ With `--search rss` it chooses from your feeds' newest entries instead.
87
+ 3. Skips anything already used, by URL or by title, tracked in `history.json`.
88
+ 4. Writes two posts from that one source. The X version reports; the LinkedIn
89
+ version argues — it takes a position, says what the item does not solve,
90
+ and ends with a question worth answering.
91
+ 5. Prints both drafts and appends them to `drafts.md` with the topic, source,
92
+ and a one-line rationale for the pick.
93
+ 6. Logs the outcome, success or failure, to `run.log`.
94
+
95
+ ## Requirements
96
+
97
+ - Python 3.13 or newer
98
+ - macOS and Linux with Python 3.13+; iPhone via a-Shell with native search only (see
99
+ [iPhone (a-Shell)](#iphone-a-shell))
100
+ - A free Groq API key — https://console.groq.com/keys
101
+ - Nothing else for the default setup: the `groq` and `openai-compat` providers
102
+ use only the standard library. `--provider anthropic` needs the `anthropic`
103
+ extra, pinned in `pyproject.toml`; see [Optional extras](#optional-extras).
104
+
105
+ ## Install
106
+
107
+ Install the `qc` command from a tagged release (Python 3.13 or newer; `uv`
108
+ fetches it if you don't have it). Releases are listed at
109
+ https://github.com/BearingQuest/questcast/releases.
110
+
111
+ ```bash
112
+ # uv, from the tag (needs git):
113
+ uv tool install git+https://github.com/BearingQuest/questcast@v4.1.2
114
+ # pipx, from the tag:
115
+ pipx install --python python3.14 git+https://github.com/BearingQuest/questcast@v4.1.2
116
+
117
+ # or from the release's wheel:
118
+ uv tool install https://github.com/BearingQuest/questcast/releases/download/v4.1.2/questcast-4.1.2-py3-none-any.whl
119
+ pipx install --python python3.14 https://github.com/BearingQuest/questcast/releases/download/v4.1.2/questcast-4.1.2-py3-none-any.whl
120
+ ```
121
+
122
+ **First run.** Create the data directory and a profile to fill in, and the key
123
+ file, private from the start. Don't put the key on a command line: it would
124
+ stay in your shell history.
125
+
126
+ ```bash
127
+ qc init # creates ~/QuestCast and author_profile.md
128
+ (umask 077; touch ~/.qc_post_env) # empty file, readable only by you
129
+ ls -l ~/.qc_post_env # -rw-------
130
+ ```
131
+
132
+ Open `~/.qc_post_env` in an editor and add one line, with your own key from
133
+ https://console.groq.com/keys:
134
+
135
+ ```
136
+ GROQ_API_KEY=<your key>
137
+ ```
138
+
139
+ Then fill in `## Beat` and `## Voice` in `~/QuestCast/author_profile.md`
140
+ (see [Setup](#setup), step 3) and run `qc`.
141
+
142
+ **Upgrade** to a new release by installing its tag over the old one:
143
+
144
+ ```bash
145
+ uv tool install --reinstall git+https://github.com/BearingQuest/questcast@v<new version>
146
+ pipx install --force --python python3.14 git+https://github.com/BearingQuest/questcast@v<new version>
147
+ ```
148
+
149
+ **Uninstall:**
150
+
151
+ ```bash
152
+ uv tool uninstall questcast # or: pipx uninstall questcast
153
+ ```
154
+
155
+ Your data folder, profile and key file are not touched; delete them by hand
156
+ if you want them gone.
157
+
158
+ **Verify a download.** Each release's wheel, source archive and SBOM carry a
159
+ build-provenance attestation. For a file you downloaded from the release (not
160
+ for an install from git), check it with the GitHub CLI:
161
+
162
+ ```bash
163
+ gh attestation verify questcast-4.1.2-py3-none-any.whl -R BearingQuest/questcast
164
+ ```
165
+
166
+ ## Setup
167
+
168
+ There are two ways to run it:
169
+
170
+ - **Installed, as the `qc` command.** See [Install](#install). Once installed,
171
+ `qc init` creates your data directory and a profile to fill in, and `qc`
172
+ takes the same flags as `daily_post.py` below.
173
+ - **From a clone of this repo**, with `python daily_post.py`. The steps below
174
+ cover this path; every command works the same as `qc`.
175
+
176
+ **1. Virtual environment.** Required on Homebrew and modern-distro Pythons,
177
+ which block system-wide pip installs per PEP 668. Nothing needs installing for
178
+ the default provider:
179
+
180
+ ```bash
181
+ python3 -m venv ~/.qc_post_venv
182
+ # only if you will use --provider anthropic, run from the clone:
183
+ ~/.qc_post_venv/bin/pip install -e '.[anthropic]'
184
+ ```
185
+
186
+ **2. API key**, in a protected file outside the repo:
187
+
188
+ ```bash
189
+ (umask 077; touch ~/.qc_post_env) # private from the start; ls -l shows -rw-------
190
+ ```
191
+
192
+ Then open it in an editor and add `GROQ_API_KEY=<your key>`, so the key never
193
+ sits in your shell history. Use `ANTHROPIC_API_KEY` instead (from https://console.anthropic.com/settings/keys)
194
+ if you run `--provider anthropic`.
195
+
196
+ The script loads this at startup. An already-set environment variable wins,
197
+ which is handy for one-off overrides. The `export` prefix is optional but lets
198
+ the same file double as a shell-sourceable env file.
199
+
200
+ **3. Author profile — the important step.** Create it from the scaffold, then
201
+ fill it in:
202
+
203
+ ```bash
204
+ ~/.qc_post_venv/bin/python daily_post.py init # installed: qc init
205
+ ```
206
+
207
+ This creates the data directory (`~/QuestCast`, or `QC_POST_DATA_DIR`) with mode
208
+ 700 if it doesn't exist, and copies `questcast/author_profile.example.md`
209
+ there as `author_profile.md`, with mode 600. It never overwrites an existing
210
+ profile: if one is there, it says so and exits without changing anything.
211
+
212
+ The scaffold explains each section:
213
+
214
+ | Section | What it does |
215
+ |---|---|
216
+ | `## Topics` | Your run-time menu of technology areas. Omit it to use the built-in catalog |
217
+ | `## Beat` | What makes an item worth posting *whatever* the topic: quality bar, exclusions, audience |
218
+ | `## Voice` | How you think and sound — your actual positions, plus real sentences you wrote |
219
+ | `## Experience` | Things you have really done that posts may reference, with a guardrail capping it at one per post |
220
+ | `## Never` | Hard rules: no employer names, no invented hands-on claims, whatever would misrepresent you |
221
+ | `## Hashtags` | A pool to draw from |
222
+ | `## Feeds` | RSS or Atom feed URLs, one per line. Used only with `--search rss` |
223
+
224
+ Beat and Voice are required. Spend your time on **Voice** — and especially on
225
+ pasting a handful of sentences you actually wrote. A description of your tone
226
+ produces competent generic prose; real samples give the model a cadence to
227
+ imitate. **Never** is what keeps a model trying to sound expert from inventing
228
+ credentials on your behalf.
229
+
230
+ Keep this file out of version control — it is personal, and it is already in
231
+ `.gitignore`.
232
+
233
+ ## iPhone (a-Shell)
234
+
235
+ Dusten tested this on an iPhone, in [a-Shell](https://apps.apple.com/app/id1473805438) with its
236
+ Python 3.13. On 26 Nov 2026 he tested QuestCast 4.1.1: he installed the v4.1.1 wheel and ran
237
+ `qc --search native --random-topic --post-all`. X's app opened with the draft; back in a-Shell it
238
+ showed "Press Return to open LinkedIn's post box (Ctrl-C to skip)."; Return opened LinkedIn in
239
+ Safari with the draft filled in. The Shortcut was tested on 4.0.0 on 25 Nov 2026 (3.1.1 was
240
+ tested first, the same day) and was not re-run on 4.1.1. It is tested, not supported: CI can't
241
+ run a-Shell. iPad is untested.
242
+
243
+ - **Install.** `pip install https://github.com/BearingQuest/questcast/releases/download/v4.1.2/questcast-4.1.2-py3-none-any.whl`.
244
+ The `qc` command then works in a-Shell. Verifying the download with `gh attestation verify`
245
+ (see [Install](#install)) happens on a computer.
246
+ - **Settings.** Only `Documents` is writable in a-Shell, so QuestCast's default folders can't be
247
+ created. Put two lines in `~/Documents/.profile`, which a-Shell runs when it opens:
248
+
249
+ ```bash
250
+ export QC_POST_DATA_DIR="$HOME/Documents/QuestCast"
251
+ export QC_POST_ENV_FILE="$HOME/Documents/.qc_post_env"
252
+ ```
253
+
254
+ Then run `qc init`.
255
+ - **Key.** Create `~/Documents/.qc_post_env` in an editor (`vim`) with one line,
256
+ `GROQ_API_KEY=<your key>`. Use a separate key for the phone, so it can be revoked on its own.
257
+ - **Profile.** Copy your `author_profile.md` into a-Shell's `Documents/QuestCast` (AirDrop or Files).
258
+ Replace the example profile from `qc init` before your first run; it won't produce a draft.
259
+ - **Search.** Native only (`--search native`). a-Shell's Python has Expat 2.6.4, and `--search rss`
260
+ needs 2.7.2 or newer to protect against entity-expansion attacks in feed XML. Keep a-Shell in
261
+ front while it runs.
262
+ - **Shortcut.** In Shortcuts, a Text action with three lines (the two `export` lines above, then
263
+ `qc --search native --random-topic`), followed by a-Shell's Execute Command action. To put it on the
264
+ Home Screen, follow Apple's guide:
265
+ https://support.apple.com/guide/shortcuts/add-a-shortcut-to-the-home-screen-apd735880972/ios
266
+ - **History.** The phone keeps its own history, so duplicate checks don't span the phone and a
267
+ computer.
268
+ - **Post on X and LinkedIn.** On the iPhone, `--post` opens the X app with the draft,
269
+ `--post-linkedin` opens LinkedIn in Safari with the text filled in, and `--post-all` opens X, then
270
+ pauses with "Press Return to open LinkedIn's post box (Ctrl-C to skip)." before opening LinkedIn.
271
+ iOS drops a second open made while a-Shell is in the background, which is why it pauses. The
272
+ Shortcut above has no terminal to answer on, so with `--post-all` it opens X and prints the
273
+ LinkedIn link to copy. If a browser opens nowhere, QuestCast prints the full link on its own line.
274
+ The links are always in `drafts.md`.
275
+
276
+ ## Optional extras
277
+
278
+ The Anthropic SDK for `--provider anthropic` is an optional extra, `anthropic`,
279
+ so the default install stays standard library only. Its exact version is pinned
280
+ in `pyproject.toml`. Install it from the repo clone, the route matching how you
281
+ run it:
282
+
283
+ ```bash
284
+ # Installed qc command:
285
+ uv tool install --reinstall '.[anthropic]'
286
+ # A repo clone's virtual environment:
287
+ ~/.qc_post_venv/bin/pip install -e '.[anthropic]'
288
+ ```
289
+
290
+ `uv tool install --reinstall` replaces the whole tool environment, so a later
291
+ `uv tool install --reinstall .` without the extra drops it. In the venv, `-e`
292
+ links the install to this clone: `daily_post.py` and the venv both use the
293
+ clone's code, so a `git pull` needs no reinstall unless the pin in
294
+ `pyproject.toml` changes.
295
+
296
+ ## Usage
297
+
298
+ ```bash
299
+ ~/.qc_post_venv/bin/python daily_post.py
300
+ ```
301
+
302
+ You get a topic menu, then both drafts print to the terminal and land in
303
+ `~/QuestCast/drafts.md`. Review, edit, post them yourself. Run whenever you like —
304
+ dedup makes irregular timing safe, and a second run the same day simply picks a
305
+ different item.
306
+
307
+ | Flag | Effect |
308
+ |---|---|
309
+ | *(none)* | Interactive topic menu, then draft both posts. The default |
310
+ | `--topic X` | Menu number, part of a menu entry, or free text not in the menu at all |
311
+ | `--random-topic` | Pick from the menu at random |
312
+ | `--list-topics` | Show the menu and exit |
313
+ | `--history` | Show the last 10 items used, with their topics |
314
+ | `--profile PATH` | Use a different profile file — handy for running more than one persona |
315
+ | `--provider NAME` | `groq`, `anthropic` or `openai-compat`. Default: `QC_POST_PROVIDER`, else `groq` |
316
+ | `--search SOURCE` | `native` or `rss`. Default: `QC_POST_SEARCH`, else `native` for `groq` and `anthropic`, `rss` for `openai-compat` |
317
+ | `--post` | Open X's compose box with the X draft filled in; nothing is posted until you click Post (see below) |
318
+ | `--post-linkedin` | Open LinkedIn's post box with the LinkedIn draft filled in; nothing is posted until you click Post (see below) |
319
+ | `--post-all` | Open both boxes, X first, then LinkedIn; the same as `--post --post-linkedin` |
320
+
321
+ For a shorter daily command, keep a wrapper outside the repo, e.g.
322
+ `~/QuestCast/qcpost.sh`:
323
+
324
+ ```bash
325
+ #!/usr/bin/env bash
326
+ set -euo pipefail
327
+ exec "$HOME/.qc_post_venv/bin/python" "/path/to/daily_post.py" "$@"
328
+ ```
329
+
330
+ `chmod +x` it once, then each day is `~/QuestCast/qcpost.sh` — and arguments pass
331
+ straight through, so `~/QuestCast/qcpost.sh --topic kubernetes` works too.
332
+
333
+ ### Providers and search
334
+
335
+ | Provider | Model | Native search | Credential |
336
+ |---|---|---|---|
337
+ | `groq` (default) | `openai/gpt-oss-120b`, or `GROQ_MODEL` | Groq's `browser_search` tool | `GROQ_API_KEY` |
338
+ | `anthropic` | `claude-sonnet-4-6` | Anthropic's `web_search` tool | `ANTHROPIC_API_KEY` |
339
+ | `openai-compat` | `OPENAI_COMPAT_MODEL` | None; uses `--search rss` | `OPENAI_COMPAT_API_KEY`, if the service needs one |
340
+
341
+ `openai-compat` reaches Gemini, Cerebras or a local Ollama server with no code
342
+ change: set `OPENAI_COMPAT_BASE_URL` to the endpoint up to `/v1` (https only;
343
+ plain http is allowed for `localhost`) and `OPENAI_COMPAT_MODEL` to its model
344
+ name. A missing credential stops the run with the variable to set; the script
345
+ never falls back to another provider.
346
+
347
+ With `--search rss`, the script reads the feeds in your profile's `## Feeds`
348
+ section and the model chooses from their newest entries, without searching the
349
+ web. Feed text is passed to the model as clearly marked data, never as
350
+ instructions. Feeds must be `https://`; a feed that redirects to plain `http://`,
351
+ fails, or isn't valid RSS or Atom is logged to `run.log` and skipped, and the
352
+ run fails only if no feed has a new entry. RSS needs Python's Expat XML library
353
+ at 2.7.2 or newer, which current Python releases include; the script checks
354
+ and exits with both versions if it isn't.
355
+
356
+ **Groq free plan.** Whether the free plan allows `browser_search`, and whether
357
+ one search call fits its tokens-per-minute limit, is not published. If a
358
+ `--provider groq` run is refused or rate limited, run
359
+ `--provider groq --search rss` instead: Groq then only writes the posts, from
360
+ your feeds.
361
+
362
+ Environment variables (set them in `~/.qc_post_env` or the shell; a value already set in
363
+ the shell wins, and `QC_POST_ENV_FILE` works only from the shell). Only the
364
+ `QC_POST_*` names are read. An old `AI_POST_*` name stops the run; see
365
+ "Upgrading to 4.0" below:
366
+
367
+ | Variable | Default | Effect |
368
+ |---|---|---|
369
+ | `QC_POST_PROVIDER` | `groq` | Provider when `--provider` isn't given |
370
+ | `QC_POST_SEARCH` | `native` for `groq` and `anthropic`, `rss` for `openai-compat` | Search source when `--search` isn't given |
371
+ | `GROQ_API_KEY` | none | Groq key, from https://console.groq.com/keys |
372
+ | `GROQ_MODEL` | `openai/gpt-oss-120b` | Groq model |
373
+ | `ANTHROPIC_API_KEY` | none | Anthropic key, for `--provider anthropic` |
374
+ | `OPENAI_COMPAT_BASE_URL` | none | Endpoint up to `/v1`, for `--provider openai-compat` |
375
+ | `OPENAI_COMPAT_MODEL` | none | Model name, for `--provider openai-compat` |
376
+ | `OPENAI_COMPAT_API_KEY` | none | Key for that service; not needed for local Ollama |
377
+ | `QC_POST_PROVIDER_TIMEOUT` | `120` | Seconds to wait for a response. Applies to `groq` and `openai-compat` only; `anthropic` keeps its SDK's own timeout. Feed requests always time out after 15 seconds |
378
+ | `QC_POST_RSS_PER_FEED` | `3` | Newest entries taken from each feed with `--search rss` |
379
+ | `QC_POST_RSS_MAX_ENTRIES` | `20` | Most candidates sent to the model with `--search rss`, after the per-feed cap. Entries matching more of the topic's words go first, then newer ones. Lower it if Groq returns 413 |
380
+ | `QC_POST_TOKEN_BUDGET` | `7000` | Most estimated prompt tokens with `--search rss`. The lowest-ranked entries are dropped until the prompt fits, after the `QC_POST_RSS_MAX_ENTRIES` cap. See "Rate limits and progress" below |
381
+ | `QC_POST_RATE_LIMIT_WAIT` | `60` | Longest wait, in seconds, that `groq` and `openai-compat` will sit out on a 429 before retrying once. `0` turns the retry off |
382
+ | `QC_POST_DATA_DIR` | `~/QuestCast` | Where the profile, drafts, history and run log live |
383
+ | `QC_POST_ENV_FILE` | `~/.qc_post_env` | The key file loaded at startup. Read from the shell environment only: the file can't name its own location, so setting it inside the file has no effect |
384
+
385
+ ### Rate limits and progress
386
+
387
+ Groq's free plan allows 8,000 tokens a minute. A run that hits that limit
388
+ gets HTTP 429 with a suggested wait. If the wait is at most
389
+ `QC_POST_RATE_LIMIT_WAIT` seconds (default 60), the run counts it down on
390
+ the terminal, for example "Groq's per-minute token limit: retrying in 27 s
391
+ (Ctrl+C to cancel)", and then sends the same request once more. A second
392
+ 429, a longer wait (a daily limit, say) or no suggested wait stops with the
393
+ usual message, and nothing is saved. A 413 (one request over the limit on
394
+ its own) is never retried. `--provider anthropic` keeps its SDK's own retry
395
+ policy.
396
+
397
+ While a provider works on its answer, the run shows the seconds elapsed and
398
+ then how long it took. On a terminal the line updates in place; when output
399
+ goes to a file or a pipe, there is one line before and one after. Progress
400
+ goes to stderr only, never to `run.log`.
401
+
402
+ With `--search rss`, the run estimates the size of the whole prompt (UTF-8
403
+ bytes divided by 4, which tends to over-count a little) and drops the
404
+ lowest-ranked feed entries until it is within `QC_POST_TOKEN_BUDGET`. It
405
+ says so when it does, for example "Sending 6 of 20 feed entries to fit the
406
+ token budget". The profile's Beat, Voice, Experience, Never and Hashtags
407
+ sections go into every prompt, so a long profile leaves room for fewer
408
+ entries. If not even one entry fits, the run stops and gives the size of
409
+ those sections. After a `groq` or `openai-compat` run, the `OK` line in
410
+ `run.log` records the provider's token counts beside the estimate, for
411
+ example `tokens: prompt 5723, completion 812, total 6535, estimate 5890`,
412
+ so you can check the estimate against them. A `FAILED` line has them too
413
+ when the provider answered. With `--search native`, the estimate is of the
414
+ prompt before search, so the gap shows how much the search results added.
415
+
416
+ If a `groq` or `openai-compat` reply has no text, the `FAILED` line says
417
+ why as far as the reply shows: its `finish_reason`, how many characters of
418
+ reasoning it held, and how many tool calls, with their names. It never
419
+ holds the reasoning, the tool arguments or the prompt. Re-run, and if it
420
+ happens again, send that line.
421
+
422
+ ### Post on X
423
+
424
+ Every run writes a Markdown link into that run's `drafts.md` entry, under `## X`:
425
+
426
+ ```text
427
+ [Post on X](https://x.com/intent/tweet?text=...)
428
+ ```
429
+
430
+ The screen doesn't print the link. After the drafts it prints one line saying the
431
+ compose links are in `drafts.md`, and that `--post`, `--post-linkedin` or `--post-all`
432
+ opens them.
433
+
434
+ The link is X's [web intent](https://docs.x.com/x-for-websites/post-button/guides/web-intent):
435
+ it opens the compose box with the draft filled in, source link included. You
436
+ edit it and click Post. `--post` opens that link in your browser for you, once,
437
+ after the drafts are saved and prints `Opened X's compose box.` If no browser
438
+ opens, QuestCast prints `No browser opened; to post on X, open this link:` and then
439
+ the full link on its own line, so you can copy it. QuestCast never posts to X itself and needs no X key: X's API
440
+ has no free tier for new developers, and a post with a URL costs $0.20
441
+ (`docs/decisions.md`). Because you post, the history records `posted_x` as
442
+ `false` for new runs.
443
+
444
+ ### Post on LinkedIn
445
+
446
+ Every run writes a Markdown link into that run's `drafts.md` entry, under `## LinkedIn`:
447
+
448
+ ```text
449
+ [Post on LinkedIn](https://www.linkedin.com/feed/?shareActive=true&text=...)
450
+ ```
451
+
452
+ The link opens LinkedIn's post box with the draft filled in. You edit it and click
453
+ Post. `--post-linkedin` opens that link in your browser for you, once, after the
454
+ drafts are saved and prints `Opened LinkedIn's post box.`; `--post-all` opens the X
455
+ link and then this one. If no browser opens, QuestCast prints
456
+ `No browser opened; to post on LinkedIn, open this link:` and then the full link on
457
+ its own line, so you can copy it. QuestCast never posts to LinkedIn itself and needs no LinkedIn app, token or key.
458
+
459
+ LinkedIn documents a share plugin that takes a URL only
460
+ ([share plugin](https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/plugins/share-plugin)).
461
+ The `shareActive=true&text=` link is not documented, so LinkedIn could change it. If
462
+ LinkedIn opens an empty post box, the draft is on screen and in `drafts.md`: copy it
463
+ from there. Because you post, the history records `posted_linkedin` as `false` for
464
+ new runs.
465
+
466
+ ### Optional: scheduling
467
+
468
+ Unattended runs need a topic, since there is no terminal to ask on — the script
469
+ says so rather than hanging:
470
+
471
+ ```cron
472
+ 0 8 * * * $HOME/.qc_post_venv/bin/python /path/to/daily_post.py --random-topic >> $HOME/QuestCast/cron.log 2>&1
473
+ ```
474
+
475
+ Env-file loading means no key handling in the crontab. On laptops that sleep,
476
+ `anacron` (Linux) or `launchd` (macOS) give "run once a day whenever awake"
477
+ semantics instead.
478
+
479
+ ## Files
480
+
481
+ In the repo:
482
+
483
+ | File | Purpose |
484
+ |---|---|
485
+ | `daily_post.py` | Runs the generator from a clone; a few lines that call the package |
486
+ | `questcast/` | The generator, as a package. Installed, it provides the `qc` command |
487
+ | `questcast/author_profile.example.md` | Scaffold that `qc init` copies; fill it in |
488
+ | `scripts/install-check.sh` | Builds and installs the package in a clean environment and checks `qc init` (`make install-check`) |
489
+ | `tests/` | Unit and acceptance tests, run with `make check`; no network needed |
490
+ | `docs/decisions.md` | Owner decisions and recorded departures |
491
+
492
+ In your data directory (`~/QuestCast` by default, override with
493
+ `QC_POST_DATA_DIR`):
494
+
495
+ | File | Purpose |
496
+ |---|---|
497
+ | `author_profile.md` | Your topics and voice. You write this; the script only reads it |
498
+ | `drafts.md` | Every draft generated, with date, topic, title, rationale, and the provider and search source used |
499
+ | `history.json` | URLs and titles already used — dedup across runs — with the provider, model and search source of each |
500
+ | `run.log` | One timestamped line per run, ending with the provider and search source |
501
+
502
+ ## Development
503
+
504
+ The dev tools (pytest, pytest-cov, ruff, mypy, pip-audit) are pinned in
505
+ `uv.lock`, along with the optional `anthropic` extra; the script itself still
506
+ needs nothing beyond the standard library.
507
+ With [uv](https://docs.astral.sh/uv/) installed:
508
+
509
+ ```bash
510
+ uv sync # Python from .python-version, plus the dev tools from uv.lock
511
+ make check # ruff check, ruff format --check, mypy, pytest with coverage
512
+ make audit # pip-audit against the locked dependencies, optional extras included
513
+ make sbom # CycloneDX SBOM of the default install's runtime dependencies, to build/sbom.cdx.json
514
+ make install-check # build, check the wheel's extras, install into a clean venv, check qc --help and qc init, and that no xgp command is installed
515
+ ```
516
+
517
+ ### Security checks
518
+
519
+ Every pull request to master runs three more checks (`.github/workflows/security.yml`):
520
+ `gitleaks` scans the git history for secrets, `semgrep` runs the `p/default`
521
+ rules, and `pip-audit` runs `make audit`. gitleaks and Semgrep findings also
522
+ appear in the repo's Security tab. `pip-audit (daily)` runs the same audit on
523
+ master every day, so an advisory against a locked version shows up between
524
+ pull requests. Both audits cover the optional extras. Dependabot proposes weekly updates for `uv.lock` and the
525
+ pinned actions.
526
+
527
+ `.claude/settings.json` holds the agent rules for Claude Code: it disables
528
+ auto and bypass-permissions modes; denies merges, PR reviews and comments,
529
+ force-pushes, amends, rebases, tags, publishing with `--post`,
530
+ `--post-linkedin` or `--post-all`, and edits to the frozen tests; and asks before every push,
531
+ `gh pr`, `gh api` and `python3` call. The rules match command text, so they
532
+ are a guardrail, not a sandbox. Only Dusten edits it.
533
+
534
+ Each push to master uploads the SBOM as a workflow artifact named
535
+ `sbom-<commit SHA>` (`.github/workflows/sbom.yml`, kept 90 days); download it
536
+ from that run on the Actions tab. It covers the default install only: the
537
+ optional `anthropic` extra and the dev tools are not in it.
538
+
539
+ Pushing a `v*` tag runs `.github/workflows/release.yml`, which builds the wheel
540
+ and the source archive, writes the same SBOM, attests all three and opens a
541
+ draft GitHub release; the release is published by hand. The release notes are
542
+ the tag's section of `CHANGELOG.md`.
543
+
544
+ ## Design notes
545
+
546
+ **Why the topic is chosen per run rather than fixed.** A single hardcoded
547
+ subject produces a monotonous feed and burns through the good material in that
548
+ niche fast. Picking per run lets one profile cover a whole professional range,
549
+ and `--random-topic` keeps it varied without a decision every morning.
550
+
551
+ **Why a profile file instead of constants in the script.** Voice, guardrails,
552
+ topics, and beat are the parts that differ per person and change most often.
553
+ Keeping them in plain text means you can edit your voice without touching code,
554
+ run several personas off one script with `--profile`, and share the code
555
+ without sharing anything personal.
556
+
557
+ **Why LinkedIn drafts are flagged rather than truncated.** X posts are
558
+ hard-trimmed at a sentence boundary because the platform enforces the limit
559
+ anyway. A LinkedIn post trimmed from the end loses its closing question and
560
+ hashtags — the two things you least want to lose — so an overlong draft prints
561
+ a warning and its character count, and you shorten it during review.
562
+
563
+ **Why the experience guardrail is worded so bluntly.** A model asked to write
564
+ as an experienced practitioner will produce plausible-sounding credentials it
565
+ was never given. Capping references at one per post and forbidding anything
566
+ outside the list is what keeps the output honest — and it matters more once
567
+ topics vary, since some days will land outside your deepest expertise.
568
+
569
+ ## Upgrading to 4.0
570
+
571
+ QuestCast was XGeneratePosts. 4.0 removes the old names: the `xgp` command (use `qc`), every
572
+ `AI_POST_*` setting, and the `~/XPosts` and `~/.ai_post_env` locations. They are never read
573
+ again. Instead `qc` stops, with exit status 1, before it reads your profile or writes
574
+ anything, so nobody silently loses history, a key or a provider choice. It stops when:
575
+
576
+ - an `AI_POST_<NAME>` setting is set, in the shell or in the key file, even if `QC_POST_<NAME>`
577
+ is set too;
578
+ - `QC_POST_DATA_DIR` is unset, `~/XPosts` exists and `~/QuestCast` doesn't;
579
+ - `QC_POST_ENV_FILE` is unset, `~/.ai_post_env` exists and `~/.qc_post_env` doesn't.
580
+
581
+ One message lists every problem, with names and paths only, never values, and what to do
582
+ about each. `qc --help` still works. If both the old and the new folder (or key file) exist,
583
+ the new one is used and nothing is said. Nothing is moved for you. Run these once:
584
+
585
+ ```bash
586
+ # 0. find anything scheduled that still uses the old paths, and update it after step 1
587
+ crontab -l 2>/dev/null | grep -n 'XPosts\|aipost\|AI_POST_'
588
+ grep -rl 'XPosts\|aipost\|AI_POST_' ~/Library/LaunchAgents 2>/dev/null
589
+
590
+ # 1. the data folder; refuses if ~/QuestCast already exists, because mv would nest it
591
+ if [ -e ~/QuestCast ]; then echo "~/QuestCast already exists: stop and merge by hand"; else mv ~/XPosts ~/QuestCast; fi
592
+
593
+ # 2. the key file; -n never overwrites an existing file, and mv keeps its mode
594
+ mv -n ~/.ai_post_env ~/.qc_post_env
595
+ ls -l ~/.qc_post_env ~/.ai_post_env 2>&1 # new file shows -rw-------; old one should be gone
596
+ ```
597
+
598
+ Scripts kept in the data folder (such as a wrapper) move with it; update any paths and
599
+ `AI_POST_` names inside them, and in any cron or LaunchAgent entry found in step 0. A wrapper
600
+ called `aipost.sh` can be renamed `qcpost.sh`.
601
+
602
+ 3. In your shell profile (and any cron or wrapper script), rename `AI_POST_` to
603
+ `QC_POST_`, for example `AI_POST_PROVIDER` to `QC_POST_PROVIDER`. Do the same
604
+ inside the key file if you set any there.
605
+ 4. If you made a clone-path venv, recreate it as `~/.qc_post_venv` (step 1 of
606
+ Setup). The old `~/.ai_post_venv` can then be deleted.
607
+ 5. Use `qc` in place of `xgp`.
608
+
609
+ If you would rather keep the old folder or key file where it is, set `QC_POST_DATA_DIR` or
610
+ `QC_POST_ENV_FILE` to its path instead of moving it.
611
+
612
+ ## Security notes
613
+
614
+ - API keys live in a `chmod 600` file in your home directory, never in the
615
+ repo. `.gitignore` also excludes `.qc_post_env`, `.ai_post_env`, `*.env`, your profile, and
616
+ all generated output. Error messages name the variable, never its value.
617
+ - Before any public push: `grep -riE "sk-ant|gsk_" .` should return nothing
618
+ except placeholders: the examples in this README and the script, and the
619
+ fake sentinel key in `tests/conftest.py`.
620
+ - Web pages and feed entries can contain text aimed at the model. Drafts are
621
+ never published unless you click Post in X's compose box or LinkedIn's post box
622
+ (`--post`, `--post-linkedin` and `--post-all` only open them), so read each one
623
+ before posting.
624
+ - If a key is ever committed, deleting it later does not scrub git history —
625
+ rotate the key.
626
+
627
+ ## License
628
+
629
+ MIT