patterns: vendor session-explainer for offline init - #13
Merged
Conversation
Mirrors the new official pattern from the Worker repo so `htmlbin patterns init` installs it when the catalog is unreachable. src/patterns/bundled-data.ts is generated from patterns/*.md by scripts/build-bundled-patterns.mjs on prebuild/pretypecheck/pretest and is gitignored, so vendoring the markdown is the whole change. Also updates the htmlbin-publish skill, which names the bundled set explicitly and would otherwise go stale. Verified: file is byte-identical to the Worker repo's copy (SHA-256 ad4b0636…), and `patterns init` installs it correctly from both the live catalog and the offline bundled fallback, producing the same hash in all three places. Full suite green (162 passed, 6 skipped). Companion Worker PR: utsengar/htmlbin#41 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
session-explainer is prescriptive: it mandates one structure and ships a
reference skeleton rather than describing a layout in prose. The bundle
globbed patterns/*.md only, so an offline `patterns init` installed the
pattern without the structure it points at.
The skeleton now travels with the pattern on every path.
- scripts/build-bundled-patterns.mjs picks up a <name>.template.html
sibling and emits it as `template: { filename, body }`.
- init writes it from the bundle offline, and fetches it from the catalog
online. The pattern's own front matter decides whether to look, so the
three patterns without a skeleton cost no extra request.
- `patterns add <name>` gets it too, but only for catalog sources — a
file/gist/github source has nowhere well-defined to look, and guessing
would mean a speculative fetch.
- schema.ts learns two optional keys: `brand_scope` ("all" |
"colors-only") and `template`.
Two things worth calling out.
The skeleton is nested on its pattern's InstallResult rather than pushed
into `installed` as a sibling. First pass pushed it, which broke an
existing assertion (`installed` had an entry whose name already carried
an extension) and, worse, made installed.length stop meaning "patterns
installed". Nesting keeps that invariant and matches what `add` returns.
The destination filename is derived from the validated pattern name, never
from the catalog. A catalog entry is remote input, and `template:
../../../etc/passwd` would otherwise be a write outside the patterns dir.
schema.ts pins the value to `<name>.template.html` and there are tests for
the traversal cases.
Verified: 171 tests pass (was 162). init installs the skeleton from both
the live catalog and the bundled fallback, byte-identical to the worker's
copy by SHA-256, idempotent on a second run, and `patterns list` still
reports 4 patterns rather than counting the skeleton as a fifth.
Companion worker PR: utsengar/htmlbin#41
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to utsengar/htmlbin#41, which adds a fourth official pattern —
session-explainer, for publishing an agent session as a narrative (problem, approach, dead ends, what shipped) rather than dumping a transcript.What changed
patterns/session-explainer.md— vendored sohtmlbin patterns initworks offline.src/patterns/bundled-data.tsis generated frompatterns/*.mdbyscripts/build-bundled-patterns.mjsonprebuild/pretypecheck/pretestand is gitignored, so vendoring the markdown is the whole change — no generated file in the diff.skills/htmlbin-publish/SKILL.md— this skill names the bundled set explicitly (summary-roundup,pr-explainer,plan-spec-explainer) and would have gone stale. Now lists all four.Verification
ad4b0636…npm test— 162 passed, 6 skipped, including the 14patternse2e checkspatterns initverified end-to-end on both paths, each producing the same hash as source:--catalogpointed at a local Worker) → installs all 4Note (pre-existing, not from this PR)
npm run typecheckreports 4 errors intest/e2e/helpers.ts(execa option types). Confirmed identical onmain— left alone.🤖 Generated with Claude Code