Skip to content

Add cross-plugin promo via systemMessage at SessionStart - #588

Merged
fdaviddpt merged 4 commits into
mainfrom
fix/574
Sep 5, 2026
Merged

fdaviddpt merged 4 commits into
mainfrom
fix/574

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #574.

Names one sibling Digital-Process-Tools plugin (supertool or claude-jit-context) the user has not installed yet, in the one hook channel a human sees and the model never does.

What changed

  • promos.json (new, repo root, beside config.example.json): id/text/url/installed_key per entry, data not shell -- copy changes without touching the hook.
  • scripts/session-start-hook.sh: at SessionStart only, checks ~/.claude/plugins/installed_plugins.json (version 2, <name>@<marketplace>) and speaks only for a plugin that reads as a confident not-installed -- cannot-tell (file absent/unreadable/wrong version, or the per-entry install-key query itself failing) suppresses exactly like a confirmed install.
  • Off switch: features.plugin_promos (default true). Throttle: cooldowns.promo_seconds (default 604800, 7 days), persisted as a machine-global marker under ~/.remember/tmp/, independent of any per-project data_dir.
  • Never emitted from SessionEnd/PostToolUse/UserPromptSubmit, and never via additionalContext alone -- the hook's stdout becomes one JSON object (hookSpecificOutput.additionalContext + systemMessage) only when a promo fires; otherwise it streams byte-for-byte unchanged, via an exec-based fd buffer rather than command substitution (the region contains a case statement, which breaks $( ... ) capture -- see the note below for the reproduction).
  • Docs: README.md, docs/hooks.md, docs/configuration.md updated. Changelog fragment: changelog.d/574.added.md.

Self-review

Two spawns (Explore + oss:auditor) against the first commit independently found the same bug: the throttle marker was written the moment a candidate was selected, before the buffer/jq stages that actually deliver systemMessage -- a buffer-open or jq failure on the emit pass could silently burn the whole 7-day cooldown on a promo nobody saw. The auditor also caught a jq-exit-status gap in the per-entry install check (a parse/type error on .plugins[key] read the same as "genuinely absent") and flagged the 140-char length-budget guard as untested by a positive control. All three fixed in the second commit, each with a regression test (12/12 pass). Full reviewer exchange and reproduction commands: notes/fix-574-20260905T221817Z.md.

Testing

tests/test_plugin_promo_574.py (new, 12 tests) exercises the hook end-to-end via subprocess: not-installed positive control, installed suppression, cannot-tell (absent file / wrong version) suppression, off switch, cooldown throttle (including a configurable-zero regression), missing-url and over-length-budget entries (both skipped and logged), the undelivered-promo-does-not-burn-the-cooldown regression, and a grep assertion that session-end-hook.sh never mentions systemMessage/promo at all.

🤖 Generated with Claude Code

[AI-generated]

fdaviddpt and others added 4 commits September 6, 2026 00:07
Names one sibling Digital-Process-Tools plugin (supertool or
claude-jit-context) the user has not installed yet, checked against
~/.claude/plugins/installed_plugins.json, in the one hook channel a
human sees and the model never does. Copy lives in promos.json so
wording changes without a shell edit. Off switch
features.plugin_promos (default true); throttle
cooldowns.promo_seconds (default 604800), persisted per machine under
~/.remember/tmp/ regardless of data_dir. Never emitted from
SessionEnd, PostToolUse, or as additionalContext.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bv6BGZD2EdZ9EuJ7tPDTb7
…#574)

Both self-review spawns independently found the same bug: the throttle/
rotation marker was written the moment a candidate was SELECTED, before
the buffered-stdout / jq stages that actually deliver the systemMessage.
A buffer-open failure or a jq hiccup on the emit pass still left a marker
claiming the promo was shown, burning the whole cooldowns.promo_seconds
window on a promo the user never saw. The marker is now written only
after the JSON carrying systemMessage has actually been printed.

The auditor also found a jq-error-vs-genuinely-absent gap in the
per-entry installed-plugin check (a non-zero jq exit was read the same
as "not installed" rather than cannot-tell) and flagged the 140-char
length-budget guard as having no positive-control test. Both fixed,
each with a regression test.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bv6BGZD2EdZ9EuJ7tPDTb7
PR #588's Windows legs (pytest 3.10/3.11/3.12) failed
tests/test_windows_skip_triage_497.py: the new blanket win32-skip test
module from this issue was never added to
docs/windows-skip-triage.md, which that self-check test diffs against
the live tree on every run. Listed as unclear, same templated reason
and verdict as the sibling session-start-hook.sh subprocess tests this
module's own tests are modelled on.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bv6BGZD2EdZ9EuJ7tPDTb7
…574)

