AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Python ai-promptsai-skillblueskyclaudeclaude-codeclawhubdeep-researchhackernewsinstagramopenclawpolymarketrecencyredditresearchsocial-mediatiktoktrendstwitterweb-searchyoutube
fix: resolve slash-command save paths through engine configuration (#1217)
Ilia Alshanetsky3715388ae41a
diff --git a/CONFIGURATION.md b/CONFIGURATION.mdindex 5c61aa2c..369d50a6 100644--- a/CONFIGURATION.md+++ b/CONFIGURATION.md@@ -29,7 +29,7 @@ Each run produces one file per topic, slug-named:### Recommended `.env` entry-`.env` files don't travel between machines or harnesses, so set `LAST30DAYS_MEMORY_DIR` explicitly in `~/.config/last30days/.env` once per host. The `/last30days` slash command works without it (the SKILL.md wrapper has its own default), but **bare engine invocations** — `python3 scripts/last30days.py ...` from cron jobs, scripts, or agents that bypass the wrapper — silently no-op the file save unless the engine sees the env var. Mirrors the `LAST30DAYS_STORE` env-or-flag convention.+`.env` files don't travel between machines or harnesses, so set `LAST30DAYS_MEMORY_DIR` explicitly in `~/.config/last30days/.env` once per host. The `/last30days` slash command resolves its directory through the engine: explicit `--save-dir` > process environment > trusted project `.claude/last30days.env` > global `.env` > `~/Documents/Last30Days`. An explicitly empty value disables research file saves and the saved-file appendix. Library and topic-queue commands use the same resolution; discovery captures the result once and reuses it for every protocol leg. **Bare engine invocations** — `python3 scripts/last30days.py ...` from cron jobs, scripts, or agents that bypass the wrapper — keep their existing no-save default when neither a flag nor configuration supplies a directory.```bash# ~/.config/last30days/.env (pick ONE — uncomment the line that matches your OS)@@ -44,6 +44,7 @@ The engine's `.env` reader doesn't expand `$HOME` — only the tilde, via `Path(**Per-run overrides:**- `--save-dir <path>` - one-off output location. **Flag wins over env var.** If neither flag nor env var is set, the engine does not write a file (DB persistence is independent — see `LAST30DAYS_STORE` below).+- `--resolve-save-dir` - print the absolute save directory selected for the skill and exit without research, browser-cookie reads, credential-store lookups, or file writes. It honors `--save-dir`, process environment, and trusted config files, preserving empty values. For memory directories, whole unresolved host placeholders such as `${user_config.memory_dir}` are absent at each configuration layer: a process placeholder falls back to trusted project then global configuration, and a project placeholder preserves the global value, including an empty value that disables saving. The bare engine uses the same placeholder precedence. Explicit `--save-dir` values remain literal paths. Only this query supplies the skill's `~/Documents/Last30Days` fallback; it does not change the bare research engine's no-save default. Shell wrappers capture this output without sourcing `.env` files.- `--output <file>` - write the rendered output to an exact file path, using the format selected by `--emit`.- `--json-profile {agent,raw}` - select the research JSON shape used with `--emit=json`. `agent` is the default, versioned workflow contract; `raw` preserves the full internal `Report` dump for debugging and power users. See the [JSON export reference](docs/reference/json-export.md).- `--corpus <dir>` - add a local `.md`/`.txt` directory as a private ranked source; repeat the flag for multiple directories. PDFs are extracted only when `pdftotext` is on PATH and otherwise skip with a note. File modification time supplies recency, so the normal research window applies.@@ -72,7 +73,7 @@ The engine's `.env` reader doesn't expand `$HOME` — only the tilde, via `Path(- `--record-fixtures <dir>` - developer-only, hidden flag that records scrubbed source responses for the offline research-quality eval harness. It writes `<dir>/http.json`; see the [eval reference](docs/reference/eval.md) before recording or committing fixtures.- `setup --github-start` / `setup --github-poll` - the two-command ScrapeCreators GitHub device-auth split. `--github-start` submits the device flow, copies the code to the clipboard, opens the browser, and returns the code immediately (foreground); `--github-poll` waits for you to authorize and persists the key. `setup --github` still runs both in one shot for back-compat.-The footer line `📎 Raw results saved to ${LAST30DAYS_MEMORY_DIR:-$HOME/Documents/Last30Days}/<slug>-raw.md` is the canonical pointer; if it shows backslashes on Windows update past v3.1.1.+The footer line `📎 Raw results saved to <resolved memory directory>/<slug>-raw.md` is the canonical pointer; if it shows backslashes on Windows update past v3.1.1. An explicitly disabled save produces no saved-file pointer.Every completed research pass writes a structured `last-report.json` cache beside `last-run.json`. HTML follow-up renders use it so `--emit=html --synthesis-file` can reuse report metadata/footer without fetching sources again; `--drill <target>` uses it as the grounded starting point for targeted re-research; bare `--verify-freshness` updates only the cached report's claim verdicts. Reuse is intentionally short-lived: `LAST30DAYS_REPORT_CACHE_TTL_SECONDS` defaults to `3600` (one hour). Set it to another integer number of seconds to tune the window, or `0` to disable report-cache reuse and post-run follow-ups.diff --git a/changelog.d/+cr-015-skill-memory-directory.fixed.md b/changelog.d/+cr-015-skill-memory-directory.fixed.mdnew file mode 100644index 00000000..8c47f04a--- /dev/null+++ b/changelog.d/+cr-015-skill-memory-directory.fixed.md@@ -0,0 +1 @@+Honor configured memory directories in skill research, library, and topic-queue commands, preserve explicit empty values, fall through unresolved host placeholders to lower-priority configuration, and reuse the resolved directory throughout discovery. Only claim a saved artifact when the engine emitted its path.diff --git a/skills/last30days/SKILL.md b/skills/last30days/SKILL.mdindex 2d915ae9..6567a30d 100644--- a/skills/last30days/SKILL.md+++ b/skills/last30days/SKILL.md@@ -160,7 +160,7 @@ These LAWs resolve presentation conflicts within this file, subject to the instr**Observed LAW 4 violation (2026-04-18, Peter Steinberger disaster #2):** the model emitted `Headline`, `What he is actually saying`, `Cross-source corroboration`, `Where evidence is thin`, `Bottom line` on a GENERAL query. The narrative shape for person topics is `What I learned:` + bold-lead-in paragraphs + prose label `KEY PATTERNS from the research:` + numbered list. No blog-post subheadings.-**LAW 5 - ENGINE FOOTER PASS-THROUGH. EVERY QUERY TYPE. EVERY RUN.** The engine output ends with a `✅ All agents reported back!` emoji-tree footer bounded by `---` lines and wrapped in `<!-- PASS-THROUGH FOOTER -->` / `<!-- END PASS-THROUGH FOOTER -->` comments (v3.0.10+). Include that block verbatim where compatible with higher-priority host/tool requirements and user instructions, positioned after KEY PATTERNS (and after the comparison-table scaffold if present) and before the invitation. Do not recompute the stats, reformat the tree, paraphrase, skip it, or fabricate your own `## Notable Stats` replacement unless governing instructions require an adjustment. Include any required citations separately.+**LAW 5 - ENGINE FOOTER PASS-THROUGH. EVERY QUERY TYPE. EVERY RUN.** When the engine emits a `✅ All agents reported back!` emoji-tree footer bounded by `---` lines and wrapped in `<!-- PASS-THROUGH FOOTER -->` / `<!-- END PASS-THROUGH FOOTER -->` comments, relay that block after KEY PATTERNS (and after the comparison-table scaffold if present) and before the invitation, subject to higher-priority instructions. Preserve the emitted statistics and lines unless governing host/tool requirements or user instructions require an adjustment. Include any required citations separately. The saved-file pointer is optional: relay it only when emitted, even if saving is enabled. If no footer or saved-file pointer was emitted, do not invent one or fabricate a `## Notable Stats` replacement.**LAW 6 - NO RAW RANKED EVIDENCE CLUSTERS IN BODY.** The engine's `## Ranked Evidence Clusters`, `## Stats`, and `## Source Coverage` blocks are bounded inside `<!-- EVIDENCE FOR SYNTHESIS -->` / `<!-- END EVIDENCE FOR SYNTHESIS -->` comments in the `--emit compact` / `--emit md` stdout. They are raw evidence for YOU to read, not output to emit. Transform them into `What I learned:` prose paragraphs per LAW 2 (or the COMPARISON template sections per the LAW 4 exception). If your response contains the literal string `### 1.` followed by a score tuple like `(score N, M items, sources: ...)`, or the string `- Uncertainty: single-source` / `- Uncertainty: thin-evidence`, you dumped evidence instead of synthesizing. STOP and regenerate.@@ -247,10 +247,12 @@ End of OUTPUT CONTRACT. The laws above are the contract; everything below is imp# HOW TO INVOKE THIS SKILL (READ FIRST, FOLLOW EVERY TIME)+**Save-directory resolution:** The commands below query the engine's trusted configuration before selecting a directory. Never source a `.env` file in the shell. If the user supplies a one-off save directory, add `--save-dir="<requested directory>"` to the `--resolve-save-dir` command and remove duplicate save-directory flags from the research arguments. Preserve an empty result: it disables research file saves and the saved-file appendix. Resolve once per research/discovery run; carry the exact resulting value into every later command. If shell tool calls do not share variables, explicitly restore that captured value (including an empty string) in each later call instead of resolving configuration again.+**LIBRARY SEARCH FAST PATH — this overrides every research/setup step below.** If the user says “search my library for X”, “have I researched X before?”, or otherwise asks to query prior saved research, do not run WebSearch, setup, preflight, or fresh source research. Run:```bash-LAST30DAYS_MEMORY_DIR="${LAST30DAYS_MEMORY_DIR:-$HOME/Documents/Last30Days}"+LAST30DAYS_MEMORY_DIR="$("${LAST30DAYS_PYTHON:-python3}" "${SKILL_DIR}/scripts/last30days.py" --resolve-save-dir)" || exit"${LAST30DAYS_PYTHON:-python3}" "${SKILL_DIR}/scripts/last30days.py" library search "${LIBRARY_QUERY}" --save-dir="${LAST30DAYS_MEMORY_DIR}"```@@ -259,7 +261,7 @@ Relay the dated, topic-grouped matches. This is deterministic offline FTS over t**LIBRARY FEED FAST PATH — this overrides every research/setup step below.** If the user asks to build, view, refresh, or subscribe to their saved research library/feed, do not run host WebSearch resolution, the first-run setup gate, topic preflight, or source research. Run:```bash-LAST30DAYS_MEMORY_DIR="${LAST30DAYS_MEMORY_DIR:-$HOME/Documents/Last30Days}"+LAST30DAYS_MEMORY_DIR="$("${LAST30DAYS_PYTHON:-python3}" "${SKILL_DIR}/scripts/last30days.py" --resolve-save-dir)" || exit"${LAST30DAYS_PYTHON:-python3}" "${SKILL_DIR}/scripts/last30days.py" library feed --save-dir="${LAST30DAYS_MEMORY_DIR}"```@@ -268,14 +270,14 @@ Relay the generated local `index.html` and `feed.xml` paths. If the user explici**TOPIC QUEUE FAST PATH — this overrides every research/setup step below.** If the user asks "what's in my topic queue", "what should I talk about next", "what topics haven't I covered", "show my content pipeline", "mark <topic> as covered", "I covered X on the podcast", "we published that article", or similar — even cold, with no research run earlier in this session — do not run WebSearch, setup, preflight, or fresh source research. Run the read form:```bash-LAST30DAYS_MEMORY_DIR="${LAST30DAYS_MEMORY_DIR:-$HOME/Documents/Last30Days}"+LAST30DAYS_MEMORY_DIR="$("${LAST30DAYS_PYTHON:-python3}" "${SKILL_DIR}/scripts/last30days.py" --resolve-save-dir)" || exit"${LAST30DAYS_PYTHON:-python3}" "${SKILL_DIR}/scripts/last30days.py" queue list --save-dir="${LAST30DAYS_MEMORY_DIR}"```or the cover form, for "mark X as covered" phrasing:```bash-LAST30DAYS_MEMORY_DIR="${LAST30DAYS_MEMORY_DIR:-$HOME/Documents/Last30Days}"+LAST30DAYS_MEMORY_DIR="$("${LAST30DAYS_PYTHON:-python3}" "${SKILL_DIR}/scripts/last30days.py" --resolve-save-dir)" || exit"${LAST30DAYS_PYTHON:-python3}" "${SKILL_DIR}/scripts/last30days.py" queue cover "<topic name>" --save-dir="${LAST30DAYS_MEMORY_DIR}"```@@ -325,8 +327,9 @@ Branching rule:**Leg 1 - nominate (Bash timeout 180000).** Sweep the listings and write the nominations bundle:```bash-LAST30DAYS_MEMORY_DIR="${LAST30DAYS_MEMORY_DIR:-$HOME/Documents/Last30Days}"+LAST30DAYS_MEMORY_DIR="$("${LAST30DAYS_PYTHON:-python3}" "${SKILL_DIR}/scripts/last30days.py" --resolve-save-dir)" || exit# Global trending: --discover with NO domain. Domain trending: --discover "${DISCOVERY_DOMAIN}".+printf 'Resolved save directory: <%s>\n' "$LAST30DAYS_MEMORY_DIR" >&2"${LAST30DAYS_PYTHON}" "${SKILL_DIR}/scripts/last30days.py" --discover --nominate-only --save-dir="${LAST30DAYS_MEMORY_DIR}"```@@ -354,7 +357,7 @@ LAST30DAYS_MEMORY_DIR="${LAST30DAYS_MEMORY_DIR:-$HOME/Documents/Last30Days}"**Leg 2 - research (Bash timeout 600000).** Write the judgments file and run the resume leg in the SAME Bash call, using the established tmpfile pattern (mktemp XXXXXX + trap + `cat >|` + quoted heredoc - same rules as the Step 0.75 plan tmpfile; run the block directly in your shell tool, NEVER wrapped in `bash -lc '...'`):```bash-LAST30DAYS_MEMORY_DIR="${LAST30DAYS_MEMORY_DIR:-$HOME/Documents/Last30Days}"+: "${LAST30DAYS_MEMORY_DIR?Restore the exact save directory captured in discovery leg 1}"# Trailing XXXXXX (no .json suffix) for BSD/macOS mktemp; >| because mktemp# already created the file (a plain > is refused under `set -o noclobber`).JUDGMENTS_FILE=$(mktemp "${TMPDIR:-/tmp}/last30days-judgments.XXXXXX")@@ -387,7 +390,7 @@ JUDGE_EOF**Leg 3 - finalize (Bash timeout 60000).** Second tmpfile (sentinel `ANGLE_EOF`), same pattern, same Bash call as the finalize command:```bash-LAST30DAYS_MEMORY_DIR="${LAST30DAYS_MEMORY_DIR:-$HOME/Documents/Last30Days}"+: "${LAST30DAYS_MEMORY_DIR?Restore the exact save directory captured in discovery leg 1}"ANGLES_FILE=$(mktemp "${TMPDIR:-/tmp}/last30days-angles.XXXXXX")trap 'rm -f "$ANGLES_FILE"' EXITcat >| "$ANGLES_FILE" <<'ANGLE_EOF'@@ -399,7 +402,7 @@ ANGLE_EOFIt applies your angles, renders the final topic-per-section brief, saves artifacts, and records the topic queue - offline, no network. **Relay its stdout verbatim** per the DISCOVERY bullet in the OUTPUT CONTRACT - including a **"Nothing solid this window"** result, which is a valid, honest outcome (the confidence floor found no topic with enough cross-source confirmation or engagement; do NOT retry, work around it, or fabricate topics - relay it and suggest a narrower domain or a direct topic run).**Protocol rules:**- - ONE identical `--save-dir="${LAST30DAYS_MEMORY_DIR}"` threaded through all three commands. The handoff files (`discover-nominations.json`, `discover-pending.json`) live in that directory; a different or missing save dir on a later leg means the leg cannot find them.+ - ONE identical `--save-dir="${LAST30DAYS_MEMORY_DIR}"` threaded through all three commands. Capture the resolved value in leg 1 and restore it unchanged for legs 2 and 3, even if configuration or working directory changes. The handoff files (`discover-nominations.json`, `discover-pending.json`) live in that directory; a different save dir on a later leg means the leg cannot find them. When saving is explicitly disabled with an empty value, all legs use the engine's config-directory handoff location; do not substitute the default memory directory.- Handoff files expire after one hour (TTL 3600s) - judge and finalize promptly, in the same session as the sweep.- Contract failures (missing/stale bundle or pending report, judgments/angles not bound to the current `bundle_id`, malformed file) exit 2 with the remedy named on stderr. Fix exactly what it names and re-run THAT leg.- **Degradation rule:** if any leg fails twice (exit 2, invalid file, timeout), fall back to the one-shot `"${LAST30DAYS_PYTHON}" "${SKILL_DIR}/scripts/last30days.py" --discover [domain] --emit=compact --save-dir="${LAST30DAYS_MEMORY_DIR}"` (Bash timeout 600000) and relay its brief - never leave the user with no output. Its one-shot heuristics note is expected on this path.@@ -501,7 +504,8 @@ fiexit 1}-LAST30DAYS_MEMORY_DIR="${LAST30DAYS_MEMORY_DIR:-$HOME/Documents/Last30Days}"+LAST30DAYS_MEMORY_DIR="$("${LAST30DAYS_PYTHON:-python3}" "${SKILL_DIR}/scripts/last30days.py" --resolve-save-dir)" || exit+printf 'Resolved save directory: <%s>\n' "$LAST30DAYS_MEMORY_DIR" >&2```**PYTHON VERSION GATE — when the Runtime Preflight Bash block above exits with a Python version error:**@@ -529,7 +533,7 @@ Your host search is better than the engine's keyless web fallback, so this tells## Configuration-Set `LAST30DAYS_MEMORY_DIR` before invoking the skill to choose where raw research files are saved. If it is not set, the skill defaults to `~/Documents/Last30Days`. The engine creates this directory on first save.+Set `LAST30DAYS_MEMORY_DIR` in the process environment, trusted project config, or global `~/.config/last30days/.env` to choose where raw research files are saved. Resolution follows that order after an explicit `--save-dir`. Only an absent setting defaults the skill to `~/Documents/Last30Days`; an explicitly empty value disables research file saves. The engine creates a nonempty directory on first save.The engine reads `LAST30DAYS_MEMORY_DIR` from either the process env or `~/.config/last30days/.env`, so direct CLI invocations (`python3 scripts/last30days.py ...`) without `--save-dir` will still save when the env var is set. Mirrors the `LAST30DAYS_STORE` env-or-flag convention. Explicit `--save-dir` always wins.@@ -1161,7 +1165,7 @@ If `--agent` appears in ARGUMENTS (e.g., `/last30days plaud granola --agent`):5. **Skip** the follow-up invitation ("I'm now an expert on X...")6. **Output** the complete research report and stop - do not wait for further input-Agent mode saves raw research data to `LAST30DAYS_MEMORY_DIR` (defaults to `~/Documents/Last30Days`) automatically via `--save-dir` (handled by the script, no extra tool calls). Use `--output <file>` only when a caller needs the rendered stdout artifact at an exact path, with the format controlled by `--emit`.+When the resolved directory is nonempty, agent mode saves raw research data to `LAST30DAYS_MEMORY_DIR` (defaults to `~/Documents/Last30Days`) automatically via `--save-dir` (handled by the script, no extra tool calls). An empty directory disables these saves and their footer pointer. Use `--output <file>` only when a caller needs the rendered stdout artifact at an exact path, with the format controlled by `--emit`.**Machine-readable JSON exception:** If the user explicitly asks for structured JSON for an agent, script, or workflow, replace the normal `--emit=compact` engine invocation with `--emit=json` and pass the engine's stdout through verbatim instead of synthesizing the report format below. The default `--json-profile=agent` is the stable, versioned flat contract; use `--json-profile=raw` only when the user explicitly requests the full internal `Report` dump. `--preflight --emit=json` is a separate permission-preflight contract and is not affected by `--json-profile`. Full field documentation and the versioning policy live in `docs/reference/json-export.md` in the repository.@@ -1732,6 +1736,8 @@ For ALL query types:**MANDATORY - do not skip this step.** Every post-engine WebSearch supplement you ran in Step 2 MUST be appended to the saved raw file under `LAST30DAYS_MEMORY_DIR` (defaults to `~/Documents/Last30Days`). Skipping this step is a common Opus 4.7 failure mode: the saved file ends at `## Source Coverage` with no appendix, future sessions cannot see what blog/tutorial/news sources informed the synthesis, and the user cannot trace where specific claims came from.+If the resolved `LAST30DAYS_MEMORY_DIR` is empty, saving was disabled: skip this appendix step and do not create a file elsewhere.+**LAW 1 citation check (read before synthesizing):** the `## WebSearch Supplemental Results` appendix preserves research for later sessions. It does not replace visible citations required by higher-priority host/tool requirements or user instructions. Include those citations in the response. Otherwise keep the default footer and invitation without an extra source list.**Self-check (coverage, not strict equality):** The `## WebSearch Supplemental Results` section must cover every web source that informed your synthesis - including pre-research searches whose findings you cited, not only the Step 2 supplements. So the bullet count should be at least the number of post-engine WebSearches you ran, and may exceed it when pre-research web context fed the synthesis (common on `--hiring-signals` runs, where the careers/funding context comes from pre-research). If a source shaped a claim, it gets a bullet. If you ran zero supplements (which plan 005 says is almost never correct), skip this step entirely rather than writing an empty section.@@ -2024,8 +2030,7 @@ Voice contract LAWs 1, 3, 5 apply to comparisons unchanged (omit unnecessary tra✅ All agents reported back!├─ 🟠 Reddit: ...├─ 🔵 X: ...-(engine footer passed through verbatim, LAW 5)-└─ 📎 Raw results saved to ...+(engine footer passed through when emitted, LAW 5; include its saved-file pointer only if emitted)I've compared {TOPIC_A} vs {TOPIC_B} [vs ...] using the latest community data. Some things you could ask:- [follow-up referencing comparison specifics, e.g. "Deep dive into {Entity} alone with /last30days {Entity}"]@@ -2158,7 +2163,7 @@ If the research output contains a `**🔍 Research Coverage:**` block, render it**THEN - Engine footer pass-through (right before invitation):**-**The research output ENDS with a deterministic footer block bracketed by `---` lines, starting with `✅ All agents reported back!` and ending with `📎 Raw results saved to {resolved LAST30DAYS_MEMORY_DIR}/<slug>-raw.md`. Include that footer block verbatim where compatible with higher-priority host/tool requirements and user instructions, positioned after your "What I learned" + "KEY PATTERNS" narrative and before the invitation. Do not recompute the stats. Do not reformat the tree. Do not paraphrase. Do not add your own source lines inside the copied footer. Required citations may appear separately.**+**When the research output contains a deterministic footer block bracketed by `---` lines and starting with `✅ All agents reported back!`, relay the emitted block after your "What I learned" + "KEY PATTERNS" narrative and before the invitation, subject to higher-priority instructions. Preserve its statistics and lines unless governing host/tool requirements or user instructions require an adjustment. Do not add your own source lines inside the copied footer. Required citations may appear separately. Include `📎 Raw results saved to ...` only when the engine emitted a saved path. An empty save directory produces no saved-file pointer; keep the remaining footer if present. Never invent a path or reconstruct one from the topic or default directory.**- The engine already omits zero-count sources. You do not need to filter them.- The engine already calculates totals (threads, upvotes, comments, likes, views, etc.). You do not need to add them up.@@ -2166,15 +2171,15 @@ If the research output contains a `**🔍 Research Coverage:**` block, render it- The engine already formats Polymarket odds as real `%` strings. You do not need to parse them.- The engine already picks top voices (handles + subreddits). You do not need to pick them.-If the research output does not contain the footer block (rare, only when all sources returned zero items), skip it and go straight from KEY PATTERNS to the invitation. If the block is present, preserve it verbatim where compatible with governing instructions.+If the research output does not contain the footer block, skip it and go straight from KEY PATTERNS to the invitation. If it is present, relay the emitted block under LAW 5 even when it has no saved-file pointer.**Citation requirements before the invitation:** include visible citations required by higher-priority host/tool requirements or user instructions. Keep the engine footer where compatible with those requirements. The default response ends at the invitation without an additional source list; required trailing citations are an exception.-**SELF-CHECK before displaying**: Re-read your "What I learned" section. Does it match what the research ACTUALLY says? If you catch yourself projecting your own knowledge instead of the research, rewrite it. Then verify: (a) no `##` headers in your response body, (b) no em-dashes or en-dashes anywhere, (c) the engine footer block appears verbatim between KEY PATTERNS and the invitation.+**SELF-CHECK before displaying**: Re-read your "What I learned" section. Does it match what the research ACTUALLY says? If you catch yourself projecting your own knowledge instead of the research, rewrite it. Then verify: (a) no `##` headers in your response body, (b) no em-dashes or en-dashes anywhere, (c) any emitted engine footer appears between KEY PATTERNS and the invitation under LAW 5, with no added saved-file pointer.**Saved artifact access flow:** after the engine has created a file, decide how the user should get access to it based on what they asked for:-- **Normal report:** the Markdown raw artifact already appears in the engine footer (`📎 Raw results saved to ...`). The chat synthesis is the primary user-facing report, so do not open the raw Markdown file automatically and do not ask a follow-up access question. The path line is enough.+- **Normal report:** if the engine emitted a saved Markdown path, relay that footer pointer (`📎 Raw results saved to ...`). Otherwise, claim no saved artifact. The chat synthesis is the primary user-facing report, so do not open the raw Markdown file automatically and do not ask a follow-up access question. An emitted path line is enough.- **Markdown file requested:** if the user explicitly asked for a Markdown file/export, treat the saved Markdown path as the deliverable. Provide the path and open it locally when the host can safely open local files and the request implies viewing it now. Do not offer hosted publishing for Markdown.- **HTML file requested:** follow `references/save-html-brief.md`. Save the local HTML first, show the absolute path, then present explicit next-step choices: open the HTML file, publish to an available/preferred HTML publishing service, or done for now.- **Share/publish requested:** sharing means hosted HTML, not Markdown. Save the local HTML first and show the path. Then respect existing publishing preferences, show available publishing choices, and ask for public-vs-password only when the selected service requires that choice (for `ht-ml.app`, ask whether password protection should be used; if yes, ask the user to type the shared password before publishing). Never block creation of the local file on the hosting decision.@@ -2291,7 +2296,7 @@ Close with `I have all the links to the {N} {source list} I pulled from. Just as## WAIT FOR USER'S RESPONSE-**STOP and wait** for the user to respond after completing the response and any citations required by higher-priority host/tool requirements or user instructions. Do not continue research after the invitation unless governing instructions require it. Omit an extra source list only when none is required. The research script already saved raw data to `LAST30DAYS_MEMORY_DIR` (defaults to `~/Documents/Last30Days`) via `--save-dir`.+**STOP and wait** for the user to respond after completing the response and any citations required by higher-priority host/tool requirements or user instructions. Do not continue research after the invitation unless governing instructions require it. Omit an extra source list only when none is required. Claim that raw data was saved only when the engine emitted a saved path; an empty `LAST30DAYS_MEMORY_DIR` disables saving and its footer pointer.---diff --git a/skills/last30days/scripts/last30days.py b/skills/last30days/scripts/last30days.pyindex 7190706f..45324671 100644--- a/skills/last30days/scripts/last30days.py+++ b/skills/last30days/scripts/last30days.py@@ -775,6 +775,10 @@ def build_parser() -> argparse.ArgumentParser:parser.add_argument("--no-browser-cookies", action="store_true",help="Disable browser-cookie extraction even when FROM_BROWSER is configured")parser.add_argument("--save-dir", help="Optional directory for saving the rendered output")+ parser.add_argument(+ "--resolve-save-dir", action="store_true",+ help="Print the skill save directory from flags/config, then exit without research",+ )parser.add_argument("--corpus",action="append",@@ -3183,6 +3187,9 @@ def _main(topic = " ".join(args.topic).strip()original_topic = topic_validate_extra_argv(parser, topic, extra_argv)+ if args.resolve_save_dir:+ print(env.resolve_memory_dir(args.save_dir))+ return 0if args.x_posts is not None and _looks_inline_json(args.x_posts):sys.stderr.write("[last30days] --x-posts accepts a file path only (inline JSON is not "diff --git a/skills/last30days/scripts/lib/env.py b/skills/last30days/scripts/lib/env.pyindex 084f74e8..aab035d4 100644--- a/skills/last30days/scripts/lib/env.py+++ b/skills/last30days/scripts/lib/env.py@@ -288,9 +288,9 @@ def load_env_file(path: Path) -> dict[str, str]:# Remove quotes if presentif value and value[0] in ('"', "'") and value[-1] == value[0]:value = value[1:-1]- # Empty LAST30DAYS_YT_PLAYER_CLIENT is a persisted disable; other- # keys still drop blanks so secrets cannot be set to "".- if key and (value or key == 'LAST30DAYS_YT_PLAYER_CLIENT'):+ # These settings use empty as a persisted disable; secrets still+ # drop blanks instead of overriding a configured credential.+ if key and (value or key in {'LAST30DAYS_YT_PLAYER_CLIENT', 'LAST30DAYS_MEMORY_DIR'}):env.update({key: value})return env@@ -494,6 +494,34 @@ def _find_project_env() -> Path | None:return None+def _configured_memory_dir(*values: str | None) -> str | None:+ for value in values:+ if value is not None and not is_unsubstituted_template(value):+ return value+ return None+++def resolve_memory_dir(save_dir: str | None = None) -> str:+ """Resolve the skill's save directory without credential-store access."""+ value = save_dir+ if value is None:+ value = _configured_memory_dir(os.environ.get("LAST30DAYS_MEMORY_DIR"))+ if value is None:+ file_env = load_env_file(CONFIG_FILE) if CONFIG_FILE else {}+ project_env = {}+ if _project_config_trusted(ConfigLoadPolicy(), file_env):+ project_path = _find_project_env()+ if project_path:+ project_env = load_env_file(project_path)+ value = _configured_memory_dir(+ project_env.get("LAST30DAYS_MEMORY_DIR"),+ file_env.get("LAST30DAYS_MEMORY_DIR"),+ )+ if value is None:+ value = str(Path.home() / "Documents" / "Last30Days")+ return str(Path(value).expanduser().absolute()) if value else ""++def get_config(policy: ConfigLoadPolicy | None = None) -> dict[str, Any]:"""Load configuration from multiple sources.@@ -722,7 +750,7 @@ def get_config(policy: ConfigLoadPolicy | None = None) -> dict[str, Any]:# Process env only; the .env value never reaches config.config[key] = os.environ.get(key) or defaultcontinue- if key == 'LAST30DAYS_YT_PLAYER_CLIENT':+ if key in {'LAST30DAYS_YT_PLAYER_CLIENT', 'LAST30DAYS_MEMORY_DIR'}:# Empty string is a valid disable; `or` would treat it as unset.if key in os.environ:config[key] = os.environ.get(key)@@ -819,7 +847,11 @@ def get_config(policy: ConfigLoadPolicy | None = None) -> dict[str, Any]:)for key in templated_keys:os.environ.pop(key, None)- fallback = merged_env.get(key)+ fallback = (+ _configured_memory_dir(project_env.get(key), file_env.get(key))+ if key == 'LAST30DAYS_MEMORY_DIR'+ else merged_env.get(key)+ )# A lower-priority value that is itself a placeholder is not a credential.if is_unsubstituted_template(fallback):fallback = Nonediff --git a/tests/test_skill_memory_directory.py b/tests/test_skill_memory_directory.pynew file mode 100644index 00000000..86d5be78--- /dev/null+++ b/tests/test_skill_memory_directory.py@@ -0,0 +1,344 @@+"""Execute the skill's save-directory setup against isolated configuration."""++from pathlib import Path+import re+import shlex+import shutil+import subprocess+import sys++import pytest+++ROOT = Path(__file__).resolve().parents[1]+SKILL = ROOT / "skills" / "last30days"+ENGINE = SKILL / "scripts" / "last30days.py"+BASH = shutil.which("bash")+++def shell_env(tmp_path):+ config_dir = tmp_path / "config"+ config_dir.mkdir()+ bin_dir = tmp_path / "bin"+ bin_dir.mkdir()+ return {+ "PATH": str(bin_dir),+ "HOME": str(Path.home()),+ "LAST30DAYS_PYTHON": sys.executable,+ "SKILL_DIR": str(SKILL),+ "LAST30DAYS_CONFIG_DIR": str(config_dir),+ "LAST30DAYS_CACHE_DIR": str(tmp_path / "cache"),+ }+++def write_config(path, text):+ path.parent.mkdir(parents=True, exist_ok=True)+ path.write_text(text)+ path.chmod(0o600)+++ ("global_value", "process_value", "expected"),+ [+ ("/tmp/client research", None, "/tmp/client research"),+ ("/tmp/global", "/tmp/process research", "/tmp/process research"),+ ("/tmp/global", "", ""),+ ("", None, ""),+ (None, None, str(Path.home() / "Documents" / "Last30Days")),+ ("/tmp/configured research", "${user_config.memory_dir}", "/tmp/configured research"),+ ("", "${user_config.memory_dir}", ""),+ (None, "${user_config.memory_dir}", str(Path.home() / "Documents" / "Last30Days")),+ ("${user_config.memory_dir}", None, str(Path.home() / "Documents" / "Last30Days")),+ ("${user_config.memory_dir}", "", ""),+ ("/tmp/configured research", " ${user_config.memory_dir} ", "/tmp/configured research"),+ (None, "/tmp/${user_config.memory_dir}/research", "/tmp/${user_config.memory_dir}/research"),+ ],+)+def test_documented_memory_resolution(global_value, process_value, expected, shell_env, tmp_path):+ if global_value is not None:+ write_config(+ Path(shell_env["LAST30DAYS_CONFIG_DIR"]) / ".env",+ f'LAST30DAYS_MEMORY_DIR="{global_value}"\n',+ )+ if process_value is not None:+ shell_env["LAST30DAYS_MEMORY_DIR"] = process_value+ assignments = re.findall(r"^LAST30DAYS_MEMORY_DIR=.*$", (SKILL / "SKILL.md").read_text(), re.M)+ assert assignments+ for assignment in set(assignments):+ result = subprocess.run(+ [BASH, "-c", assignment + '\nprintf "%s" "$LAST30DAYS_MEMORY_DIR"'],+ env=shell_env, cwd=tmp_path, text=True, capture_output=True, check=True,+ )+ assert result.stdout == expected++[email protected]("trust", [None, "1", "0", "global"])+def test_resolver_honors_project_trust(shell_env, tmp_path, trust):+ config_text = "LAST30DAYS_MEMORY_DIR=/tmp/global research\n"+ if trust == "global":+ config_text += "LAST30DAYS_TRUST_PROJECT_CONFIG=1\n"+ elif trust is not None:+ shell_env["LAST30DAYS_TRUST_PROJECT_CONFIG"] = trust+ write_config(Path(shell_env["LAST30DAYS_CONFIG_DIR"]) / ".env", config_text)+ write_config(+ tmp_path / ".claude" / "last30days.env",+ "LAST30DAYS_MEMORY_DIR=project research\nLAST30DAYS_TRUST_PROJECT_CONFIG=1\n",+ )+ result = subprocess.run(+ [sys.executable, str(ENGINE), "--resolve-save-dir"],+ env=shell_env, cwd=tmp_path, text=True, capture_output=True, check=True,+ )+ expected = str(tmp_path / "project research") if trust in {"1", "global"} else "/tmp/global research"+ assert result.stdout == expected + "\n"++[email protected]("project_value", ["project research", ""])+def test_process_placeholder_uses_trusted_project_setting(shell_env, tmp_path, project_value):+ write_config(+ Path(shell_env["LAST30DAYS_CONFIG_DIR"]) / ".env",+ "LAST30DAYS_MEMORY_DIR=/tmp/global research\nLAST30DAYS_TRUST_PROJECT_CONFIG=1\n",+ )+ write_config(tmp_path / ".claude" / "last30days.env", f"LAST30DAYS_MEMORY_DIR={project_value}\n")+ shell_env["LAST30DAYS_MEMORY_DIR"] = "${user_config.memory_dir}"+ result = subprocess.run(+ [sys.executable, str(ENGINE), "--resolve-save-dir"],+ env=shell_env, cwd=tmp_path, text=True, capture_output=True, check=True,+ )+ assert result.stdout == (str(tmp_path / project_value) if project_value else "") + "\n"++[email protected](("process_value", "global_value", "expected"), [+ (None, "/tmp/global research", "/tmp/global research"),+ ("${user_config.memory_dir}", "/tmp/global research", "/tmp/global research"),+ (None, "", ""),+ ("${user_config.memory_dir}", "", ""),+ ("", "/tmp/global research", ""),+ ("/tmp/process research", "/tmp/global research", "/tmp/process research"),+ (None, None, None),+ (None, "${user_config.memory_dir}", None),+ ("${user_config.memory_dir}", "${user_config.memory_dir}", None),+])+def test_project_placeholder_preserves_memory_precedence(+ shell_env, tmp_path, process_value, global_value, expected,+):+ shell_env["HOME"] = str(tmp_path / "home")+ config_text = "LAST30DAYS_TRUST_PROJECT_CONFIG=1\n"+ if global_value is not None:+ config_text += f"LAST30DAYS_MEMORY_DIR={global_value}\n"+ write_config(Path(shell_env["LAST30DAYS_CONFIG_DIR"]) / ".env", config_text)+ write_config(+ tmp_path / ".claude" / "last30days.env",+ "LAST30DAYS_MEMORY_DIR=${user_config.memory_dir}\n",+ )+ if process_value is not None:+ shell_env["LAST30DAYS_MEMORY_DIR"] = process_value++ result = subprocess.run(+ [sys.executable, str(ENGINE), "--resolve-save-dir"],+ env=shell_env, cwd=tmp_path, text=True, capture_output=True, check=True,+ )++ if expected is None:+ expected = str(tmp_path / "home" / "Documents" / "Last30Days")+ assert result.stdout == expected + "\n"++[email protected]("entrypoint", ["skill", "engine"])[email protected]("disabled", [False, True])[email protected]("process_value", [None, "${user_config.memory_dir}"])+def test_project_placeholder_preserves_global_research_save(+ shell_env, tmp_path, entrypoint, disabled, process_value,+):+ shell_env["HOME"] = str(tmp_path / "home")+ if process_value is not None:+ shell_env["LAST30DAYS_MEMORY_DIR"] = process_value+ target = tmp_path / "global research"+ write_config(+ Path(shell_env["LAST30DAYS_CONFIG_DIR"]) / ".env",+ f"LAST30DAYS_MEMORY_DIR={'' if disabled else target}\nLAST30DAYS_TRUST_PROJECT_CONFIG=1\n",+ )+ write_config(+ tmp_path / ".claude" / "last30days.env",+ "LAST30DAYS_MEMORY_DIR=${user_config.memory_dir}\n",+ )+ command = '"$LAST30DAYS_PYTHON" "$SKILL_DIR/scripts/last30days.py" OpenAI --mock --quick --no-browser-cookies --emit=compact'+ if entrypoint == "skill":+ assignment = re.findall(r"^LAST30DAYS_MEMORY_DIR=.*$", (SKILL / "SKILL.md").read_text(), re.M)[0]+ command = assignment + "\n" + command + ' --save-dir="$LAST30DAYS_MEMORY_DIR"'+ result = subprocess.run(+ [BASH, "-c", command], env=shell_env, cwd=tmp_path,+ text=True, capture_output=True,+ )++ assert result.returncode == 0, result.stderr+ if disabled:+ assert "Raw results saved to" not in result.stdout+ assert not target.exists()+ else:+ artifacts = list(target.glob("*.md"))+ assert len(artifacts) == 1+ assert f"Raw results saved to {artifacts[0]}" in result.stdout+ assert "OpenAI" in artifacts[0].read_text()+ assert not (tmp_path / "home" / "Documents" / "Last30Days").exists()+ assert not (tmp_path / "${user_config.memory_dir}").exists()+++def test_bare_engine_with_only_memory_placeholders_does_not_save(shell_env, tmp_path):+ shell_env["HOME"] = str(tmp_path / "home")+ shell_env["LAST30DAYS_MEMORY_DIR"] = "${user_config.memory_dir}"+ write_config(+ Path(shell_env["LAST30DAYS_CONFIG_DIR"]) / ".env",+ "LAST30DAYS_MEMORY_DIR=${user_config.memory_dir}\nLAST30DAYS_TRUST_PROJECT_CONFIG=1\n",+ )+ write_config(+ tmp_path / ".claude" / "last30days.env",+ "LAST30DAYS_MEMORY_DIR=${user_config.memory_dir}\n",+ )++ result = subprocess.run(+ [sys.executable, str(ENGINE), "OpenAI", "--mock", "--quick", "--no-browser-cookies", "--emit=compact"],+ env=shell_env, cwd=tmp_path, text=True, capture_output=True,+ )++ assert result.returncode == 0, result.stderr+ assert "✅ All agents reported back!" in result.stdout+ assert "Raw results saved to" not in result.stdout+ assert not list(tmp_path.rglob("*-raw.md"))++[email protected]("flag", ["flag research", "", "${user_config.memory_dir}", "prefix-${user_config.memory_dir}"])+def test_resolver_explicit_flag_wins(shell_env, tmp_path, flag):+ shell_env["LAST30DAYS_MEMORY_DIR"] = "/tmp/process research"+ result = subprocess.run(+ [sys.executable, str(ENGINE), "--resolve-save-dir", "--save-dir", flag],+ env=shell_env, cwd=tmp_path, text=True, capture_output=True, check=True,+ )+ assert result.stdout == (str(tmp_path / flag) if flag else "") + "\n"+++def test_dotenv_path_is_data_not_shell_code(shell_env, tmp_path):+ marker = tmp_path / "must-not-execute"+ value = f"$(printf unsafe > {marker})"+ write_config(Path(shell_env["LAST30DAYS_CONFIG_DIR"]) / ".env", f"LAST30DAYS_MEMORY_DIR={value}\n")+ assignment = re.findall(r"^LAST30DAYS_MEMORY_DIR=.*$", (SKILL / "SKILL.md").read_text(), re.M)[0]+ result = subprocess.run(+ [BASH, "-c", assignment + '\nprintf "%s" "$LAST30DAYS_MEMORY_DIR"'],+ env=shell_env, cwd=tmp_path, text=True, capture_output=True, check=True,+ )+ assert result.stdout == str(tmp_path / value)+ assert not marker.exists()+++def test_resolver_exits_before_auth_or_research(monkeypatch, capsys):+ import last30days+ from lib import env++ assert Path(last30days.__file__).resolve() == ENGINE+ assert Path(env.__file__).resolve() == SKILL / "scripts" / "lib" / "env.py"++ def forbidden(*args, **kwargs):+ pytest.fail("path query entered credential/research configuration")++ monkeypatch.setattr(env, "_load_keychain", forbidden)+ monkeypatch.setattr(env, "_load_pass", forbidden)+ monkeypatch.setattr(env, "_discover_and_apply_x_credentials", forbidden)+ monkeypatch.setattr(sys, "argv", [str(ENGINE), "--resolve-save-dir", "--save-dir", ""])+ assert last30days.main() == 0+ assert capsys.readouterr().out == "\n"+++def test_documented_discovery_legs_reuse_captured_directory(shell_env, tmp_path):+ text = (SKILL / "SKILL.md").read_text()+ starts = re.findall(r"^LAST30DAYS_MEMORY_DIR=.*$", text, re.M)+ guards = re.findall(r'^: "\$\{LAST30DAYS_MEMORY_DIR\?.*$', text, re.M)+ assert len(guards) == 2+ config_path = Path(shell_env["LAST30DAYS_CONFIG_DIR"]) / ".env"+ captured = tmp_path / "original research"+ write_config(config_path, f"LAST30DAYS_MEMORY_DIR={captured}\n")+ changed = tmp_path / "changed research"+ command = "\n".join([+ starts[0],+ f"printf '%s\\n' {shlex.quote(f'LAST30DAYS_MEMORY_DIR={changed}')} > {shlex.quote(str(config_path))}",+ *guards,+ 'printf "%s" "$LAST30DAYS_MEMORY_DIR"',+ ])+ result = subprocess.run(+ [BASH, "-c", command], env=shell_env, cwd=tmp_path,+ text=True, capture_output=True, check=True,+ )+ assert result.stdout == str(captured)+++def test_mock_research_saves_to_documented_dotenv_directory(shell_env, tmp_path):+ target = tmp_path / "client research"+ write_config(Path(shell_env["LAST30DAYS_CONFIG_DIR"]) / ".env", f"LAST30DAYS_MEMORY_DIR={target}\n")+ text = (SKILL / "SKILL.md").read_text()+ assignment = re.findall(r"^LAST30DAYS_MEMORY_DIR=.*$", text, re.M)[0]+ command = assignment + '\n"$LAST30DAYS_PYTHON" "$SKILL_DIR/scripts/last30days.py" OpenAI --mock --quick --no-browser-cookies --emit=md --save-dir="$LAST30DAYS_MEMORY_DIR"'+ result = subprocess.run(+ [BASH, "-c", command], env=shell_env, cwd=tmp_path,+ text=True, capture_output=True,+ )+ assert result.returncode == 0, result.stderr+ artifacts = list(target.glob("*.md"))+ assert artifacts+ assert "OpenAI" in artifacts[0].read_text()+++def test_empty_project_setting_disables_bare_engine_save(shell_env, tmp_path):+ target = tmp_path / "global research"+ write_config(+ Path(shell_env["LAST30DAYS_CONFIG_DIR"]) / ".env",+ f"LAST30DAYS_MEMORY_DIR={target}\nLAST30DAYS_TRUST_PROJECT_CONFIG=1\n",+ )+ write_config(tmp_path / ".claude" / "last30days.env", "LAST30DAYS_MEMORY_DIR=\n")+ result = subprocess.run(+ [sys.executable, str(ENGINE), "OpenAI", "--mock", "--quick", "--no-browser-cookies", "--emit=md"],+ env=shell_env, cwd=tmp_path, text=True, capture_output=True,+ )+ assert result.returncode == 0, result.stderr+ assert "OpenAI" in result.stdout+ assert not target.exists()+ assert "Saved output to" not in result.stderr++[email protected]("disabled", [False, True])+def test_documented_mock_research_placeholder_uses_configured_save_state(shell_env, tmp_path, disabled):+ target = tmp_path / "configured research"+ write_config(+ Path(shell_env["LAST30DAYS_CONFIG_DIR"]) / ".env",+ f"LAST30DAYS_MEMORY_DIR={'' if disabled else target}\n",+ )+ shell_env["LAST30DAYS_MEMORY_DIR"] = "${user_config.memory_dir}"+ assignment = re.findall(r"^LAST30DAYS_MEMORY_DIR=.*$", (SKILL / "SKILL.md").read_text(), re.M)[0]+ command = assignment + '\n"$LAST30DAYS_PYTHON" "$SKILL_DIR/scripts/last30days.py" OpenAI --mock --quick --no-browser-cookies --emit=compact --save-dir="$LAST30DAYS_MEMORY_DIR"'+ result = subprocess.run(+ [BASH, "-c", command], env=shell_env, cwd=tmp_path,+ text=True, capture_output=True,+ )+ assert result.returncode == 0, result.stderr+ assert "✅ All agents reported back!" in result.stdout+ if disabled:+ assert "Raw results saved to" not in result.stdout+ assert not target.exists()+ else:+ artifacts = list(target.glob("*.md"))+ assert len(artifacts) == 1+ assert f"Raw results saved to {artifacts[0]}" in result.stdout+ assert "OpenAI" in artifacts[0].read_text()+++def test_skill_footer_claims_only_emitted_saved_paths():+ text = (SKILL / "SKILL.md").read_text()+ law = text.split("**LAW 5 -", 1)[1].split("**LAW 6 -", 1)[0]+ assert "saved-file pointer is optional" in law+ assert "only when emitted" in law+ assert "higher-priority instructions" in law+ footer = text.split("**THEN - Engine footer pass-through", 1)[1].split("**LAST - Invitation", 1)[0]+ assert "only when the engine emitted a saved path" in footer+ assert "Never invent a path" in footer+ assert "higher-priority instructions" in footer+ assert "and ending with `📎 Raw results saved to" not in footer+ assert "└─ 📎 Raw results saved to ..." not in text+ assert "The research script already saved raw data" not in textdiff --git a/tests/test_version_consistency.py b/tests/test_version_consistency.pyindex 1084c60d..b55deccd 100644--- a/tests/test_version_consistency.py+++ b/tests/test_version_consistency.py@@ -39,10 +39,23 @@ class TestVersionConsistency(unittest.TestCase):compare_text = (SKILL_ROOT / "scripts" / "compare.sh").read_text(encoding="utf-8")default_assignment = 'LAST30DAYS_MEMORY_DIR="${LAST30DAYS_MEMORY_DIR:-$HOME/Documents/Last30Days}"'- self.assertIn(default_assignment, skill_text)+ assignments = re.findall(r"^LAST30DAYS_MEMORY_DIR=.*$", skill_text, re.MULTILINE)+ self.assertTrue(assignments, "Skill commands must resolve the configured memory directory")+ for assignment in assignments:+ with self.subTest(assignment=assignment):+ self.assertIn("--resolve-save-dir", assignment)+ self.assertFalse(+ default_assignment in skill_text,+ "Shell defaults must not bypass the engine's memory-directory configuration",+ )self.assertIn(default_assignment, compare_text)self.assertNotIn("--save-dir=~/Documents/Last30Days", skill_text)- self.assertIn('--save-dir="${LAST30DAYS_MEMORY_DIR}"', skill_text)+ bash_blocks = re.findall(r"```bash\n(.*?)\n```", skill_text, re.DOTALL)+ save_dir_values = re.findall(+ r'''--save-dir=("[^"]*"|'[^']*'|\S+)''', "\n".join(bash_blocks)+ )+ self.assertTrue(save_dir_values, "Skill commands must pass the resolved save directory")+ self.assertEqual({'"${LAST30DAYS_MEMORY_DIR}"'}, set(save_dir_values))def test_compare_script_does_not_skip_permissions(self) -> None:compare_text = (SKILL_ROOT / "scripts" / "compare.sh").read_text(encoding="utf-8")@@ -67,9 +80,18 @@ class TestVersionConsistency(unittest.TestCase):except UnicodeDecodeError:continue+ in_code_block = Falsefor line_number, line in enumerate(lines, start=1):+ if path.suffix == ".md" and line.lstrip().startswith("```"):+ in_code_block = not in_code_blockif "~/Documents/Last30Days" not in line and "$HOME/Documents/Last30Days" not in line:continue+ documented_fallback = (+ path.suffix == ".md"+ and not in_code_block+ and ("LAST30DAYS_MEMORY_DIR" in line or "--resolve-save-dir" in line)+ and re.search(r"\b(default\w*|fallback)\b", line) is not None+ )allowed_default = ("LAST30DAYS_MEMORY_DIR" in lineand (@@ -82,7 +104,7 @@ class TestVersionConsistency(unittest.TestCase):or "${LAST30DAYS_MEMORY_DIR:-$HOME/Documents/Last30Days}" in line))- if not allowed_default:+ if not (allowed_default or documented_fallback):offenders.append(f"{path.relative_to(ROOT)}:{line_number}: {line.strip()}")self.assertEqual([], offenders)