PR #588's ubuntu-latest/3.9 leg (and every other non-Windows leg once
they ran) failed test_path_resolution.py::test_scripts_use_jq_var_not_hardcoded
at session-start-hook.sh:965 -- a `command -v jq >/dev/null 2>&1 ||
return 0` availability probe added by this issue, which the test's own
docstring already says should be excluded ("but not ... 'command -v
jq'") but the implementation never actually excluded, since its naive
`" jq " in line` substring check matches the "v jq >" span inside that
exact probe. Fixed the scanner to skip a `command -v jq` line before
the substring check, with a positive-control regression test proving
the exclusion actually fires for this shape.

That surfaced a second, real instance of the pattern the scanner is
FOR: this issue's own new jq calls at session-start-hook.sh:1008 (and
several siblings) invoked hardcoded `jq` rather than the `$JQ` variable
detect-tools.sh already exports (real jq when found, `_jq_fallback`
otherwise) -- the same convention line 333 of this file already
follows. Switched every new invocation to `$JQ`; safe because each one
runs only after the file's own `command -v jq` guard has already
confirmed `$JQ` resolves to the real binary at that point.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bv6BGZD2EdZ9EuJ7tPDTb7
@fdaviddpt
fdaviddpt merged commit be92024 into main Sep 5, 2026
16 checks passed
@fdaviddpt
fdaviddpt deleted the fix/574 branch September 5, 2026 23:06
fdaviddpt added a commit that referenced this pull request Sep 6, 2026
…591)

* Add authoring-time reminder for a new blanket win32-skip test (#589)

#585 and #588 each hit the same gap in one session: a new module-level
`pytestmark = pytest.mark.skipif(sys.platform == "win32", ...)` needs a
`docs/windows-skip-triage.md` row in the same commit, and both times this
was caught only well into a CI run rather than at authoring time.

Add a `.claude/jit-context` tools-dimension entry
(`tools/00-manual/win32-skip-triage-entry.md`) that fires on a `supertool`
Bash call whose command text contains the `pytestmark = pytest.mark.skipif`
pattern -- this repo's own write path always carries a new file's content
inside the Bash command string (`paste:@-`/`edit:@-` heredocs), so a
content-shaped regex can see it even though jit-context deliberately never
inspects a native Edit/Write tool_input.content. Proven to fire on a
matching payload and stay silent on a non-matching one (both checked
directly against pre-tool-hook.sh).

State the same convention in `CONTRIBUTING.md` and in
`docs/windows-skip-triage.md`'s own header, as a backstop for a contributor
whose write does not go through `supertool` -- the one path the jit-context
rule cannot see into.

Audited tests/test_path_resolution.py for other instances of the issue's
second half (a docstring/comment promising an exclusion the code does not
implement, with no positive-control test proving it fires): the
`command -v jq` case is already fixed (#574/#588 follow-up); no other
instance found. Every other per-line exclusion in that file is a plain,
correctly-implemented containment check or a whole-file omission, not a
substring pattern that can quietly amnesty a real violation.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bv6BGZD2EdZ9EuJ7tPDTb7

* Fix win32-skip jit-context regex to match this repo's real skip formatting (#589)

Both spawned reviewers (Explore and oss:auditor) independently caught the same
high-severity bug in the previous commit: `match:
~pytest\.mark\.skipif\(sys\.platform *== *.win32.` requires `sys.platform`
immediately after the literal `(`, with no separator. That only matches a
single-line `pytestmark = pytest.mark.skipif(sys.platform == "win32", ...)`.
Only 5 of 118 blanket-skip test modules in this tree use that form; the other
~113, including `tests/test_plugin_promo_574.py` -- the exact #588 incident
this rule cites as its motivation -- write the condition on its own line. The
rule would not have fired on the incident it was written to catch.

Explore also found a second issue: the old regex had no `pytestmark` anchor,
so it would also fire on a per-test `@pytest.mark.skipif(...)` decorator --
exactly the shape this repo's own declined trap
`487.ostype-immutable-on-windows-gitbash`
(`.claude/jit-context/tools/00-manual/00-README.md`) already reasoned a rule
should not restate, since the skip is already visible at the decorator site.

New pattern: `~pytestmark[^)]*skipif\([^)]*win32`. Requires `pytestmark`
somewhere before an unclosed `skipif(...win32...)` call, tolerating any
whitespace/newlines in between (including the list-form
`pytestmark = [pytest.mark.skipif(...), ...]`) while stopping at the first
literal `)`, so it does not cross into an unrelated statement. Re-verified
against `pre-tool-hook.sh` directly: fires on the real multi-line content of
`tests/test_plugin_promo_574.py`, fires on a synthetic single-line form,
stays silent on a per-test decorator with no `pytestmark`, and stays silent
on ordinary test content.

The auditor's other observation -- `tests/test_windows_skip_triage_497.py`
already catches the same doc/tree drift on every CI leg via an AST scan, so
this rule's only independent value is firing before push -- is now stated
in the entry's own body rather than left implicit.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bv6BGZD2EdZ9EuJ7tPDTb7

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cross-promote supertool and jit-context to the human via systemMessage, with a config bool to disable

1 participant